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, getBytesPerSegment
public 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 AddressSegmentSeries
public int getDivisionCount()
getDivisionCount
in interface AddressStringDivisionSeries
public int getBitCount()
getBitCount
in interface AddressItem
public int getByteCount()
AddressComponent
getByteCount
in interface AddressComponent
public AddressSection getSection()
public AddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
public AddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
public AddressDivision getDivision(int index)
getDivision
in interface AddressDivisionSeries
getDivision
in interface AddressStringDivisionSeries
public AddressSegment getSegment(int index)
getSegment
in interface AddressSegmentSeries
public AddressSegment[] getSegments()
getSegments
in interface AddressSegmentSeries
public void getSegments(AddressSegment[] segs)
getSegments
in interface AddressSegmentSeries
public void getSegments(int start, int end, AddressSegment[] segs, int index)
AddressSegmentSeries
getSegments
in interface AddressSegmentSeries
public abstract int getMaxSegmentValue()
public abstract java.lang.Iterable<? extends Address> getIterable()
AddressComponent
AddressComponent.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegmentSeries
public abstract java.util.Iterator<? extends Address> iterator()
AddressComponent
AddressItem.isMultiple()
to determine if this instance represents multiple.
This method iterates through the individual elements.iterator
in interface AddressComponent
iterator
in interface AddressSegmentSeries
public java.util.Iterator<? extends AddressSegment[]> segmentsIterator()
segmentsIterator
in interface AddressSegmentSeries
public abstract Address getLower()
AddressComponent
getLower
in interface AddressComponent
getLower
in interface AddressSegmentSeries
public abstract Address getUpper()
AddressComponent
getUpper
in interface AddressComponent
getUpper
in interface AddressSegmentSeries
public boolean isMultipleByPrefix()
AddressDivisionSeries
isMultipleByPrefix
in interface AddressDivisionSeries
public boolean isMultiple()
AddressItem
isMultiple
in interface AddressItem
public boolean isPrefixed()
AddressDivisionSeries
isPrefixed
in interface AddressDivisionSeries
public java.lang.Integer getPrefixLength()
getPrefixLength
in interface AddressDivisionSeries
public int getMinPrefix()
AddressDivisionSeries
getMinPrefix
in interface AddressDivisionSeries
public java.lang.Integer getEquivalentPrefix()
getEquivalentPrefix
in interface AddressDivisionSeries
public abstract boolean isMulticast()
InetAddress.isMulticastAddress()
public java.math.BigInteger getCount()
getCount
in interface AddressItem
public int isMore(AddressDivisionSeries other)
AddressDivisionSeries
isMore
in interface AddressDivisionSeries
public byte[] getBytes()
getBytes
in interface AddressItem
public byte[] getBytes(byte[] bytes)
AddressItem
getBytes
in interface AddressItem
public byte[] getUpperBytes()
getUpperBytes
in interface AddressItem
public byte[] getUpperBytes(byte[] bytes)
AddressItem
getUpperBytes
in interface AddressItem
public boolean isZero()
isZero
in interface AddressItem
public boolean isFullRange()
isFullRange
in interface AddressItem
public abstract boolean isLocal()
public int hashCode()
hashCode
in class java.lang.Object
public 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.Object
public abstract boolean contains(Address other)
public boolean isRangeEquivalentToPrefix()
AddressDivisionSeries
isRangeEquivalentToPrefix
in interface AddressDivisionSeries
public HostIdentifierString toAddressString()
public java.lang.String toHexString(boolean with0xPrefix)
toHexString
in interface AddressComponent
public java.lang.String toNormalizedString()
toNormalizedString
in interface AddressComponent
public java.lang.String toCanonicalString()
toCanonicalString
in interface AddressSegmentSeries
public java.lang.String toCompressedString()
toCompressedString
in interface AddressSegmentSeries
public java.lang.String toString()
toString
in class java.lang.Object
public abstract Address reverseSegments()
AddressSegmentSeries
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 abstract Address removePrefixLength()
AddressSegmentSeries
removePrefixLength
in interface AddressSegmentSeries
public abstract Address adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
public abstract Address adjustPrefixLength(int adjustment)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
public abstract Address setPrefixLength(int prefixLength)
AddressSegmentSeries
setPrefixLength
in interface AddressSegmentSeries
public abstract Address applyPrefixLength(int networkPrefixLength)
AddressSegmentSeries
applyPrefixLength
in interface AddressSegmentSeries