inet.ipaddr.format

Class IPAddressDivision

  • java.lang.Object
    • inet.ipaddr.format.IPAddressDivision
    • Field Detail

      • ADJUST_RANGES_BY_PREFIX

        public static final boolean ADJUST_RANGES_BY_PREFIX
        See Also:
        Constant Field Values
    • Method Detail

      • isMultiple

        public boolean isMultiple()
        Returns:
        whether this segment represents multiple values
      • getBitCount

        public abstract int getBitCount()
      • getByteCount

        public abstract int getByteCount()
      • isPrefixed

        public boolean isPrefixed()
      • getDivisionPrefixLength

        public java.lang.Integer getDivisionPrefixLength()
        Returns the network prefix for the division. The network prefix is 16 for an address like 1.2.0.0/16. When it comes to each address division or segment, the prefix for the division is the prefix obtained when applying the address or section prefix. For instance, with the address 1.2.0.0/20, segment 1 has no prefix because the address prefix 20 extends beyond the 8 bits in the first segment, it does not even apply to the segment, segment 2 has no prefix because the address prefix extends beyond bits 9 to 16 which lie in the second segment, it does not apply to that segment either, segment 3 has the prefix 4 because the address prefix 20 corresponds to the first 4 bits in the 3rd segment, which means that the first 4 bits are part of the network section of the address or segment, and segment 4 has the prefix 0 because not a single bit is in the network section of the address or segment The prefix applied across the address is null ... null ... (1 to segment bit length) ... 0 ... 0 If the segment has no prefix then null is returned.
        Returns:
      • isZero

        public boolean isZero()
      • getLowerValue

        public abstract long getLowerValue()
      • getUpperValue

        public abstract long getUpperValue()
      • getCount

        public long getCount()
      • rangeIsWithin

        public boolean rangeIsWithin(long lower,
                                     long upper)
      • valueIsWithin

        public boolean valueIsWithin(long lower,
                                     long upper)
      • matches

        public boolean matches(long value)
      • matchesWithPrefix

        public boolean matchesWithPrefix(long value,
                                         java.lang.Integer divisionPrefixLen)
      • matchesWithMask

        public boolean matchesWithMask(int value,
                                       long mask)
      • getMaskPrefixLength

        public java.lang.Integer getMaskPrefixLength(boolean network)
        If this is equivalent to the mask for a CIDR prefix, it returns that prefix length. Otherwise, it returns null. A CIDR network mask is an address with all 1s in the network section (the upper bits) and then all 0s in the host section. A CIDR host mask is an address with all 0s in the network section (the lower bits) and then all 1s in the host section. The prefix length is the length of the network section. Also, keep in mind that the prefix length returned by this method is not equivalent to the prefix length used to construct this object. The prefix length used to construct indicates the network and host portion of this address. The prefix length returned here indicates the whether the value of this address can be used as a mask for the network and host of an address with that prefix length. Therefore the two values can be different values, or one can be null while the other is not. This method applies only to the lower value of the range if this segment represents multiple values.
        Parameters:
        network - whether to check for a network mask or a host mask
        Returns:
        the prefix length corresponding to this mask, or null if this address is not a CIDR prefix mask
        See Also:
        IPAddressSection.getEquivalentPrefix()
      • isSamePrefixedRange

        public boolean isSamePrefixedRange(long lowerValue)
        Parameters:
        lowerValue -
        Returns:
        whether the range of this segment matches the range of a segment with the given value and the CIDR prefix length of this segment
      • isRangeEquivalent

        public boolean isRangeEquivalent(java.lang.Integer divisionPrefixLen)
        Parameters:
        divisionPrefixLen -
        Returns:
        whether the range of this segment can be specified only using the segment's lower value and the given prefix length If the prefix is null or equal to the bit length, then this returns true for non-multiple addresses.
      • isRangeUnchanged

        public boolean isRangeUnchanged(java.lang.Integer divisionPrefixLen)
        Parameters:
        divisionPrefixLen -
        Returns:
        whether the given range remains the same with the given prefix applied
      • isRangeEquivalentToPrefix

        public boolean isRangeEquivalentToPrefix()
        Returns:
        whether the range of this segment can be specified only using the segment's lower value and the segment's prefix length
      • isFullRange

        public boolean isFullRange()
      • isMaskCompatibleWithRange

        public boolean isMaskCompatibleWithRange(long maskValue,
                                                 java.lang.Integer divisionPrefixLen)
      • getDefaultTextualRadix

        public abstract int getDefaultTextualRadix()
        Returns:
        the default radix for textual representations of addresses (10 for IPv4, 16 for IPv6)
      • getDefaultMaxChars

        public abstract int getDefaultMaxChars()
        Returns:
        the max number of characters per segment when using the default radix
      • hasAlphabeticDigits

        public boolean hasAlphabeticDigits(int base,
                                           boolean lowerOnly)
      • defaultMaxCharsPerSegment

        public static int defaultMaxCharsPerSegment(IPAddress.IPVersion version)
      • getDefaultMaxChars

        public int getDefaultMaxChars(int radix)
      • getCharWidth

        public static int getCharWidth(long value,
                                       int radix)
      • getMaxLeadingZeros

        public int getMaxLeadingZeros(int radix)
      • toString

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

        public java.lang.String getString()
        Produces a normalized string to represent the segment. If the segment CIDR prefix length covers the range, then it is assumed to be a CIDR, and the string has only the lower value of the CIDR range. Otherwise, the explicit range will be printed.
        Returns:
      • getWildcardString

        public java.lang.String getWildcardString()
        Produces a string to represent the segment, favouring wildcards and range characters over the network prefix to represent subnets. If it exists, the segment CIDR prefix is ignored and the explicit range is printed.
        Returns:
      • getWildcardString

        public int getWildcardString(IPAddressSection.WildcardOptions.Wildcards wildcards,
                                     int leadingZeroCount,
                                     java.lang.String stringPrefix,
                                     int radix,
                                     boolean uppercase,
                                     boolean splitDigits,
                                     char splitDigitSeparator,
                                     boolean reverseSplitDigits,
                                     java.lang.StringBuilder appendable)
        Produces a string to represent the segment, favouring wildcards and range characters over the network prefix to represent subnets. Use this instead of getWildcardString() if you have a customized wildcard or range separator or you have a non-zero leadingZeroCount, or you have a string prefix, or you have a non-standard radix (for IPv4 standard radix is 10, for IPv6 it is 16)
      • getPrefixAdjustedWildcardString

        public int getPrefixAdjustedWildcardString(IPAddressSection.WildcardOptions.Wildcards wildcards,
                                                   int leadingZeroCount,
                                                   java.lang.String stringPrefix,
                                                   int radix,
                                                   boolean uppercase,
                                                   java.lang.StringBuilder appendable)
        Produces a string to represent the segment.

        Use this instead of #getWildcardString(Wildcards, int, String, int, boolean, StringBuilder) if you wish to avoid printing wildcards in the host section of the address.

        Use this instead of getString() if you have a customized wildcard or range separator or you have a non-zero leadingZeroCount, or you have a string prefix, or you have a non-default radix (for IPv4 default radix is 10, for IPv6 it is 16)

        Returns:
        if the supplied appendable is null, returns the length of the string that would have been appended, otherwise returns 0