inet.ipaddr.format

Interface AddressDivisionSeries

    • Method Detail

      • isMore

        int isMore(AddressDivisionSeries other)
        Use this method to compare the counts of two address series. Rather than calculating counts with getCount(), there can be more efficient ways of comparing whether one series represents more individual address series than another.
        Returns:
        a positive integer if this AddressDivisionSeries has a larger count than the provided, 0 if they are the same, a negative integer if the other has a larger count.
      • isPrefixed

        boolean isPrefixed()
        Whether there exists a prefix.
      • getPrefixLength

        java.lang.Integer getPrefixLength()
        The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.

        Typically this is the largest number of bits in the upper-most portion of the section for which the remaining bits assume all possible values.

        For IP addresses, this must be explicitly defined when the address is created. For example, 1.2.0.0/16 has a prefix length of 16, while 1.2.*.* has no prefix length, even though they both represent the same set of addresses and are considered equal. Prefixes can be considered variable for any given IP addresses and can depend on the routing table.

        The methods getMinPrefixLengthForBlock() and getPrefixLengthForSingleBlock() can help you to obtain or define a prefix length if one does not exist already. 1.2.0.0/16 and 1.2.*.* both the same equivalent and minimum prefix length of 16.

        For MAC addresses, the prefix is initially defined by the range, so 1:2:3:*:*:* has a prefix length of 24 by definition. Addresses derived from the original may retain the original prefix length regardless of their range.

      • isPrefixBlock

        boolean isPrefixBlock()
        Returns whether this address segment series represents a block of addresses associated with its prefix length.

        This returns false if it has no prefix length or if it is a range of addresses that does not include the entire subnet block for the prefix length.

        If AddressNetwork.getPrefixConfiguration() is set to consider all prefixes as subnets, this returns true for any series with a prefix length.

        Returns:
      • containsPrefixBlock

        boolean containsPrefixBlock(int prefixLength)
                             throws PrefixLenException
        Returns whether the values of this series contains the prefix block for the given prefix length. An important distinction of this method with isPrefixBlock() is that isPrefixBlock() returns false if the series does not have a prefix length assigned to it, even if there exists one or more prefix lengths for which containsPrefixBlock(int) returns true. This method simply returns whether it contains all the values for the given prefix length block regardless of whether that prefix length has been assigned to this series.

        Use getMinPrefixLengthForBlock() to determine the smallest prefix length for which this method returns true.

        Parameters:
        prefixLength -
        Returns:
        Throws:
        PrefixLenException - if prefixLength exceeds the bit count or is negative
      • isSinglePrefixBlock

        boolean isSinglePrefixBlock()
        Returns whether the range of values matches a single subnet block for the prefix length
        Returns:
      • containsSinglePrefixBlock

        boolean containsSinglePrefixBlock(int prefixLength)
                                   throws PrefixLenException
        Returns whether the values of this series contains a single prefix block for the given prefix length. An important distinction of this method with isSinglePrefixBlock() is that isSinglePrefixBlock() returns false if the series does not have a prefix length assigned to it, even if there exists a prefix length for which containsSinglePrefixBlock(int) returns true. This method simply returns whether it contains exactly the values for the given prefix length block regardless of whether that prefix length has been assigned to this series.

        Use getPrefixLengthForSingleBlock() to determine whether there is a prefix length for which this method returns true.

        Parameters:
        prefixLength -
        Returns:
        Throws:
        PrefixLenException - if prefixLength exceeds the bit count or is negative
      • getPrefixCount

        java.math.BigInteger getPrefixCount()
        If this has a prefix length, the count of the range of values in the prefix.

        If this has no prefix length, returns the same value as AddressItem.getCount()

        Returns:
      • getMinPrefixLengthForBlock

        int getMinPrefixLengthForBlock()
        Returns the smallest prefix length possible such that this address division series includes the block of addresses for that prefix.

        If the entire range can be dictated this way, then this method returns the same value as getPrefixLengthForSingleBlock(). Otherwise, this method will return the minimal possible prefix that can be paired with this address, while getPrefixLengthForSingleBlock() will return null.

        In cases where the final bit in this address division series is constant, this returns the bit length of this address division series.

        Returns:
        the prefix length
      • getPrefixLengthForSingleBlock

        java.lang.Integer getPrefixLengthForSingleBlock()
        Returns a prefix length for which the range of this division series matches the the block of addresses for that prefix.

        If the range can be dictated this way, then this method returns the same value as getMinPrefixLengthForBlock().

        If no such prefix exists, returns null.

        If this segment grouping represents a single value, returns the bit length of this address division series.

        Returns:
        the prefix length or null
      • getDivisionStrings

        java.lang.String[] getDivisionStrings()
        Get standard-format strings for each of the divisions in the series.
        Returns:
      • getValue

        java.math.BigInteger getValue()
        Returns:
        the value of the lowest address item represented by this address division series
      • getUpperValue

        java.math.BigInteger getUpperValue()
        Returns:
        the value of the highest address item represented by this address division series