inet.ipaddr.format

Class IPAddressSegmentGrouping

  • java.lang.Object
    • inet.ipaddr.format.IPAddressSegmentGrouping
  • All Implemented Interfaces:
    IPAddressPart, java.io.Serializable, java.lang.Comparable<IPAddressSegmentGrouping>
    Direct Known Subclasses:
    IPAddressSection, IPv6AddressSection.IPv6v4MixedAddressSection


    public class IPAddressSegmentGrouping
    extends java.lang.Object
    implements IPAddressPart, java.lang.Comparable<IPAddressSegmentGrouping>
    IPAddressSegmentGrouping 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) IPAddressSegmentGrouping objects are immutable. Some of the derived state is created upon demand and cached. This also makes them thread-safe.

    See Also:
    Serialized Form
    • Constructor Detail

      • IPAddressSegmentGrouping

        public IPAddressSegmentGrouping(IPAddressDivision[] divisions)
    • Method Detail

      • getBitCount

        public int getBitCount()
      • isPrefixed

        public boolean isPrefixed()
        Returns:
        whether this address represents a network prefix or the set of all addresses with the same network prefix
      • getNetworkPrefixLength

        public java.lang.Integer getNetworkPrefixLength()
        Description copied from interface: IPAddressPart
        Returns the network prefix, which is 16 for an address like 1.2.0.0/16 If there is no prefix length, returns null.
        Specified by:
        getNetworkPrefixLength in interface IPAddressPart
        Returns:
        the prefix length
      • 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.
        Returns:
      • isMultiple

        public boolean isMultiple()
        Description copied from interface: IPAddressPart
        whether this is a pat of more than one address. In other words, it is the same part of many potential addresses.
        Specified by:
        isMultiple in interface IPAddressPart
        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)
      • isMultipleByNetworkPrefix

        public boolean isMultipleByNetworkPrefix()
      • isRangeEquivalentToPrefix

        public boolean isRangeEquivalentToPrefix()
        Returns:
        whether this address represents more than one address determined entirely by the network prefix length.
      • 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()