- All Implemented Interfaces:
AddressDivisionSeries
,AddressItem
,AddressStringDivisionSeries
,Serializable
,Comparable<AddressItem>
- Direct Known Subclasses:
AddressDivisionGrouping
,IPAddressLargeDivisionGrouping
AddressDivisionGrouping objects are immutable. This also makes them thread-safe.
AddressDivision objects use long to represent their values, so this places a cap on the size of the divisions in AddressDivisionGrouping.
- Author:
- sfoley
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAddressDivisionGroupingBase
(AddressDivisionBase[] divisions) AddressDivisionGroupingBase
(AddressDivisionBase[] divisions, boolean checkDivisions) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Two groupings are equal if: - they match type/version (ipv4, ipv6, mac, or a specific grouping class) - they match division counts - each division matches bit counts - each division matches their specific grouping class - each division matches values Prefix lengths, for those groupings and/or divisionsS that have them, are ignored.byte[]
getBytes()
Gets the bytes for the lowest address in the range represented by this address.byte[]
getBytes
(byte[] bytes) Equivalent togetBytes(byte[], int)
with index of 0.byte[]
getBytes
(byte[] bytes, int index) Gets the value for the lowest address in the range represented by this address division.getCount()
gets the count of addresses that this address division grouping may represent If this address division grouping is not a subnet block of multiple addresses or has no range of values, then there is only one such address.getDivision
(int index) int
String[]
Get standard-format strings for each of the divisions in the series.int
Returns the smallest prefix length possible such that this address division grouping includes the block of addresses for that prefix.If this has a prefix length, the count of the range of values in the prefix.The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.Returns a prefix length for which the range of this segment grouping matches the block of addresses for that prefix.byte[]
Gets the bytes for the highest address in the range represented by this address.byte[]
getUpperBytes
(byte[] bytes) Equivalent togetBytes(byte[], int)
with index of 0.byte[]
getUpperBytes
(byte[] bytes, int index) Similar togetBytes(byte[], int)
, but for obtaining the upper value of the range.Returns the highest value represented by this address item, the highest value included in the range of valuesgetValue()
Returns the lowest value represented by this address item, the lowest value included in the range of valuesint
hashCode()
boolean
Returns whether this item includes the maximum possible value for the address type or version within its rangeboolean
Returns whether this item includes the value of zero within its rangeboolean
whether this address item represents all possible values attainable by an address item of this typeboolean
isMax()
Returns whether this item matches the maximum possible value for the address type or versionboolean
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)boolean
Returns whether this address segment series represents a block of addresses associated with its prefix length.boolean
Whether there exists a prefix length associated with this series.boolean
Returns whether the range of values matches a single subnet block for the prefix lengthboolean
isZero()
Returns whether this item matches the value of zerotoString()
Methods inherited from interface inet.ipaddr.format.AddressDivisionSeries
getBitCount, getBlockCount, getPrefixCount, getSequentialBlockIndex, isMore, isSequential
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getByteCount
-
Constructor Details
-
AddressDivisionGroupingBase
-
AddressDivisionGroupingBase
-
-
Method Details
-
getDivision
- Specified by:
getDivision
in interfaceAddressDivisionSeries
- Specified by:
getDivision
in interfaceAddressStringDivisionSeries
- Returns:
- the given division in this series. The first is at index 0.
-
getDivisionCount
public int getDivisionCount()- Specified by:
getDivisionCount
in interfaceAddressStringDivisionSeries
-
getBytes
public byte[] getBytes()Gets the bytes for the lowest address in the range represented by this address.Since bytes are signed values while addresses are unsigned, values greater than 127 are represented as the (negative) two's complement value of the actual value. You can get the unsigned integer value i from byte b using i = 0xff & b.
- Specified by:
getBytes
in interfaceAddressItem
- Returns:
-
getBytes
public byte[] getBytes(byte[] bytes, int index) Gets the value for the lowest address in the range represented by this address division.If the value fits in the specified array, the same array is returned with the value. Otherwise, a new array is allocated and returned with the value.
You can use
AddressDivisionSeries.getBitCount()
to determine the required array length for the bytes.Since bytes are signed values while addresses are unsigned, values greater than 127 are represented as the (negative) two's complement value of the actual value. You can get the unsigned integer value i from byte b using i = 0xff & b.
- Specified by:
getBytes
in interfaceAddressItem
- Returns:
-
getBytes
public byte[] getBytes(byte[] bytes) Equivalent togetBytes(byte[], int)
with index of 0.- Specified by:
getBytes
in interfaceAddressItem
- Returns:
- the bytes of the lowest address represented by this address item.
-
getUpperBytes
public byte[] getUpperBytes()Gets the bytes for the highest address in the range represented by this address.- Specified by:
getUpperBytes
in interfaceAddressItem
- Returns:
-
getUpperBytes
public byte[] getUpperBytes(byte[] bytes, int index) Similar togetBytes(byte[], int)
, but for obtaining the upper value of the range. If this division represents a single value, equivalent togetBytes(byte[], int)
- Specified by:
getUpperBytes
in interfaceAddressItem
- Returns:
- the bytes of the largest address represented by this address item.
-
getUpperBytes
public byte[] getUpperBytes(byte[] bytes) Equivalent togetBytes(byte[], int)
with index of 0.- Specified by:
getUpperBytes
in interfaceAddressItem
- Returns:
- the bytes of the largest address represented by this address item.
-
getValue
Description copied from interface:AddressItem
Returns the lowest value represented by this address item, the lowest value included in the range of values- Specified by:
getValue
in interfaceAddressItem
- Returns:
- the lowest value represented by this address item
-
getUpperValue
Description copied from interface:AddressItem
Returns the highest value represented by this address item, the highest value included in the range of values- Specified by:
getUpperValue
in interfaceAddressItem
- Returns:
- the highest value represented by this address item
-
isPrefixed
public boolean isPrefixed()Description copied from interface:AddressDivisionSeries
Whether there exists a prefix length associated with this series.- Specified by:
isPrefixed
in interfaceAddressDivisionSeries
-
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
AddressItem.getMinPrefixLengthForBlock()
andAddressItem.getPrefixLengthForSingleBlock()
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 initially defined by the range, so 1:2:3:*:*:* has a prefix length of 24 by definition. Addresses derived from the original may retain the original prefix length regardless of their range.
- Specified by:
getPrefixLength
in interfaceAddressDivisionSeries
-
getMinPrefixLengthForBlock
public int getMinPrefixLengthForBlock()Returns the smallest prefix length possible such that this address division grouping includes the block of addresses for that prefix.- Specified by:
getMinPrefixLengthForBlock
in interfaceAddressItem
- Returns:
- the prefix length
-
getPrefixLengthForSingleBlock
Returns a prefix length for which the range of this segment grouping matches the block of addresses for that prefix. If no such prefix exists, returns null If this segment grouping represents a single value, returns the bit length- Specified by:
getPrefixLengthForSingleBlock
in interfaceAddressItem
- Returns:
- the prefix length or null
-
getCount
gets the count of addresses that this address division grouping may represent If this address division grouping is not a subnet block of multiple addresses or has no range of values, then there is only one such address.- Specified by:
getCount
in interfaceAddressDivisionSeries
- Specified by:
getCount
in interfaceAddressItem
- Returns:
-
getPrefixCount
Description copied from interface:AddressDivisionSeries
If this has a prefix length, the count of the range of values in the prefix.If this has no prefix length, returns the same value as
AddressDivisionSeries.getCount()
- Specified by:
getPrefixCount
in interfaceAddressDivisionSeries
- Returns:
-
isMultiple
public boolean isMultiple()Description copied from interface:AddressItem
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)- Specified by:
isMultiple
in interfaceAddressItem
- 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)
-
hashCode
public int hashCode() -
equals
Two groupings are equal if: - they match type/version (ipv4, ipv6, mac, or a specific grouping class) - they match division counts - each division matches bit counts - each division matches their specific grouping class - each division matches values Prefix lengths, for those groupings and/or divisionsS that have them, are ignored. -
toString
-
getDivisionStrings
Description copied from interface:AddressDivisionSeries
Get standard-format strings for each of the divisions in the series.- Specified by:
getDivisionStrings
in interfaceAddressDivisionSeries
- Returns:
-
isZero
public boolean isZero()Description copied from interface:AddressItem
Returns whether this item matches the value of zero- Specified by:
isZero
in interfaceAddressItem
- Returns:
- whether this item matches the value of zero
-
includesZero
public boolean includesZero()Description copied from interface:AddressItem
Returns whether this item includes the value of zero within its range- Specified by:
includesZero
in interfaceAddressItem
- Returns:
- whether this item includes the value of zero within its range
-
isMax
public boolean isMax()Description copied from interface:AddressItem
Returns whether this item matches the maximum possible value for the address type or version- Specified by:
isMax
in interfaceAddressItem
- Returns:
- whether this item matches the maximum possible value
-
includesMax
public boolean includesMax()Description copied from interface:AddressItem
Returns whether this item includes the maximum possible value for the address type or version within its range- Specified by:
includesMax
in interfaceAddressItem
- Returns:
- whether this item includes the maximum possible value within its range
-
isFullRange
public boolean isFullRange()Description copied from interface:AddressItem
whether this address item represents all possible values attainable by an address item of this type- Specified by:
isFullRange
in interfaceAddressItem
- Returns:
- whether this address item represents all possible values attainable by an address item of this type, or in other words, both includesZero() and includesMax() return true
-
isSinglePrefixBlock
public boolean isSinglePrefixBlock()Description copied from interface:AddressDivisionSeries
Returns whether the range of values matches a single subnet block for the prefix lengthAn important distinction of this method with
AddressItem.containsSinglePrefixBlock(int)
is that this method returns false if the series does not have a prefix length assigned to it, even if there exists a prefix length for whichAddressItem.containsSinglePrefixBlock(int)
returns true.- Specified by:
isSinglePrefixBlock
in interfaceAddressDivisionSeries
- Returns:
-
isPrefixBlock
public boolean isPrefixBlock()Description copied from interface:AddressDivisionSeries
Returns whether this address segment series represents a block of addresses associated with its prefix length.This returns false if it has no prefix length or if it is a range of addresses that does not include the entire subnet block for the prefix length.
If
AddressNetwork.getPrefixConfiguration()
is set to consider all prefixes as subnets, this returns true for any series with a prefix length.An important distinction of
AddressItem.containsPrefixBlock(int)
with this method is that this method returns false if the series does not have a prefix length assigned to it, even if there exists one or more prefix lengths for whichAddressItem.containsPrefixBlock(int)
returns true.- Specified by:
isPrefixBlock
in interfaceAddressDivisionSeries
- Returns:
-