public abstract class Address extends java.lang.Object implements AddressSegmentSeries, java.lang.Comparable<Address>
| Modifier and Type | Class and Description |
|---|---|
static interface |
Address.SegmentValueProvider |
| Modifier and Type | Field and Description |
|---|---|
static AddressComparator |
addressComparator |
static char |
ALTERNATIVE_RANGE_SEPARATOR |
static java.lang.String |
ALTERNATIVE_RANGE_SEPARATOR_STR |
static java.lang.String |
ALTERNATIVE_SEGMENT_WILDCARD_STR |
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 |
| Constructor and Description |
|---|
Address(AddressSection section)
Constructs an address.
|
| Modifier and Type | Method and Description |
|---|---|
abstract Address |
adjustPrefixBySegment(boolean nextSegment)
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 |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new segment series representing all segment series starting with the same prefix.
|
int |
compareTo(Address other) |
abstract boolean |
contains(Address other) |
boolean |
equals(java.lang.Object o)
Two Address objects are equal if they represent the same set of addresses.
|
int |
getBitCount() |
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
byte[] |
getBytes() |
byte[] |
getBytes(byte[] bytes)
Copies the bytes of the smallest address item represented by this address item into the supplied array,
and returns that array.
|
java.math.BigInteger |
getCount()
Gets the count of addresses that this address may represent.
|
AddressDivision |
getDivision(int index) |
int |
getDivisionCount() |
java.lang.Integer |
getEquivalentPrefix()
Returns a prefix length for which the range of this address can be specified only using the address lower value and the prefix length
If no such prefix exists, returns null.
|
abstract java.lang.Iterable<? extends Address> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract Address |
getLower()
If this instance represents multiple address components, returns the one with the lowest numeric value.
|
abstract int |
getMaxSegmentValue() |
int |
getMinPrefix()
Returns the smallest prefix length possible such that this address paired with that prefix length represents the exact same range of addresses.
|
java.lang.Integer |
getPrefixLength()
the largest number of high bits for which this address represents all addresses with the same set of high bits
|
AddressSection |
getSection() |
AddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
|
AddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
|
AddressSegment |
getSegment(int index) |
int |
getSegmentCount() |
AddressSegment[] |
getSegments() |
void |
getSegments(AddressSegment[] segs) |
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
|
abstract Address |
getUpper()
If this instance represents multiple address components, returns the one with the highest numeric value.
|
byte[] |
getUpperBytes()
Gets the bytes for the highest address in the range represented by this address.
|
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.
|
int |
hashCode() |
boolean |
isFullRange() |
abstract boolean |
isLocal() |
int |
isMore(AddressDivisionSeries other)
Use this method to compare the counts of two address series.
|
abstract boolean |
isMulticast() |
boolean |
isMultiple()
Whether this represents multiple potential values (eg a prefixed address or a segment representing a range of values)
|
boolean |
isMultipleByPrefix()
whether there is a prefix and it is less than the bit-count
|
boolean |
isPrefixed()
Whether there exists a prefix.
|
boolean |
isRangeEquivalentToPrefix()
whether there is a prefix and the range of values is dictated entirely by the prefix.
|
boolean |
isSameAddress(Address other) |
boolean |
isZero() |
abstract java.util.Iterator<? extends Address> |
iterator()
An address component can represent a single segment, address, or section, or it can represent multiple,
typically a subnet or range of segment, address, or section values.
|
abstract Address |
removePrefixLength()
Removes the prefix.
|
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.
|
java.util.Iterator<? extends AddressSegment[]> |
segmentsIterator() |
abstract Address |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
HostIdentifierString |
toAddressString()
Returns a host identifier string representation for this address,
which will be validated already.
|
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.
|
java.lang.String |
toString() |
getBitsPerSegment, getBytesPerSegmentpublic 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 addressComparator
public Address(AddressSection section)
section - the address segmentspublic int getSegmentCount()
getSegmentCount in interface AddressSegmentSeriespublic int getDivisionCount()
getDivisionCount in interface AddressStringDivisionSeriespublic int getBitCount()
getBitCount in interface AddressItempublic int getByteCount()
AddressComponentgetByteCount in interface AddressComponentpublic AddressSection getSection()
public AddressSection getSection(int index)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriespublic AddressSection getSection(int index, int endIndex)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriespublic AddressDivision getDivision(int index)
getDivision in interface AddressDivisionSeriesgetDivision in interface AddressStringDivisionSeriespublic AddressSegment getSegment(int index)
getSegment in interface AddressSegmentSeriespublic AddressSegment[] getSegments()
getSegments in interface AddressSegmentSeriespublic void getSegments(AddressSegment[] segs)
getSegments in interface AddressSegmentSeriespublic void getSegments(int start,
int end,
AddressSegment[] segs,
int index)
AddressSegmentSeriesgetSegments in interface AddressSegmentSeriespublic abstract int getMaxSegmentValue()
public abstract java.lang.Iterable<? extends Address> getIterable()
AddressComponentAddressComponent.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSegmentSeriespublic abstract java.util.Iterator<? extends Address> iterator()
AddressComponentAddressItem.isMultiple() to determine if this instance represents multiple.
This method iterates through the individual elements.iterator in interface AddressComponentiterator in interface AddressSegmentSeriespublic java.util.Iterator<? extends AddressSegment[]> segmentsIterator()
segmentsIterator in interface AddressSegmentSeriespublic abstract Address getLower()
AddressComponentgetLower in interface AddressComponentgetLower in interface AddressSegmentSeriespublic abstract Address getUpper()
AddressComponentgetUpper in interface AddressComponentgetUpper in interface AddressSegmentSeriespublic boolean isMultipleByPrefix()
AddressDivisionSeriesisMultipleByPrefix in interface AddressDivisionSeriespublic boolean isMultiple()
AddressItemisMultiple in interface AddressItempublic boolean isPrefixed()
AddressDivisionSeriesisPrefixed in interface AddressDivisionSeriespublic java.lang.Integer getPrefixLength()
getPrefixLength in interface AddressDivisionSeriespublic int getMinPrefix()
AddressDivisionSeriesgetMinPrefix in interface AddressDivisionSeriespublic java.lang.Integer getEquivalentPrefix()
getEquivalentPrefix in interface AddressDivisionSeriespublic abstract boolean isMulticast()
InetAddress.isMulticastAddress()public java.math.BigInteger getCount()
getCount in interface AddressItempublic int isMore(AddressDivisionSeries other)
AddressDivisionSeriesisMore in interface AddressDivisionSeriespublic byte[] getBytes()
getBytes in interface AddressItempublic byte[] getBytes(byte[] bytes)
AddressItemgetBytes in interface AddressItempublic byte[] getUpperBytes()
getUpperBytes in interface AddressItempublic byte[] getUpperBytes(byte[] bytes)
AddressItemgetUpperBytes in interface AddressItempublic boolean isZero()
isZero in interface AddressItempublic boolean isFullRange()
isFullRange in interface AddressItempublic abstract boolean isLocal()
public int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(Address other)
compareTo in interface java.lang.Comparable<Address>public boolean isSameAddress(Address other)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic abstract boolean contains(Address other)
public boolean isRangeEquivalentToPrefix()
AddressDivisionSeriesisRangeEquivalentToPrefix in interface AddressDivisionSeriespublic HostIdentifierString toAddressString()
public java.lang.String toHexString(boolean with0xPrefix)
toHexString in interface AddressComponentpublic java.lang.String toNormalizedString()
toNormalizedString in interface AddressComponentpublic java.lang.String toCanonicalString()
toCanonicalString in interface AddressSegmentSeriespublic java.lang.String toCompressedString()
toCompressedString in interface AddressSegmentSeriespublic java.lang.String toString()
toString in class java.lang.Objectpublic abstract Address reverseSegments()
AddressSegmentSeriesreverseSegments 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 abstract Address removePrefixLength()
AddressSegmentSeriesremovePrefixLength in interface AddressSegmentSeriespublic abstract Address adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeriesadjustPrefixBySegment in interface AddressSegmentSeriespublic abstract Address adjustPrefixLength(int adjustment)
AddressSegmentSeriesadjustPrefixLength in interface AddressSegmentSeriespublic abstract Address setPrefixLength(int prefixLength)
AddressSegmentSeriessetPrefixLength in interface AddressSegmentSeriespublic abstract Address applyPrefixLength(int networkPrefixLength)
AddressSegmentSeriesapplyPrefixLength in interface AddressSegmentSeries