public abstract class Address extends java.lang.Object implements AddressSegmentSeries
| Modifier and Type | Class and Description |
|---|---|
static interface |
Address.AddressValueProvider |
static interface |
Address.SegmentValueProvider |
| Modifier and Type | Field and Description |
|---|---|
static AddressComparator |
ADDRESS_LOW_VALUE_COMPARATOR |
static char |
ALTERNATIVE_RANGE_SEPARATOR |
static java.lang.String |
ALTERNATIVE_RANGE_SEPARATOR_STR |
static java.lang.String |
ALTERNATIVE_SEGMENT_WILDCARD_STR |
static AddressComparator |
DEFAULT_ADDRESS_COMPARATOR |
static java.lang.String |
HEX_PREFIX |
static java.lang.String |
OCTAL_PREFIX |
static char |
RANGE_SEPARATOR |
static java.lang.String |
RANGE_SEPARATOR_STR |
static char |
SEGMENT_SQL_SINGLE_WILDCARD |
static java.lang.String |
SEGMENT_SQL_SINGLE_WILDCARD_STR |
static char |
SEGMENT_SQL_WILDCARD |
static java.lang.String |
SEGMENT_SQL_WILDCARD_STR |
static char |
SEGMENT_WILDCARD |
static java.lang.String |
SEGMENT_WILDCARD_STR |
| Modifier and Type | Method and Description |
|---|---|
abstract Address |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
abstract Address |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
abstract Address |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
abstract Address |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
abstract Address |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new segment series.
|
boolean |
contains(Address other)
Returns whether this is same type and version of the given address and whether it contains all values in the given address or subnet
|
boolean |
containsPrefixBlock(int prefixLength)
Returns whether the values of this series contains the prefix block for the given prefix length.
|
boolean |
containsSinglePrefixBlock(int prefixLength)
Returns whether the values of this series contains a single prefix block for the given prefix length.
|
static IPv4AddressNetwork |
defaultIpv4Network() |
static IPv6AddressNetwork |
defaultIpv6Network() |
static MACAddressNetwork |
defaultMACNetwork() |
boolean |
equals(java.lang.Object o)
Two Address objects are equal if they represent the same set of addresses.
|
int |
getBitCount()
Provides the number of bits comprising this address item
|
java.math.BigInteger |
getBlockCount(int segmentCount)
Returns the count of values in the initial (higher) count of divisions.
|
int |
getByteCount()
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8
|
byte[] |
getBytes() |
byte[] |
getBytes(byte[] bytes)
Copies the bytes of the lowest address item represented by this address item into the supplied array,
and returns that array.
|
byte[] |
getBytes(byte[] bytes,
int index)
Copies the bytes of the lowest address item represented by this address item into the supplied array starting at the given index,
and returns that array.
|
java.math.BigInteger |
getCount()
Gets the count of addresses that this address may represent.
|
int |
getDivisionCount() |
java.lang.String[] |
getDivisionStrings()
Get standard-format strings for each of the divisions in the series.
|
abstract java.lang.Iterable<? extends Address> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract Address |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
int |
getMinPrefixLengthForBlock()
Returns the smallest prefix length possible such that this includes the block of addresses for that prefix.
|
java.math.BigInteger |
getPrefixCount()
If this has a prefix length, the count of the range of values in the prefix.
|
java.math.BigInteger |
getPrefixCount(int prefixLength)
Gets the count of prefixes in this address for the given prefix length.
|
java.lang.Integer |
getPrefixLength()
the largest number of high bits for which this address represents all addresses with the same set of high bits
|
java.lang.Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this address subnet matches the the block of addresses for that prefix.
|
AddressSection |
getSection()
Gets the subsection from the series that comprises all segments
|
int |
getSegmentCount()
Returns the number of segments in this series.
|
void |
getSegments(AddressSegment[] segs)
Copies the existing segments into the given array.
|
void |
getSegments(int start,
int end,
AddressSegment[] segs,
int index)
get the segments from start to end and insert into the segs array at the the given index
|
java.lang.String[] |
getSegmentStrings()
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.
|
abstract Address |
getUpper()
If this represents a series with ranging values, returns a series representing the upper values of the range
If this represents a series with a single value in each segment, returns this.
|
byte[] |
getUpperBytes()
Gets the bytes for the highest address in the range of addresses represented by this address instance.
|
byte[] |
getUpperBytes(byte[] bytes)
Copies the bytes of the largest address item represented by this address item into the supplied array,
and returns that array.
|
byte[] |
getUpperBytes(byte[] bytes,
int index)
Copies the bytes of the largest address item represented by this address item into the supplied array at the given index,
and returns that array.
|
java.math.BigInteger |
getUpperValue()
Returns the highest value represented by this address item, the highest value included in the range of values
|
java.math.BigInteger |
getValue()
Returns the lowest value represented by this address item, the lowest value included in the range of values
|
int |
hashCode() |
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
|
abstract Address |
increment(long increment)
Returns the series from the subnet that is the given increment upwards into the subnet range, with the increment of 0
returning the first address in the range.
|
abstract Address |
incrementBoundary(long increment)
If the given increment is positive, adds the value to the upper series (
AddressSegmentSeries.getUpper()) in the subnet range to produce a new series. |
boolean |
isFullRange() |
abstract boolean |
isLocal()
Whether the address can be considered a local address (as opposed to a global one)
|
boolean |
isMax()
Returns whether this item matches the maximum possible value for the address type or version
|
int |
isMore(AddressDivisionSeries other)
Use this method to compare the counts of two address series.
|
abstract boolean |
isMulticast()
Whether the MAC address or IP address or other form of address is multicast.
|
boolean |
isMultiple()
Returns whether this address represents more than a single individual address, whether it is a subnet.
|
boolean |
isPrefixBlock()
Returns whether the address range has a prefix length and includes the block of values for its prefix length.
|
boolean |
isPrefixed()
Returns whether this address has an associated prefix length
|
boolean |
isSameAddress(Address other) |
boolean |
isSequential()
Returns whether the series represents a range of values that are sequential.
|
boolean |
isSinglePrefixBlock()
Returns whether the address range the block of values for a single prefix identified by its prefix length.
|
boolean |
isZero()
Returns whether this item matches the value of zero
|
abstract java.util.Iterator<? extends Address> |
iterator()
Iterates through the individual segment series.
|
abstract java.util.Iterator<? extends Address> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
boolean |
prefixEquals(Address other) |
abstract java.util.Iterator<? extends Address> |
prefixIterator()
Iterates through the individual prefixes.
|
abstract Address |
removePrefixLength()
Removes the prefix length while zeroing out the existing host.
|
abstract Address |
removePrefixLength(boolean zeroed)
Deprecated.
|
abstract Address |
reverseBits(boolean perByte)
Returns a new segment series with the bits reversed.
|
abstract Address |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
abstract Address |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
abstract Address |
reverseSegments()
Returns a new segment series with the segments reversed.
|
abstract Address |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
abstract Address |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
HostIdentifierString |
toAddressString()
Returns a host identifier string representation for this address,
which will be already validated.
|
java.lang.String |
toCanonicalString()
This produces a canonical string.
|
java.lang.String |
toCompressedString()
Produce short strings for the address in the usual address format.
|
java.lang.String |
toHexString(boolean with0xPrefix)
Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
|
java.lang.String |
toNormalizedString()
The normalized string returned by this method is a common and consistent representation of the address.
|
abstract Address |
toPrefixBlock()
If this series has a prefix length, returns the block for that prefix.
|
java.lang.String |
toString() |
abstract Address |
withoutPrefixLength()
Provides the same address with no prefix.
|
getBitsPerSegment, getBytesPerSegment, getMaxSegmentValue, getNetwork, getSection, getSection, getSegment, getSegments, segmentsIteratorgetDivisioncompareTo, testRange, testRangepublic static final java.lang.String HEX_PREFIX
public static final java.lang.String OCTAL_PREFIX
public static final char RANGE_SEPARATOR
public static final java.lang.String RANGE_SEPARATOR_STR
public static final char ALTERNATIVE_RANGE_SEPARATOR
public static final java.lang.String ALTERNATIVE_RANGE_SEPARATOR_STR
public static final char SEGMENT_WILDCARD
public static final java.lang.String SEGMENT_WILDCARD_STR
public static final java.lang.String ALTERNATIVE_SEGMENT_WILDCARD_STR
public static final char SEGMENT_SQL_WILDCARD
public static final java.lang.String SEGMENT_SQL_WILDCARD_STR
public static final char SEGMENT_SQL_SINGLE_WILDCARD
public static final java.lang.String SEGMENT_SQL_SINGLE_WILDCARD_STR
public static final AddressComparator DEFAULT_ADDRESS_COMPARATOR
public static final AddressComparator ADDRESS_LOW_VALUE_COMPARATOR
public static IPv6AddressNetwork defaultIpv6Network()
public static IPv4AddressNetwork defaultIpv4Network()
public static MACAddressNetwork defaultMACNetwork()
public int getSegmentCount()
AddressSegmentSeriesgetSegmentCount in interface AddressSegmentSeriespublic int getDivisionCount()
getDivisionCount in interface AddressStringDivisionSeriespublic int getBitCount()
AddressItemgetBitCount in interface AddressDivisionSeriesgetBitCount in interface AddressItempublic int getByteCount()
AddressItemgetByteCount in interface AddressItempublic AddressSection getSection()
AddressSegmentSeriesgetSection in interface AddressSegmentSeriespublic void getSegments(AddressSegment[] segs)
AddressSegmentSeriesAddressSegmentSeries.getSegmentCount()getSegments in interface AddressSegmentSeriespublic void getSegments(int start,
int end,
AddressSegment[] segs,
int index)
AddressSegmentSeriesgetSegments in interface AddressSegmentSeriesstart - the first segment index from this series to be includedend - the first segment index to be excludedsegs - the target arrayindex - where to insert the segments in the segs arraypublic abstract java.lang.Iterable<? extends Address> getIterable()
AddressItemRangeAddressItemRange.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSegmentSeriesgetIterable in interface AddressItemRangepublic abstract java.util.Iterator<? extends Address> iterator()
AddressSegmentSeriesiterator in interface AddressComponentiterator in interface AddressSegmentSeriesiterator in interface AddressItemRangepublic abstract java.util.Iterator<? extends Address> prefixIterator()
AddressSegmentSeriesAddressSegmentSeries.iterator()prefixIterator in interface AddressSegmentSeriespublic abstract java.util.Iterator<? extends Address> prefixBlockIterator()
AddressSegmentSeriesAddressSegmentSeries.iterator()prefixBlockIterator in interface AddressSegmentSeriespublic abstract Address increment(long increment) throws AddressValueException
AddressSegmentSeriesIf the subnet has multiple values and the increment exceeds the subnet size, then the amount by which it exceeds the size - 1 is added to the upper series of the range (the final iterator value).
If the increment is negative, it is added to the lower series of the range (the first iterator value).
If the subnet is just a single address values, the series is simply incremented by the given value, positive or negative.
If a subnet has multiple values, a positive increment value is equivalent to the same number of values from the AddressSegmentSeries.iterator()
For instance, a increment of 0 is the first value from the iterator, an increment of 1 is the second value from the iterator, and so on.
A negative increment added to the subnet count is equivalent to the same number of values preceding the upper bound of the iterator.
For instance, an increment of count - 1 is the last value from the iterator, an increment of count - 2 is the second last value, and so on.
An increment of size count gives you the series just above the highest series of the subnet. To get the series just below the lowest series of the subnet, use the increment -1.
increment in interface AddressSegmentSeriesAddressValueException - in case of underflow or overflowpublic abstract Address incrementBoundary(long increment) throws AddressValueException
AddressSegmentSeriesAddressSegmentSeries.getUpper()) in the subnet range to produce a new series.
If the given increment is negative, adds the value to the lower series (AddressSegmentSeries.getLower()) in the subnet range to produce a new series.
If the increment is zero, returns this.
In the case where the series is a single value, this simply returns the address produced by adding the given increment to this address series.
incrementBoundary in interface AddressSegmentSeriesAddressValueException - in case of underflow or overflowpublic abstract Address getLower()
AddressSegmentSeriesgetLower in interface AddressComponentgetLower in interface AddressSegmentSeriesgetLower in interface AddressItemRangepublic abstract Address getUpper()
AddressSegmentSeriesgetUpper in interface AddressComponentgetUpper in interface AddressSegmentSeriesgetUpper in interface AddressItemRangepublic boolean isMultiple()
isMultiple in interface AddressItempublic boolean isPrefixed()
isPrefixed in interface AddressDivisionSeriespublic java.lang.Integer getPrefixLength()
getPrefixLength in interface AddressDivisionSeriespublic int getMinPrefixLengthForBlock()
If the entire range can be dictated this way, then this method returns the same value as getPrefixLengthForSingleBlock().
Otherwise, this method will return the minimal possible prefix that can be paired with this address, while getPrefixLengthForSingleBlock() will return null.
In cases where the final bit in this address division series is constant, this returns the bit length of this address division series.
getMinPrefixLengthForBlock in interface AddressItempublic java.lang.Integer getPrefixLengthForSingleBlock()
If the range can be dictated this way, then this method returns the same value as getMinPrefixLengthForBlock().
If no such prefix exists, returns null.
If this segment grouping represents a single value, returns the bit length of this address division series.
IP address examples: 1.2.3.4 returns 32 1.2.*.* returns 16 1.2.*.0/24 returns 16 in the case of PrefixConfiguration == ALL_PREFIXES_ARE_SUBNETS, 32 otherwise 1.2.*.4 returns null 1.2.252-255.* returns 22 1.2.3.4/x returns x in the case of PrefixConfiguration == ALL_PREFIXES_ARE_SUBNETS, 32 otherwise 1.2.0.0/16 returns 16 in the case of PrefixConfiguration == ALL_PREFIXES_ARE_SUBNETS or PREFIXED_ZERO_HOSTS_ARE_SUBNETS, 32 otherwise
getPrefixLengthForSingleBlock in interface AddressItempublic abstract boolean isMulticast()
InetAddress.isMulticastAddress()public java.math.BigInteger getCount()
getCount in interface AddressDivisionSeriesgetCount in interface AddressItempublic java.math.BigInteger getPrefixCount(int prefixLength)
getPrefixCount in interface AddressDivisionSeriesgetPrefixCount in interface AddressItempublic java.math.BigInteger getPrefixCount()
getCount()getPrefixCount in interface AddressDivisionSeriespublic java.math.BigInteger getBlockCount(int segmentCount)
AddressDivisionSeriesgetBlockCount in interface AddressDivisionSeriespublic int isMore(AddressDivisionSeries other)
AddressDivisionSeriesisMore in interface AddressDivisionSeriespublic byte[] getBytes()
getBytes in interface AddressItempublic byte[] getBytes(byte[] bytes)
AddressItemgetBytes in interface AddressItempublic byte[] getBytes(byte[] bytes,
int index)
AddressItemgetBytes in interface AddressItempublic byte[] getUpperBytes()
getUpperBytes in interface AddressItempublic byte[] getUpperBytes(byte[] bytes)
AddressItemgetUpperBytes in interface AddressItempublic byte[] getUpperBytes(byte[] bytes,
int index)
AddressItemgetUpperBytes in interface AddressItempublic java.math.BigInteger getValue()
AddressItemgetValue in interface AddressItempublic java.math.BigInteger getUpperValue()
AddressItemgetUpperValue in interface AddressItempublic 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()
isFullRange in interface AddressItempublic abstract boolean isLocal()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean isSameAddress(Address other)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic boolean prefixEquals(Address other)
public boolean contains(Address other)
other - public boolean isSequential()
AddressDivisionSeriesGenerally, this means that any division covering a range of values must be followed by divisions that are full range, covering all values.
isSequential in interface AddressDivisionSeriespublic HostIdentifierString toAddressString()
public java.lang.String toHexString(boolean with0xPrefix)
throws IncompatibleAddressException
toHexString in interface AddressComponentIncompatibleAddressExceptionpublic java.lang.String toNormalizedString()
The string returned by this method is unique for each address.
toNormalizedString in interface AddressComponentpublic java.lang.String toCanonicalString()
RFC 5952 describes canonical representations for Ipv6 http://en.wikipedia.org/wiki/IPv6_address#Recommended_representation_as_text http://tools.ietf.org/html/rfc5952
Each address has a unique canonical string, not counting the prefix. The prefix can cause two equal addresses to have different strings.
toCanonicalString in interface AddressSegmentSeriespublic java.lang.String toCompressedString()
toCompressedString in interface AddressSegmentSeriespublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String[] getDivisionStrings()
AddressDivisionSeriesgetDivisionStrings in interface AddressDivisionSeriespublic java.lang.String[] getSegmentStrings()
AddressSegmentSeriesgetSegmentStrings in interface AddressSegmentSeriespublic abstract Address reverseSegments()
AddressSegmentSeriesIncompatibleAddressException since all address series can reverse their segments.reverseSegments in interface AddressSegmentSeriespublic abstract Address reverseBits(boolean perByte)
AddressSegmentSeriesreverseBits in interface AddressComponentreverseBits in interface AddressSegmentSeriesperByte - if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic abstract Address reverseBytes()
AddressSegmentSeriesreverseBytes in interface AddressComponentreverseBytes in interface AddressSegmentSeriespublic abstract Address reverseBytesPerSegment()
AddressSegmentSeriesreverseBytesPerSegment in interface AddressSegmentSeriespublic boolean isPrefixBlock()
isPrefixBlock in interface AddressDivisionSeriespublic boolean containsPrefixBlock(int prefixLength)
AddressItem
Use AddressItem.getMinPrefixLengthForBlock() to determine the smallest prefix length for which this method returns true.
containsPrefixBlock in interface AddressItempublic boolean isSinglePrefixBlock()
isPrefixBlock() except that it returns false when
the subnet has multiple prefixes.
For instance, 1.*.*.* /16 return false for this method and returns true for isPrefixBlock()isSinglePrefixBlock in interface AddressDivisionSeriespublic boolean containsSinglePrefixBlock(int prefixLength)
AddressItem
Use AddressItem.getPrefixLengthForSingleBlock() to determine whether there is a prefix length for which this method returns true.
containsSinglePrefixBlock in interface AddressItempublic abstract Address toPrefixBlock()
AddressSegmentSeriestoPrefixBlock in interface AddressSegmentSeriespublic abstract Address removePrefixLength()
AddressSegmentSeriesIf the series already has a prefix length, the bits outside the prefix become zero.
Equivalent to calling removePrefixLength(true)
removePrefixLength in interface AddressSegmentSeriesfor an alternative which never changes the address valuepublic abstract Address withoutPrefixLength()
AddressSegmentSerieswithoutPrefixLength in interface AddressSegmentSeries@Deprecated public abstract Address removePrefixLength(boolean zeroed)
AddressSegmentSeriesremovePrefixLength in interface AddressSegmentSerieszeroed - whether the bits outside the prefix become zeropublic abstract Address adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
Follows the same rules as AddressSegmentSeries.adjustPrefixLength(int):
When prefix length is increased, the bits moved within the prefix become zero.
When a prefix length is decreased, the bits moved outside the prefix become zero.
adjustPrefixBySegment in interface AddressSegmentSeriesnextSegment - whether to move prefix to previous or following segment boundarypublic abstract Address adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeriesadjustPrefixBySegment in interface AddressSegmentSeriesnextSegment - whether to move prefix to previous or following segment boundaryzeroed - whether the bits that move from one side of the prefix to the other become zero or retain their original valuespublic abstract Address adjustPrefixLength(int adjustment)
AddressSegmentSeriesWhen prefix length is increased, the bits moved within the prefix become zero. When the prefix is extended beyond the segment series boundary, it is removed. When a prefix length is decreased, the bits moved outside the prefix become zero.
adjustPrefixLength in interface AddressSegmentSeriespublic abstract Address adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeriesadjustPrefixLength in interface AddressSegmentSeriesadjustment - the incrementzeroed - whether the bits that move from one side of the prefix to the other become zero or retain their original valuespublic abstract Address setPrefixLength(int prefixLength)
AddressSegmentSeriesIf this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero.
When the prefix is extended beyond the segment series boundary, it is removed.
The bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.
setPrefixLength in interface AddressSegmentSeriesAddressSegmentSeries.applyPrefixLength(int)public abstract Address setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeriesWhen the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength in interface AddressSegmentSerieszeroed - whether the bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.public abstract Address applyPrefixLength(int networkPrefixLength)
AddressSegmentSeries
Similar to AddressSegmentSeries.setPrefixLength(int) except that prefix lengths are never increased.
When this series already has a prefix length that is less than or equal to the requested prefix length, this series is returned.
Otherwise the returned series has the given prefix length.
The bits moved outside the prefix will become zero in the returned series.
applyPrefixLength in interface AddressSegmentSeriesAddressSegmentSeries.setPrefixLength(int)