inet.ipaddr.format

Class AddressDivisionGrouping

  • java.lang.Object
    • inet.ipaddr.format.AddressDivisionGrouping
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  AddressDivisionGrouping.StringOptions
      Represents a clear way to create a specific type of string.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int compareTo(AddressDivisionGrouping other) 
      boolean equals(java.lang.Object o) 
      int getBitCount() 
      byte[] getBytes()
      Gets the bytes for the lowest address in the range represented by this address.
      byte[] getBytes(byte[] bytes)
      Gets the value for the lowest address in the range represented by this address division.
      java.math.BigInteger getCount()
      gets the count of addresses that this address may represent If this address is not a CIDR and it has no range, then there is only one such address.
      AddressDivision getDivision(int index) 
      int getDivisionCount() 
      java.lang.Integer getEquivalentPrefix()
      Returns a prefix length for which the range of this segment grouping can be specified only using the section's lower value and the prefix length If no such prefix exists, returns null If this segment grouping represents a single value, returns the bit length
      int getMinPrefix()
      Returns the smallest prefix length possible such that this address paired with that prefix length represents the exact same range of addresses.
      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.
      byte[] getUpperBytes()
      Gets the bytes for the highest address in the range represented by this address.
      byte[] getUpperBytes(byte[] bytes)
      Copies the bytes of the largest address item represented by this address item into the supplied array, and returns that array.
      int hashCode() 
      boolean isFullRange() 
      int isMore(AddressDivisionSeries other)
      Use this method to compare the counts of two address series.
      boolean isMultiple()
      Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
      boolean isMultipleByPrefix()
      whether there is a prefix and it is less than the bit-count
      boolean isPrefixed()
      Whether there exists a prefix.
      boolean isRangeEquivalent(int prefix) 
      boolean isRangeEquivalentToPrefix()
      whether there is a prefix and the range of values is dictated entirely by the prefix.
      boolean isZero() 
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AddressDivisionGrouping

        public AddressDivisionGrouping(AddressDivision[] divisions)
    • Method Detail

      • getBitCount

        public int getBitCount()
        Specified by:
        getBitCount in interface AddressItem
        Returns:
        the number of bits in this item
      • getBytes

        public byte[] getBytes()
        Gets the bytes for the lowest address in the range represented by this address. Since bytes are signed values while addresses are unsigned, values greater than 127 are represented as the (negative) two's complement value of the actual value. You can get the unsigned integer value i from byte b using i = 0xff & b.
        Specified by:
        getBytes in interface AddressItem
        Returns:
      • getBytes

        public byte[] getBytes(byte[] bytes)
        Gets the value for the lowest address in the range represented by this address division. If the value fits in the specified array, the same array is returned with the value. Otherwise, a new array is allocated and returned with the value. You can use getBitCount() to determine the required array length for the bytes. Since bytes are signed values while addresses are unsigned, values greater than 127 are represented as the (negative) two's complement value of the actual value. You can get the unsigned integer value i from byte b using i = 0xff & b.
        Specified by:
        getBytes in interface AddressItem
        Returns:
      • getUpperBytes

        public byte[] getUpperBytes()
        Gets the bytes for the highest address in the range represented by this address.
        Specified by:
        getUpperBytes in interface AddressItem
        Returns:
      • getUpperBytes

        public byte[] getUpperBytes(byte[] bytes)
        Description copied from interface: AddressItem
        Copies the bytes of the largest address item represented by this address item into the supplied array, and returns that array. If the supplied array is null or of insufficient size, a new array is created and returned.
        Specified by:
        getUpperBytes in interface AddressItem
        Returns:
        the bytes of the largest address represented by this address item.
      • getPrefixLength

        public java.lang.Integer getPrefixLength()
        Description copied from interface: AddressDivisionSeries
        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 getMinPrefix and getEquivalentPrefix 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 implicit, so 1:2:3:*:*:* has a prefix length of 24 by definition. Generally prefixes are not variable for a given address. Either an address has a prefix or not, the one assigned by the IEEE. There is no way to explicitly define the prefix in a representation of a MAC address. The prefix length is instead determined by the address itself when created.
        Specified by:
        getPrefixLength in interface AddressDivisionSeries
      • getMinPrefix

        public int getMinPrefix()
        Returns the smallest prefix length possible such that this address paired with that prefix length represents the exact same range of addresses.
        Specified by:
        getMinPrefix in interface AddressDivisionSeries
        Returns:
        the prefix length
      • getEquivalentPrefix

        public java.lang.Integer getEquivalentPrefix()
        Returns a prefix length for which the range of this segment grouping can be specified only using the section's lower value and the prefix length If no such prefix exists, returns null If this segment grouping represents a single value, returns the bit length
        Specified by:
        getEquivalentPrefix in interface AddressDivisionSeries
        Returns:
        the prefix length or null
      • getCount

        public java.math.BigInteger getCount()
        gets the count of addresses that this address may represent If this address is not a CIDR and it has no range, then there is only one such address.
        Specified by:
        getCount in interface AddressItem
        Returns:
      • isMore

        public int isMore(AddressDivisionSeries other)
        Description copied from interface: AddressDivisionSeries
        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.
        Specified by:
        isMore in interface AddressDivisionSeries
        Returns:
        > 0 if this AddressDivisionSeries has a larger count than the provided, 0 if they are the same, < 0 if the other has a larger count.
      • isMultiple

        public boolean isMultiple()
        Description copied from interface: AddressItem
        Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
        Specified by:
        isMultiple in interface AddressItem
        Returns:
        whether this address represents more than one address. Such addresses include CIDR/IP addresses (eg 1.2.3.4/11) or wildcard addresses (eg 1.2.*.4) or range addresses (eg 1.2.3-4.5)
      • isMultipleByPrefix

        public boolean isMultipleByPrefix()
        Description copied from interface: AddressDivisionSeries
        whether there is a prefix and it is less than the bit-count
        Specified by:
        isMultipleByPrefix in interface AddressDivisionSeries
        Returns:
        there is a prefix and there are multiple addresses associated with that prefix
      • isRangeEquivalent

        public boolean isRangeEquivalent(int prefix)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isZero

        public boolean isZero()
        Specified by:
        isZero in interface AddressItem
        Returns:
        whether this item has the value of zero
      • isFullRange

        public boolean isFullRange()
        Specified by:
        isFullRange in interface AddressItem
        Returns:
        whether this address item represents all possible values attainable by an address item of this type.