Module inet.ipaddr
Package 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
      • overlaps

        boolean overlaps​(AddressSection other)
        Determines if one section overlaps 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 overlaps the given address section
      • enumerate

        java.math.BigInteger enumerate​(AddressSection other)
        Indicates where an address section sits relative to the ordering of individual address sections within this section.

        Determines how many address section elements precede the given address section element, if the given address section is within this address section. If above the range, it is the distance to the upper boundary added to the address section count less one, and if below the range, the distance to the lower boundary.

        In other words, if the given address section is not in this section but above it, returns the number of individual address sections preceding the given address section from the upper section boundary, added to one less than the total number of individual address sections within. If the given address section is not in this section but below it, returns the number of individual address sections following the given address section to the lower section boundary.

        enumerate returns null when the argument is a multi-valued section. The argument must be an individual address section.

        When this address section is also single-valued, the returned value is the distance (difference) between this address section and the argument address section.

        enumerate is the inverse of the increment method:

        • section.enumerate(section.increment(inc)) = inc
        • section.increment(section.enumerate(individualSection)) = individualSection
        If the given address section does not have the same version or type as this address section, then null is returned. If the given address section is the same version and type, but has a different segment count, then SizeMismatchException is thrown.
      • prefixEquals

        boolean prefixEquals​(AddressSection other)
        Determines if the argument section matches this section up to the prefix length of this section.

        The entire prefix of this section must be present in the other section to be comparable.

        For sections which are aware of their position in an address (IPv6 and MAC), the argument section must have the same or an earlier position in the address to match all prefix segments of this section, and the matching is lined up relative to the position.

        Parameters:
        other -
        Returns:
        whether the argument section has the same address section prefix as this
      • 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,
                                             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 boundary
        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,
                                          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. For an alternative that does not set bits to zero, use AddressSegmentSeries.setPrefixLength(int, boolean) with the second argument as false.

        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:
      • 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:
      • prefixStream

        java.util.stream.Stream<? extends AddressSection> prefixStream()
        Description copied from interface: AddressSegmentSeries
        Returns a sequential stream of the individual prefixes for the prefix length of this series. For a parallel stream, call BaseStream.parallel() on the returned stream.
        Specified by:
        prefixStream in interface AddressSegmentSeries
        Returns:
      • prefixBlockStream

        java.util.stream.Stream<? extends AddressSection> prefixBlockStream()
        Description copied from interface: AddressSegmentSeries
        Returns a sequential stream of the individual prefix blocks for the prefix length of this series. For a parallel stream, call BaseStream.parallel() on the returned stream.
        Specified by:
        prefixBlockStream in interface AddressSegmentSeries
        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, with the increment of 0 returning the first address in the range.

        If the subnet has multiple values and the increment exceeds the subnet size, then the amount by which it exceeds the size - 1 is added to the upper series of the range (the final iterator value).

        If the increment is negative, it is added to the lower series of the range (the first iterator value).

        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 AddressSegmentSeries.iterator() For instance, a increment of 0 is the first value from the iterator, an increment of 1 is the second value from the iterator, and so on. A negative increment added to the subnet count is equivalent to the same number of values preceding the upper bound of the iterator. For instance, an increment of count - 1 is the last value from the iterator, an increment of count - 2 is the second last value, and so on.

        An increment of size count gives you the series just above the highest series of the subnet. To get the series just below the lowest series of the subnet, use the increment -1.

        Specified by:
        increment in interface AddressSegmentSeries
        Returns:
      • incrementBoundary

        AddressSection incrementBoundary​(long increment)
        Description copied from interface: AddressSegmentSeries
        If the given increment is positive, adds the value to the upper series (AddressSegmentSeries.getUpper()) in the subnet range to produce a new series. If the given increment is negative, adds the value to the lower series (AddressSegmentSeries.getLower()) in the subnet range to produce a new series. If the increment is zero, returns this.

        In the case where the series is a single value, this simply returns the address produced by adding the given increment to this address series.

        Specified by:
        incrementBoundary in interface AddressSegmentSeries
        Returns: