inet.ipaddr

Interface AddressSection

    • Method Detail

      • contains

        boolean contains(AddressSection other)
        Determines if one section contains another. Sections must have the same number of segments to be comparable. For sections which are aware of their position in an address (IPv6 and MAC), their respective positions must match to be comparable.
        Parameters:
        other -
        Returns:
        whether this section contains the given address section
      • toPrefixBlock

        AddressSection toPrefixBlock()
        Description copied from interface: AddressSegmentSeries
        If this series has a prefix length, returns the block for that prefix. Otherwise, this address series is returned.
        Specified by:
        toPrefixBlock in interface AddressSegmentSeries
        Returns:
        the block of address series for the prefix length
      • adjustPrefixBySegment

        AddressSection adjustPrefixBySegment(boolean nextSegment)
        Description copied from interface: AddressSegmentSeries
        Increases or decreases prefix length to the next segment boundary.

        Follows the same rules as AddressSegmentSeries.adjustPrefixLength(int):
        When prefix length is increased, the bits moved within the prefix become zero. When a prefix length is decreased, the bits moved outside the prefix become zero.

        Specified by:
        adjustPrefixBySegment in interface AddressSegmentSeries
        Parameters:
        nextSegment - whether to move prefix to previous or following segment coundary
        Returns:
      • adjustPrefixBySegment

        AddressSection adjustPrefixBySegment(boolean nextSegment,
                                             boolean zeroed)
        Description copied from interface: AddressSegmentSeries
        Increases or decreases prefix length to the next segment boundary.
        Specified by:
        adjustPrefixBySegment in interface AddressSegmentSeries
        Parameters:
        nextSegment - whether to move prefix to previous or following segment coundary
        zeroed - whether the bits that move from one side of the prefix to the other become zero or retain their original values
        Returns:
      • adjustPrefixLength

        AddressSection adjustPrefixLength(int adjustment)
        Description copied from interface: AddressSegmentSeries
        Increases or decreases prefix length by the given increment.

        When prefix length is increased, the bits moved within the prefix become zero. When the prefix is extended beyond the segment series boundary, it is removed. When a prefix length is decreased, the bits moved outside the prefix become zero.

        Specified by:
        adjustPrefixLength in interface AddressSegmentSeries
        Returns:
      • adjustPrefixLength

        AddressSection adjustPrefixLength(int adjustment,
                                          boolean zeroed)
        Description copied from interface: AddressSegmentSeries
        Increases or decreases prefix length by the given increment.
        Specified by:
        adjustPrefixLength in interface AddressSegmentSeries
        Parameters:
        adjustment - the increment
        zeroed - whether the bits that move from one side of the prefix to the other become zero or retain their original values
        Returns:
      • setPrefixLength

        AddressSection setPrefixLength(int prefixLength)
        Description copied from interface: AddressSegmentSeries
        Sets the prefix length.

        If this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero.

        When the prefix is extended beyond the segment series boundary, it is removed.

        The bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.

        Specified by:
        setPrefixLength in interface AddressSegmentSeries
        Returns:
        See Also:
        AddressSegmentSeries.applyPrefixLength(int)
      • setPrefixLength

        AddressSection setPrefixLength(int prefixLength,
                                       boolean zeroed)
        Description copied from interface: AddressSegmentSeries
        Sets the prefix length.

        When the prefix is extended beyond the segment series boundary, it is removed.

        Specified by:
        setPrefixLength in interface AddressSegmentSeries
        zeroed - whether the bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.
        Returns:
      • increment

        AddressSection increment(long increment)
        Description copied from interface: AddressSegmentSeries
        Returns the series from the subnet that is the given increment upwards into the subnet range, or if the given increment is negative the given increment downwards into the subnet range, or if this is just an individual series, it simply adds the increment to this. If the increment is 0, then this series is returned.

        If the subnet has multiple values and the increment exceeds the subnet size, then the amount by which is exceeds the size is added to the upper series of the range (the final iterator value) or is subtracted from the lower series of the range (the first iterator value) if negative.

        If the subnet is just a single address values, the series is simply incremented by the given value, positive or negative.

        If a subnet has multiple values, a positive increment value is equivalent to the same number of values from the iterator. For instance, a increment of 1 is value 1 from the iterator, an increment of 2 is the second value from the iterator, and so on. A negative increment is equivalent to the same number of values preceding the upper bound of the iterator. For instance, an increment of -1 is the last value from the iterator, and increment of -2 is the second last value, and so on.

        Therefore, to get the series just above the highest series of the subnet, use an increment of size:count > 1 ? count + 1 : 1 where count is the subnet size. To get the series just below the lowest series of the subnet, use an increment of size:-(count > 1 ? count + 1 : 1) where count is the subnet size.

        Specified by:
        increment in interface AddressSegmentSeries
        Returns: