inet.ipaddr.format

Class IPAddressDivisionGrouping

  • All Implemented Interfaces:
    AddressDivisionSeries, AddressItem, AddressStringDivisionSeries, IPAddressStringDivisionSeries, java.io.Serializable, java.lang.Comparable<AddressDivisionGrouping>
    Direct Known Subclasses:
    IPAddressSection, IPv6AddressSection.IPv6v4MixedAddressSection


    public class IPAddressDivisionGrouping
    extends AddressDivisionGrouping
    implements IPAddressStringDivisionSeries
    IPAddressDivisionGrouping objects consist of a series of IPAddressDivision objects, each division containing one or more segments.

    With the IPAddressSection subclass, each division is one segment (eg either groupings of 4 like 1.2.3.4 or groupings of 8 like 1:2:3:4:5:6:7:8). For IPv6, a compressed segment still counts as one of the groupings, it is simply not printed as part of the text representation. Alternative groupings include ipv4 groupings define by inet_aton (eg groupings of 1, 2, or 3 divisions like 1, 1.2, and 1.2.3) and the mixed ipv6/ipv4 representation of ipv6 addresses (eg a grouping of 10 divisions like a:b:c:d:e:f:1.2.3.4) IPAddressDivisionGrouping objects are immutable. Some of the derived state is created upon demand and cached. This also makes them thread-safe. May be associated with a prefix length, in which case that number of bits in the upper-most portion of the object represent a prefix, while the remaining bits can assume all possible values.

    See Also:
    Serialized Form
    • Constructor Detail

      • IPAddressDivisionGrouping

        public IPAddressDivisionGrouping(IPAddressDivision[] divisions)
    • Method Detail

      • 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
        Overrides:
        isMore in class AddressDivisionGrouping
        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.
      • 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
        Specified by:
        getPrefixLength in interface IPAddressStringDivisionSeries
        Overrides:
        getPrefixLength in class AddressDivisionGrouping
        Returns:
        the prefix length or null if there is none
      • getNetworkPrefixLength

        public java.lang.Integer getNetworkPrefixLength()
      • isMultipleByNetworkPrefix

        public boolean isMultipleByNetworkPrefix()
      • getEquivalentPrefix

        public java.lang.Integer getEquivalentPrefix()
        Description copied from class: AddressDivisionGrouping
        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
        Overrides:
        getEquivalentPrefix in class AddressDivisionGrouping
        Returns:
        the prefix length or null