- All Implemented Interfaces:
AddressGenericDivision
,AddressItem
,IPAddressGenericDivision
,AddressStringDivision
,IPAddressStringDivision
,Serializable
,Comparable<AddressItem>
- Direct Known Subclasses:
IPAddressBitsDivision
,IPAddressJoinedSegments
,IPAddressSegment
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class inet.ipaddr.format.standard.AddressDivision
AddressDivision.BitwiseOrResult, AddressDivision.MaskResult
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsPrefixBlock
(int divisionPrefixLen) Returns whether the values of this series contains the prefix block for the given prefix length.boolean
containsSinglePrefixBlock
(int divisionPrefixLen) Returns whether the division range matches exactly the block of values for the given prefix length.getBlockMaskPrefixLength
(boolean network) If this is equivalent to the mask for a CIDR prefix length block or subnet class, it returns the prefix length.Returns the network prefix for the division.int
getLeadingBitCount
(boolean network) Returns the number of consecutive leading one or zero bits.int
getPrefixAdjustedRangeString
(int segmentIndex, AddressSegmentParams params, StringBuilder appendable) 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.Produces a normalized string to represent the segment.int
getTrailingBitCount
(boolean network) Returns the number of consecutive trailing one or zero bits.Produces a string to represent the segment, favouring wildcards and range characters over the network prefix to represent subnets.boolean
Returns whether the division range includes the block of values for its prefix lengthboolean
boolean
Returns whether the division range matches the block of values for its prefix lengthboolean
matchesWithPrefixMask
(long value, Integer divisionPrefixLen) Methods inherited from class inet.ipaddr.format.standard.AddressDivision
bitwiseOrRange, equals, getCount, getDigitCount, getDivisionPrefixCount, getDivisionValue, getDivisionValueCount, getMaxDigitCount, getMaxValue, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperDivisionValue, getUpperValue, getValue, hashCode, hasUppercaseVariations, includesMax, includesZero, isBitwiseOrCompatibleWithRange, isBoundedBy, isMaskCompatibleWithRange, isMax, isMultiple, isZero, maskRange, matches, matchesWithMask, matchesWithMask
Methods inherited from class inet.ipaddr.format.AddressDivisionBase
getBytes, getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toString
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, getBitCount, getByteCount, getBytes, getBytes, getBytes, getCount, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isZero
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivision
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardString, isBoundedBy
Methods inherited from interface inet.ipaddr.format.IPAddressGenericDivision
isFullRange
Methods inherited from interface inet.ipaddr.format.string.IPAddressStringDivision
getBitCount
-
Method Details
-
isPrefixed
public boolean isPrefixed()- Specified by:
isPrefixed
in interfaceIPAddressGenericDivision
-
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 interfaceIPAddressStringDivision
- Returns:
-
matchesWithPrefixMask
-
getBlockMaskPrefixLength
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:
-
getTrailingBitCount
public int getTrailingBitCount(boolean network) Returns the number of consecutive trailing one or zero bits. If network is true, returns the number of consecutive trailing zero bits. Otherwise, returns the number of consecutive trailing one bits.This method applies only to the lower value of the range if this segment represents multiple values.
- Parameters:
network
-- Returns:
-
getLeadingBitCount
public int getLeadingBitCount(boolean network) Returns the number of consecutive leading one or zero bits. If network is true, returns the number of consecutive leading one bits. Otherwise, returns the number of consecutive leading zero bits.This method applies only to the lower value of the range if this segment represents multiple values.
- Parameters:
network
-- Returns:
-
containsPrefixBlock
public boolean containsPrefixBlock(int divisionPrefixLen) Description copied from interface:AddressItem
Returns whether the values of this series contains the prefix block for the given prefix length.Use
AddressItem.getMinPrefixLengthForBlock()
to determine the smallest prefix length for which this method returns true.- Specified by:
containsPrefixBlock
in interfaceAddressItem
- Parameters:
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 interfaceIPAddressStringDivision
- Returns:
- whether the division range includes the block of values for the division prefix length, or false if the division has no prefix length
-
containsSinglePrefixBlock
public boolean containsSinglePrefixBlock(int divisionPrefixLen) Returns whether the division range matches exactly the block of values for the given prefix length.- Specified by:
containsSinglePrefixBlock
in interfaceAddressItem
- 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 interfaceIPAddressStringDivision
- Returns:
- whether the division range matches exactly the block of values for its prefix length.
-
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
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, 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 interfaceIPAddressStringDivision
- Returns:
- if the supplied appendable is null, returns the length of the string that would have been appended, otherwise returns 0
-