inet.ipaddr.format

Class IPAddressDivision

    • Method Detail

      • 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.
        Specified by:
        getDivisionPrefixLength in interface IPAddressStringDivision
        Returns:
      • matchesWithPrefixMask

        public boolean matchesWithPrefixMask(long value,
                                             java.lang.Integer divisionPrefixLen)
      • getBlockMaskPrefixLength

        public java.lang.Integer getBlockMaskPrefixLength(boolean network)
        If this is equivalent to the mask for a CIDR prefix length block or subnet class, it returns the 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 there is no such prefix length
        See Also:
        IPAddressSection.getPrefixLengthForSingleBlock()
      • isPrefixBlock

        public boolean isPrefixBlock(int divisionPrefixLen)
        Returns:
        whether the division range includes the block of values for the given prefix length
      • isPrefixBlock

        public boolean isPrefixBlock()
        Description copied from interface: IPAddressStringDivision
        Returns whether the division range includes the block of values for its prefix length
        Specified by:
        isPrefixBlock in interface IPAddressStringDivision
        Returns:
        whether the division range includes the block of values for the division prefix length, or false if the division has no prefix length
      • isSinglePrefixBlock

        public boolean isSinglePrefixBlock(int divisionPrefixLen)
        Returns whether the division range matches exactly the block of values for the given prefix length. If the given prefix length is null, return false.
        Parameters:
        divisionPrefixLen -
        Returns:
        whether the range of this division matches the range for a single prefix with a single value and the given prefix length.
      • isSinglePrefixBlock

        public boolean isSinglePrefixBlock()
        Description copied from interface: IPAddressStringDivision
        Returns whether the division range matches the block of values for its prefix length
        Specified by:
        isSinglePrefixBlock in interface IPAddressStringDivision
        Returns:
        whether the division range matches exactly the block of values for its prefix length.
      • 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.
        Overrides:
        getString in class AddressDivisionBase
        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:
      • getPrefixAdjustedRangeString

        public int getPrefixAdjustedRangeString(int segmentIndex,
                                                AddressSegmentParams params,
                                                java.lang.StringBuilder appendable)
        Description copied from interface: IPAddressStringDivision
        Produces a string to represent the segment of the form a-b where the value b has been adjusted for the prefix, anything beyond the prefix length being zero.
        Specified by:
        getPrefixAdjustedRangeString in interface IPAddressStringDivision
        Returns:
        if the supplied appendable is null, returns the length of the string that would have been appended, otherwise returns 0