public abstract class AddressDivisionGroupingBase extends Object implements AddressDivisionSeries
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.
| Constructor and Description |
|---|
AddressDivisionGroupingBase(AddressDivisionBase[] divisions) |
AddressDivisionGroupingBase(AddressDivisionBase[] divisions,
boolean checkDivisions) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o)
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 to
getBytes(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 grouping.
|
BigInteger |
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.
|
AddressDivisionBase |
getDivision(int index) |
int |
getDivisionCount() |
String[] |
getDivisionStrings()
Get standard-format strings for each of the divisions in the series.
|
int |
getMinPrefixLengthForBlock()
Returns the smallest prefix length possible such that this address division grouping includes the block of addresses for that prefix.
|
BigInteger |
getPrefixCount()
If this has a prefix length, the count of the range of values in the prefix.
|
Integer |
getPrefixLength()
The bit-length of the portion of the address that is not specific to an individual address but common amongst a group of addresses.
|
Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this segment grouping matches the block of addresses for that prefix.
|
byte[] |
getUpperBytes()
Gets the bytes for the highest address in the range represented by this address.
|
byte[] |
getUpperBytes(byte[] bytes)
Equivalent to
getBytes(byte[], int) with index of 0. |
byte[] |
getUpperBytes(byte[] bytes,
int index)
Similar to
getBytes(byte[], int), but for obtaining the upper value of the range. |
BigInteger |
getUpperValue()
Returns the highest value represented by this address item, the highest value included in the range of values
|
BigInteger |
getValue()
Returns the lowest value represented by this address item, the lowest value included in the range of values
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
includesMax()
Returns whether this item includes the maximum possible value for the address type or version within its range
|
boolean |
includesZero()
Returns whether this item includes the value of zero within its range
|
boolean |
isFullRange()
whether this address item represents all possible values attainable by an address item of this type
|
boolean |
isMax()
Returns whether this item matches the maximum possible value for the address type or version
|
boolean |
isMultiple()
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
|
boolean |
isPrefixBlock()
Returns whether this address segment series represents a block of addresses associated with its prefix length.
|
boolean |
isPrefixed()
Whether there exists a prefix length associated with this series.
|
boolean |
isSinglePrefixBlock()
Returns whether the range of values matches a single subnet block for the prefix length
|
boolean |
isZero()
Returns whether this item matches the value of zero
|
String |
toString()
Returns a string representation of the object.
|
getBitCount, getBlockCount, getPrefixCount, getSequentialBlockIndex, isMore, isSequentialcompareTo, containsPrefixBlock, containsSinglePrefixBlock, getByteCountpublic AddressDivisionGroupingBase(AddressDivisionBase[] divisions)
public AddressDivisionGroupingBase(AddressDivisionBase[] divisions, boolean checkDivisions)
public AddressDivisionBase getDivision(int index)
getDivision in interface AddressDivisionSeriesgetDivision in interface AddressStringDivisionSeriespublic int getDivisionCount()
getDivisionCount in interface AddressStringDivisionSeriespublic byte[] getBytes()
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.
getBytes in interface AddressItempublic byte[] getBytes(byte[] bytes,
int index)
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.
getBytes in interface AddressItempublic byte[] getBytes(byte[] bytes)
getBytes(byte[], int) with index of 0.getBytes in interface AddressItempublic byte[] getUpperBytes()
getUpperBytes in interface AddressItempublic byte[] getUpperBytes(byte[] bytes,
int index)
getBytes(byte[], int), but for obtaining the upper value of the range.
If this division represents a single value, equivalent to getBytes(byte[], int)getUpperBytes in interface AddressItempublic byte[] getUpperBytes(byte[] bytes)
getBytes(byte[], int) with index of 0.getUpperBytes in interface AddressItempublic BigInteger getValue()
AddressItemgetValue in interface AddressItempublic BigInteger getUpperValue()
AddressItemgetUpperValue in interface AddressItempublic boolean isPrefixed()
AddressDivisionSeriesisPrefixed in interface AddressDivisionSeriespublic Integer getPrefixLength()
AddressDivisionSeriesTypically 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() and AddressItem.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.
getPrefixLength in interface AddressDivisionSeriespublic int getMinPrefixLengthForBlock()
getMinPrefixLengthForBlock in interface AddressItempublic Integer getPrefixLengthForSingleBlock()
getPrefixLengthForSingleBlock in interface AddressItempublic BigInteger getCount()
getCount in interface AddressDivisionSeriesgetCount in interface AddressItempublic BigInteger getPrefixCount()
AddressDivisionSeries
If this has no prefix length, returns the same value as AddressDivisionSeries.getCount()
getPrefixCount in interface AddressDivisionSeriespublic boolean isMultiple()
AddressItemisMultiple in interface AddressItempublic int hashCode()
java.lang.ObjectHashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode in class ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)public boolean equals(Object o)
equals in class Objecto - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic String toString()
java.lang.ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
public String[] getDivisionStrings()
AddressDivisionSeriesgetDivisionStrings in interface AddressDivisionSeriespublic boolean isZero()
AddressItemisZero in interface AddressItempublic boolean includesZero()
AddressItemincludesZero in interface AddressItempublic boolean isMax()
AddressItemisMax in interface AddressItempublic boolean includesMax()
AddressItemincludesMax in interface AddressItempublic boolean isFullRange()
AddressItemisFullRange in interface AddressItempublic boolean isSinglePrefixBlock()
AddressDivisionSeries
An 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 which AddressItem.containsSinglePrefixBlock(int)
returns true.
isSinglePrefixBlock in interface AddressDivisionSeriespublic boolean isPrefixBlock()
AddressDivisionSeriesThis 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 which AddressItem.containsPrefixBlock(int) returns true.
isPrefixBlock in interface AddressDivisionSeries