public abstract class Address extends Object implements AddressSegmentSeries
To construct one from a String
use
IPAddressString
or MACAddressString
Modifier and Type | Class and Description |
---|---|
static interface |
Address.AddressValueProvider |
static interface |
Address.SegmentValueProvider |
Modifier and Type | Field and Description |
---|---|
static AddressComparator |
ADDRESS_HIGH_VALUE_COMPARATOR |
static AddressComparator |
ADDRESS_LOW_VALUE_COMPARATOR |
static char |
ALTERNATIVE_RANGE_SEPARATOR |
static String |
ALTERNATIVE_RANGE_SEPARATOR_STR |
static String |
ALTERNATIVE_SEGMENT_WILDCARD_STR |
static AddressComparator |
DEFAULT_ADDRESS_COMPARATOR |
static String |
HEX_PREFIX |
static String |
OCTAL_PREFIX |
static char |
RANGE_SEPARATOR |
static String |
RANGE_SEPARATOR_STR |
static char |
SEGMENT_SQL_SINGLE_WILDCARD |
static String |
SEGMENT_SQL_SINGLE_WILDCARD_STR |
static char |
SEGMENT_SQL_WILDCARD |
static String |
SEGMENT_SQL_WILDCARD_STR |
static char |
SEGMENT_WILDCARD |
static 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)
Deprecated.
|
boolean |
contains(Address other)
Returns whether this is same type and version of the given address and whether it contains all individual addresses 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() |
abstract BigInteger |
enumerate(Address other)
Indicates where an address sits relative to the subnet ordering.
|
boolean |
equals(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
|
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.
|
BigInteger |
getCount()
Gets the count of addresses that this address may represent.
|
int |
getDivisionCount() |
String[] |
getDivisionStrings()
Get standard-format strings for each of the divisions in the series.
|
abstract 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.
|
BigInteger |
getPrefixCount()
If this has a prefix length, the count of the range of values in the prefix.
|
BigInteger |
getPrefixCount(int prefixLength)
Gets the count of prefixes in this address for the given prefix length.
|
Integer |
getPrefixLength()
the largest number of high bits for which this address represents all addresses with the same set of high bits
|
Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this address subnet matches 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 given index
|
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.
|
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.
|
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() |
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()
whether this address item represents all possible values attainable by an address item of this type
|
boolean |
isIPAddress()
Returns whether this address is an IP address
|
abstract boolean |
isLocal()
Whether the address can be considered a local address (as opposed to a global one)
|
boolean |
isMACAddress()
Returns whether this address is a MAC address
|
boolean |
isMax()
Returns whether this item matches the maximum possible value for the address type or version
|
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 Iterator<? extends Address> |
iterator()
Iterates through the individual address components.
|
static boolean |
matchOrdered(Address[] addrs1,
Address[] addrs2)
Checks if the two arrays share the same ordered list of addresses, subnets, or address collections, using address equality.
|
static boolean |
matchUnordered(Address[] addrs1,
Address[] addrs2)
Checks if the two arrays share the same list of addresses, subnets, or address collections, in any order, using address equality.
|
boolean |
overlaps(Address other)
Returns whether this is same type and version of the given address and whether it overlaps with the individual addresses in the given address or subnet,
containing at least one individual address common to both.
|
abstract Iterator<? extends Address> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
abstract AddressComponentSpliterator<? extends Address> |
prefixBlockSpliterator()
Partitions and traverses through the individual prefix blocks for the prefix length of this series.
|
abstract Stream<? extends Address> |
prefixBlockStream()
Returns a sequential stream of the individual prefix blocks for the prefix length of this series.
|
boolean |
prefixEquals(Address other) |
abstract Iterator<? extends Address> |
prefixIterator()
Iterates through the individual prefixes.
|
abstract AddressComponentSpliterator<? extends Address> |
prefixSpliterator()
Partitions and traverses through the individual prefixes for the prefix length of this series.
|
abstract Stream<? extends Address> |
prefixStream()
Returns a sequential stream of the individual prefixes for the prefix length of this series.
|
abstract Address |
removePrefixLength()
Deprecated.
|
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.
|
abstract AddressComponentSpliterator<? extends Address> |
spliterator()
Partitions and traverses through the individual address components.
|
abstract Stream<? extends Address> |
stream()
Returns a sequential stream of the individual address components.
|
HostIdentifierString |
toAddressString()
Returns a host identifier string representation for this address,
which will be already validated.
|
String |
toCanonicalString()
This produces a canonical string.
|
String |
toCompressedString()
Produce short strings for the address in the usual address format.
|
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.
|
IPAddress |
toIPAddress()
If this address is an IP address, returns that
IPAddress . |
MACAddress |
toMACAddress()
If this address is a MAC address, returns that
MACAddress . |
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.
|
String |
toString() |
abstract Address |
withoutPrefixLength()
Provides the same address with no prefix.
|
getBitsPerSegment, getBytesPerSegment, getMaxSegmentValue, getSection, getSection, getSegment, getSegments, isOneBit, segmentsIterator, segmentsSpliterator, segmentsStream, testBit
getDivision, getSequentialBlockIndex, isMore
getNetwork
stream, stream
compareTo, getBitsForCount, getBlockSize
public static final String HEX_PREFIX
public static final String OCTAL_PREFIX
public static final char RANGE_SEPARATOR
public static final String RANGE_SEPARATOR_STR
public static final char ALTERNATIVE_RANGE_SEPARATOR
public static final String ALTERNATIVE_RANGE_SEPARATOR_STR
public static final char SEGMENT_WILDCARD
public static final String SEGMENT_WILDCARD_STR
public static final String ALTERNATIVE_SEGMENT_WILDCARD_STR
public static final char SEGMENT_SQL_WILDCARD
public static final String SEGMENT_SQL_WILDCARD_STR
public static final char SEGMENT_SQL_SINGLE_WILDCARD
public static final String SEGMENT_SQL_SINGLE_WILDCARD_STR
public static final AddressComparator DEFAULT_ADDRESS_COMPARATOR
public static final AddressComparator ADDRESS_LOW_VALUE_COMPARATOR
public static final AddressComparator ADDRESS_HIGH_VALUE_COMPARATOR
public static IPv6AddressNetwork defaultIpv6Network()
public static IPv4AddressNetwork defaultIpv4Network()
public static MACAddressNetwork defaultMACNetwork()
public int getSegmentCount()
AddressSegmentSeries
getSegmentCount
in interface AddressSegmentSeries
public int getDivisionCount()
getDivisionCount
in interface AddressStringDivisionSeries
public int getBitCount()
AddressItem
getBitCount
in interface AddressDivisionSeries
getBitCount
in interface AddressItem
public int getByteCount()
AddressItem
getByteCount
in interface AddressItem
public AddressSection getSection()
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
public void getSegments(AddressSegment[] segs)
AddressSegmentSeries
AddressSegmentSeries.getSegmentCount()
getSegments
in interface AddressSegmentSeries
public void getSegments(int start, int end, AddressSegment[] segs, int index)
AddressSegmentSeries
getSegments
in interface AddressSegmentSeries
start
- 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 Iterable<? extends Address> getIterable()
AddressComponentRange
AddressComponentRange.iterator()
directly.getIterable
in interface AddressSegmentSeries
getIterable
in interface AddressComponentRange
public abstract Iterator<? extends Address> iterator()
AddressComponentRange
An address component can represent an individual segment, address, or section, or it can represent multiple, typically a subnet of addresses or a range of segment or section values.
Call AddressItem.isMultiple()
to determine if this instance represents multiple, or AddressItem.getCount()
for the count.
iterator
in interface AddressSegmentSeries
iterator
in interface AddressComponentRange
public abstract AddressComponentSpliterator<? extends Address> spliterator()
AddressComponentRange
spliterator
in interface AddressComponent
spliterator
in interface AddressSegmentSeries
spliterator
in interface AddressComponentRange
public abstract Stream<? extends Address> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressSegmentSeries
stream
in interface AddressComponentRange
public abstract Iterator<? extends Address> prefixIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixIterator
in interface AddressSegmentSeries
public abstract AddressComponentSpliterator<? extends Address> prefixSpliterator()
AddressSegmentSeries
prefixSpliterator
in interface AddressSegmentSeries
public abstract Stream<? extends Address> prefixStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixStream
in interface AddressSegmentSeries
public abstract Iterator<? extends Address> prefixBlockIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixBlockIterator
in interface AddressSegmentSeries
public abstract AddressComponentSpliterator<? extends Address> prefixBlockSpliterator()
AddressSegmentSeries
prefixBlockSpliterator
in interface AddressSegmentSeries
public abstract Stream<? extends Address> prefixBlockStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixBlockStream
in interface AddressSegmentSeries
public abstract Address increment(long increment) throws AddressValueException
AddressSegmentSeries
If 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 AddressSegmentSeries
AddressValueException
- in case of underflow or overflowpublic abstract Address incrementBoundary(long increment) throws AddressValueException
AddressSegmentSeries
AddressSegmentSeries.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 AddressSegmentSeries
AddressValueException
- in case of underflow or overflowpublic abstract Address getLower()
AddressSegmentSeries
getLower
in interface AddressSegmentSeries
getLower
in interface AddressComponentRange
public abstract Address getUpper()
AddressSegmentSeries
getUpper
in interface AddressSegmentSeries
getUpper
in interface AddressComponentRange
public boolean isMultiple()
isMultiple
in interface AddressItem
public boolean isPrefixed()
isPrefixed
in interface AddressDivisionSeries
public boolean isIPAddress()
public boolean isMACAddress()
public IPAddress toIPAddress()
IPAddress
. Otherwise, returns null.public MACAddress toMACAddress()
MACAddress
. Otherwise, returns null.public Integer getPrefixLength()
getPrefixLength
in interface AddressDivisionSeries
public 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 AddressItem
public 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 AddressItem
public abstract boolean isMulticast()
InetAddress.isMulticastAddress()
public BigInteger getCount()
getCount
in interface AddressDivisionSeries
getCount
in interface AddressItem
public BigInteger getPrefixCount(int prefixLength)
getPrefixCount
in interface AddressDivisionSeries
getPrefixCount
in interface AddressItem
public BigInteger getPrefixCount()
getCount()
getPrefixCount
in interface AddressDivisionSeries
public BigInteger getBlockCount(int segmentCount)
AddressDivisionSeries
getBlockCount
in interface AddressDivisionSeries
public byte[] getBytes()
getBytes
in interface AddressItem
public byte[] getBytes(byte[] bytes)
AddressItem
getBytes
in interface AddressItem
public byte[] getBytes(byte[] bytes, int index)
AddressItem
getBytes
in interface AddressItem
public byte[] getUpperBytes()
getUpperBytes
in interface AddressItem
public byte[] getUpperBytes(byte[] bytes)
AddressItem
getUpperBytes
in interface AddressItem
public byte[] getUpperBytes(byte[] bytes, int index)
AddressItem
getUpperBytes
in interface AddressItem
public BigInteger getValue()
AddressItem
getValue
in interface AddressItem
public BigInteger getUpperValue()
AddressItem
getUpperValue
in interface AddressItem
public boolean isZero()
AddressItem
isZero
in interface AddressItem
public boolean includesZero()
AddressItem
includesZero
in interface AddressItem
public boolean isMax()
AddressItem
isMax
in interface AddressItem
public boolean includesMax()
AddressItem
includesMax
in interface AddressItem
public boolean isFullRange()
AddressItem
isFullRange
in interface AddressItem
public abstract boolean isLocal()
public boolean isSameAddress(Address other)
public boolean equals(Object o)
public boolean prefixEquals(Address other)
public boolean overlaps(Address other)
other
- public boolean contains(Address other)
other
- public abstract BigInteger enumerate(Address other)
Determines how many address elements of a subnet precede the given address element, if the address is in the subnet. If above the subnet range, it is the distance to the upper boundary added to the subnet address count less one, and if below the subnet range, the distance to the lower boundary.
In other words, if the given address is not in the subnet but above it, returns the number of addresses preceding the address from the upper subnet boundary, added to one less than the total number of subnet addresses. If the given address is not in the subnet but below it, returns the number of addresses following the address to the lower subnet boundary.
enumerate returns null when the argument is a multi-valued subnet. The argument must be an individual address.
When this address is also single-valued, the returned value is the distance (difference) between this address and the argument address.
enumerate is the inverse of the increment method:
If the given address does not have the same version or type as this subnet or address, then null is returned.
public boolean isSequential()
AddressDivisionSeries
Generally, 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 AddressDivisionSeries
public HostIdentifierString toAddressString()
public String toHexString(boolean with0xPrefix) throws IncompatibleAddressException
toHexString
in interface AddressComponent
IncompatibleAddressException
public String toNormalizedString()
The string returned by this method is unique for each address.
toNormalizedString
in interface AddressComponent
public 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 AddressSegmentSeries
public String toCompressedString()
toCompressedString
in interface AddressSegmentSeries
public String[] getDivisionStrings()
AddressDivisionSeries
getDivisionStrings
in interface AddressDivisionSeries
public String[] getSegmentStrings()
AddressSegmentSeries
getSegmentStrings
in interface AddressSegmentSeries
public abstract Address reverseSegments()
AddressSegmentSeries
IncompatibleAddressException
since all address series can reverse their segments.reverseSegments
in interface AddressSegmentSeries
public abstract Address reverseBits(boolean perByte)
AddressSegmentSeries
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegmentSeries
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic abstract Address reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegmentSeries
public abstract Address reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSegmentSeries
public boolean isPrefixBlock()
isPrefixBlock
in interface AddressDivisionSeries
public boolean containsPrefixBlock(int prefixLength)
AddressItem
Use AddressItem.getMinPrefixLengthForBlock()
to determine the smallest prefix length for which this method returns true.
containsPrefixBlock
in interface AddressItem
public 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 AddressDivisionSeries
public 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 AddressItem
public abstract Address toPrefixBlock()
AddressSegmentSeries
toPrefixBlock
in interface AddressSegmentSeries
@Deprecated public abstract Address removePrefixLength()
AddressSegmentSeries
If the series already has a prefix length, the bits outside the prefix become zero.
Use AddressSegmentSeries.withoutPrefixLength()
to remove the prefix length without changing the series values.
Equivalent to calling removePrefixLength(true)
removePrefixLength
in interface AddressSegmentSeries
for an alternative which does not change the address series values.
public abstract Address withoutPrefixLength()
AddressSegmentSeries
Use AddressSegmentSeries.removePrefixLength()
as an alternative that deletes the host at the same time by zeroing the host values.
withoutPrefixLength
in interface AddressSegmentSeries
@Deprecated public abstract Address removePrefixLength(boolean zeroed)
AddressSegmentSeries
AddressSegmentSeries.removePrefixLength()
removePrefixLength
in interface AddressSegmentSeries
zeroed
- 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.
To avoid the zeroing behaviour, use AddressSegmentSeries.adjustPrefixBySegment(boolean, boolean)
with second arg false.
adjustPrefixBySegment
in interface AddressSegmentSeries
nextSegment
- whether to move prefix to previous or following segment boundarypublic abstract Address adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
nextSegment
- 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)
AddressSegmentSeries
When 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.
To avoid the zeroing behaviour, use AddressSegmentSeries.adjustPrefixLength(int, boolean)
with second arg false.
adjustPrefixLength
in interface AddressSegmentSeries
public abstract Address adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
adjustment
- 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)
AddressSegmentSeries
If this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero.
For an alternative that does not set bits to zero, use AddressSegmentSeries.setPrefixLength(int, boolean)
with the second argument as false.
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 AddressSegmentSeries
public abstract Address setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeries
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength
in interface AddressSegmentSeries
zeroed
- 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.@Deprecated 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 AddressSegmentSeries
AddressSegmentSeries.setPrefixLength(int)
public static boolean matchUnordered(Address[] addrs1, Address[] addrs2)
addrs1
- addrs2
- public static boolean matchOrdered(Address[] addrs1, Address[] addrs2)
addrs1
- addrs2
-