public abstract class IPAddressSection extends IPAddressDivisionGrouping implements IPAddressSegmentSeries, AddressSection
IPAddressSection objects are immutable. Some of the derived state is created upon demand and cached. This also makes them thread-safe. Almost all operations that can be performed on IPAddress objects can also be performed on IPAddressSection objects and vice-versa.
| Modifier and Type | Class and Description |
|---|---|
static class |
IPAddressSection.IPStringBuilderOptions
This user-facing class is designed to be a clear way to create a collection of strings.
|
static class |
IPAddressSection.IPStringOptions
Represents a clear way to create a specific type of string.
|
static interface |
IPAddressSection.SegFunction<R,S> |
static class |
IPAddressSection.WildcardOptions |
IPAddressDivisionGrouping.Range, IPAddressDivisionGrouping.RangeListAddressDivisionGrouping.StringOptions| Modifier and Type | Method and Description |
|---|---|
IPAddressSection |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
abstract IPAddressSection |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
abstract IPAddressSection |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new segment series.
|
IPAddressSection |
assignMinPrefixForBlock()
Constructs an equivalent address section with the smallest CIDR prefix possible (largest network),
such that the range of values are a set of subnet blocks for that prefix.
|
IPAddressSection |
assignPrefixForSingleBlock()
Returns the equivalent CIDR address section with a prefix length for which the subnet block for that prefix matches the range of values in this section.
|
static int |
bitsPerSegment(IPAddress.IPVersion version) |
static int |
bytesPerSegment(IPAddress.IPVersion version) |
boolean |
contains(IPAddressSection other) |
int |
getBitCount() |
java.lang.Integer |
getBlockMaskPrefixLength(boolean network)
If this address section is equivalent to the mask for a CIDR prefix block, it returns that prefix length.
|
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
java.math.BigInteger |
getCountImpl() |
java.lang.Integer |
getHostBitCount() |
java.lang.Integer |
getHostSegmentCount() |
abstract java.lang.Iterable<? extends IPAddressSection> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract IPAddressSection |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
abstract IPAddressSection |
getLowerNonZeroHost()
Similar to
IPAddressSegmentSeries.getLower(), but will not return a series that has a prefix length and whose host value is zero. |
int |
getMinPrefixLengthForBlock()
Returns the smallest CIDR prefix length possible (largest network) for which this includes the block of address sections for that prefix.
|
java.lang.Integer |
getNetworkSegmentCount() |
java.math.BigInteger |
getNonZeroHostCount()
Gets the count of single value series that this series may represent.
|
IPAddressStringDivisionSeries[] |
getParts(IPAddressSection.IPStringBuilderOptions options)
Get all representations of this address including this IPAddressSection.
|
java.lang.Integer |
getPrefixLengthForSingleBlock()
Returns a prefix length for which the range of this address section matches the the block of addresses for that prefix.
|
abstract IPAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
|
abstract IPAddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
|
IPAddressSegment |
getSegment(int index)
Returns the segment from this series at the given index.
|
int |
getSegmentCount()
Returns the number of segments in this series.
|
static java.lang.Integer |
getSegmentPrefixLength(int bitsPerSegment,
java.lang.Integer prefixLength,
int segmentIndex)
Across the address prefixes are:
IPv6: (null):...:(null):(1 to 16):(0):...:(0)
or IPv4: ...(null).(1 to 8).(0)...
|
void |
getSegments(AddressSegment[] segs)
Copies the existing segments into the given array.
|
void |
getSegments(int start,
int end,
AddressSegment[] segs,
int destIndex)
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.
|
void |
getStartsWithSQLClause(java.lang.StringBuilder builder,
java.lang.String expression)
This method gives you an SQL clause that allows you to search the database for the front part of an address or
addresses in a given network.
|
void |
getStartsWithSQLClause(java.lang.StringBuilder builder,
java.lang.String expression,
IPAddressSQLTranslator translator) |
abstract IPAddressSection |
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.
|
boolean |
includesZeroHost() |
boolean |
isEntireAddress() |
boolean |
isFullRange() |
boolean |
isIPv4() |
boolean |
isIPv6() |
abstract java.util.Iterator<? extends IPAddressSection> |
iterator()
Iterates through the individual segment series.
|
abstract java.util.Iterator<? extends IPAddressSection> |
nonZeroHostIterator() |
abstract IPAddressSection |
removePrefixLength()
Removes the prefix length.
|
abstract IPAddressSection |
removePrefixLength(boolean zeroed)
Removes the prefix length.
|
abstract IPAddressSection |
reverseBits(boolean perByte)
Returns a new series which has the bits reversed.
|
abstract IPAddressSection |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
abstract IPAddressSection |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
abstract IPAddressSection |
reverseSegments()
Returns a new segment series with the segments reversed.
|
abstract IPAddressSection |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
abstract IPAddressSection |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
IPAddressPartStringCollection |
toAllStringCollection()
Use this method with care...
|
java.lang.String |
toBinaryString()
Writes this IP address segment series as a single binary value with always the exact same number of characters
If this section represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.
|
IPAddressPartStringCollection |
toDatabaseSearchStringCollection()
Returns a set of strings for search the standard string representations in a database
-compress the largest compressible segments or no compression (a:0:0:c:d:0:e:f or a::c:d:0:e:f)
-upper/lowercase is not considered because many databases are case-insensitive
|
java.lang.String |
toHexString(boolean with0xPrefix)
Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
|
java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
Creates a customized string from this series.
|
static java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions opts,
IPAddressStringDivisionSeries section) |
java.lang.String |
toOctalString(boolean with0Prefix)
Writes this IP address segment series as a single octal value with always the exact same number of characters, with or without a preceding 0 prefix.
|
abstract IPAddressSection |
toPrefixBlock()
If this series has a prefix length, returns the subnet block for that prefix.
|
abstract IPAddressSection |
toPrefixBlock(int networkPrefixLength)
Returns the segment series of the same length that spans all hosts.
|
IPAddressPartStringCollection |
toStandardStringCollection()
Returns at most a couple dozen string representations:
-mixed (1:2:3:4:5:6:1.2.3.4)
-upper and lower case
-full compressions or no compression (a:0:0:c:d:0:e:f or a::c:d:0:e:f or a:0:b:c:d::e:f)
-full leading zeros (000a:0000:000b:000c:000d:0000:000e:000f)
-combinations thereof
|
java.lang.String |
toString() |
equals, getDivision, getNetwork, getNetworkPrefixLength, getPrefixLength, getZeroRangeSegments, getZeroSegments, isMore, isPrefixBlock, isPrefixed, isSinglePrefixBlockcompareTo, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, isMultiple, isZerogetHostSection, getHostSection, getIPVersion, getNetwork, getNetworkPrefixLength, getNetworkSection, getNetworkSection, getNetworkSection, getSegments, segmentsIterator, segmentsNonZeroHostIterator, toCanonicalWildcardString, toCompressedWildcardString, toFullString, toNormalizedWildcardString, toPrefixLengthString, toReverseDNSLookupString, toSQLWildcardString, toStringCollection, toSubnetStringcontainsgetBitsPerSegment, getBytesPerSegment, toCanonicalString, toCompressedStringgetDivision, getDivisionStrings, getPrefixLength, getUpperValue, getValue, isMore, isPrefixBlock, isPrefixed, isSinglePrefixBlockgetDivisionCounttoNormalizedStringgetBytes, getBytes, getCount, getUpperBytes, getUpperBytes, isMultiple, isZeropublic int getBitCount()
getBitCount in interface AddressItemgetBitCount in class AddressDivisionGroupingpublic int getByteCount()
AddressComponentgetByteCount in interface AddressComponentpublic static int bitsPerSegment(IPAddress.IPVersion version)
public static int bytesPerSegment(IPAddress.IPVersion version)
public java.math.BigInteger getNonZeroHostCount()
IPAddressSegmentSeriesAddressItem.getCount().getNonZeroHostCount in interface IPAddressSegmentSeriespublic java.math.BigInteger getCountImpl()
public boolean isIPv4()
public boolean isIPv6()
public java.lang.Integer getBlockMaskPrefixLength(boolean network)
network - whether to check for a network mask or a host maskpublic java.lang.Integer getNetworkSegmentCount()
public java.lang.Integer getHostSegmentCount()
public java.lang.Integer getHostBitCount()
public static java.lang.Integer getSegmentPrefixLength(int bitsPerSegment,
java.lang.Integer prefixLength,
int segmentIndex)
public int getSegmentCount()
AddressSegmentSeriesgetSegmentCount in interface AddressSegmentSeriespublic IPAddressSegment getSegment(int index)
AddressSegmentSeriesgetSegment in interface AddressSegmentSeriesgetSegment in interface IPAddressSegmentSeriespublic boolean contains(IPAddressSection other)
other - public boolean isFullRange()
isFullRange in interface AddressItemisFullRange in class AddressDivisionGroupingpublic abstract IPAddressSection applyPrefixLength(int networkPrefixLength) throws PrefixLenException
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.
With some address types, the bits moved outside the prefix will become zero in the returned series.
applyPrefixLength in interface AddressSectionapplyPrefixLength in interface AddressSegmentSeriesapplyPrefixLength in interface IPAddressSegmentSeriesPrefixLenExceptionAddressSegmentSeries.setPrefixLength(int)public abstract IPAddressSection toPrefixBlock()
IPAddressSegmentSeriestoPrefixBlock in interface AddressSegmentSeriestoPrefixBlock in interface IPAddressSegmentSeriespublic abstract IPAddressSection toPrefixBlock(int networkPrefixLength)
IPAddressSegmentSeriestoPrefixBlock in interface IPAddressSegmentSeriespublic IPAddressSection assignPrefixForSingleBlock()
If no such prefix length exists, returns null.
If this address represents just a single address, "this" is returned.
assignPrefixForSingleBlock in interface IPAddressSegmentSeriesIPAddressSegmentSeries.toPrefixBlock(),
IPAddressSegmentSeries.assignMinPrefixForBlock()public IPAddressSection assignMinPrefixForBlock()
assignMinPrefixForBlock in interface IPAddressSegmentSeriesIPAddressSegmentSeries.toPrefixBlock(),
IPAddressSegmentSeries.assignPrefixForSingleBlock()public boolean includesZeroHost()
includesZeroHost in class IPAddressDivisionGroupingpublic abstract IPAddressSection removePrefixLength(boolean zeroed)
IPAddressSegmentSeriesIPAddressSegmentSeries.removePrefixLength()removePrefixLength in interface IPAddressSegmentSeriespublic abstract IPAddressSection removePrefixLength()
AddressSegmentSeriesIf the series already has a prefix length, the bits previously not within the prefix become zero.
removePrefixLength in interface AddressSectionremovePrefixLength in interface AddressSegmentSeriesremovePrefixLength in interface IPAddressSegmentSeriespublic IPAddressSection adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeriesWhen prefix length is increased, the bits moved within the prefix become zero. When a prefix length is decreased, whether the bits moved outside the prefix become zero is dependent on the address type.
adjustPrefixBySegment in interface AddressSectionadjustPrefixBySegment in interface AddressSegmentSeriesadjustPrefixBySegment in interface IPAddressSegmentSeriespublic abstract IPAddressSection 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, whether the bits moved outside the prefix become zero is dependent on the address type.
adjustPrefixLength in interface AddressSectionadjustPrefixLength in interface AddressSegmentSeriesadjustPrefixLength in interface IPAddressSegmentSeriespublic abstract IPAddressSection 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.
When a prefix length is decreased, whether the bits moved outside the prefix become zero is dependent on the address type.
setPrefixLength in interface AddressSectionsetPrefixLength in interface AddressSegmentSeriessetPrefixLength in interface IPAddressSegmentSeriesAddressSegmentSeries.applyPrefixLength(int)public abstract IPAddressSection setPrefixLength(int prefixLength, boolean zeroed)
IPAddressSegmentSeriesIf zeroed is true, and this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero. When a prefix length is decreased, whether the bits moved outside the prefix become zero is dependent on the address type.
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength in interface IPAddressSegmentSeriespublic int getMinPrefixLengthForBlock()
getMinPrefixLengthForBlock in interface AddressDivisionSeriesgetMinPrefixLengthForBlock in class AddressDivisionGroupingIPAddressDivision.getBlockMaskPrefixLength(boolean)public java.lang.Integer getPrefixLengthForSingleBlock()
If no such prefix exists, returns null
If this address section represents a single value, returns the bit length
getPrefixLengthForSingleBlock in interface AddressDivisionSeriesgetPrefixLengthForSingleBlock in class IPAddressDivisionGroupingpublic abstract IPAddressSection getLowerNonZeroHost()
IPAddressSegmentSeriesIPAddressSegmentSeries.getLower(), but will not return a series that has a prefix length and whose host value is zero.
If this series has no prefix length, returns the same series as IPAddressSegmentSeries.getLower().getLowerNonZeroHost in interface IPAddressSegmentSeriespublic abstract IPAddressSection getLower()
AddressSegmentSeriesgetLower in interface AddressComponentgetLower in interface AddressSectiongetLower in interface AddressSegmentSeriesgetLower in interface IPAddressSegmentSeriespublic abstract IPAddressSection getUpper()
AddressSegmentSeriesgetUpper in interface AddressComponentgetUpper in interface AddressSectiongetUpper in interface AddressSegmentSeriesgetUpper in interface IPAddressSegmentSeriespublic abstract IPAddressSection reverseSegments()
AddressSegmentSeriesIncompatibleAddressException since all address series can reverse their segments.reverseSegments in interface AddressSectionreverseSegments in interface AddressSegmentSeriesreverseSegments in interface IPAddressSegmentSeriespublic abstract IPAddressSection reverseBits(boolean perByte)
IPAddressSegmentSeriesIf this has an associated prefix length, then the prefix length is dropped in the reversed series.
If this represents a range of values that cannot be reversed,
because reversing the range results in a set of addresses that cannot be described by a range, then this throws IncompatibleAddressException.
In such cases you can call IPAddressSegmentSeries.iterator(), IPAddressSegmentSeries.getLower(), IPAddressSegmentSeries.getUpper() or some other method to transform the address
into an address representing a single value before reversing.
reverseBits in interface AddressComponentreverseBits in interface AddressSectionreverseBits in interface AddressSegmentSeriesreverseBits in interface IPAddressSegmentSeriesperByte - if true, only the bits in each byte are reversed, if false, then all bits in the address are reversedpublic abstract IPAddressSection reverseBytes()
AddressSegmentSeriesreverseBytes in interface AddressComponentreverseBytes in interface AddressSectionreverseBytes in interface AddressSegmentSeriesreverseBytes in interface IPAddressSegmentSeriespublic abstract IPAddressSection reverseBytesPerSegment()
AddressSegmentSeriesreverseBytesPerSegment in interface AddressSectionreverseBytesPerSegment in interface AddressSegmentSeriesreverseBytesPerSegment in interface IPAddressSegmentSeriespublic abstract IPAddressSection getSection(int index)
AddressSegmentSeriesgetSection in interface AddressSectiongetSection in interface AddressSegmentSeriesgetSection in interface IPAddressSegmentSeriespublic abstract IPAddressSection getSection(int index, int endIndex)
AddressSegmentSeriesgetSection in interface AddressSectiongetSection in interface AddressSegmentSeriesgetSection in interface IPAddressSegmentSeriespublic void getSegments(AddressSegment[] segs)
AddressSegmentSeriesAddressSegmentSeries.getSegmentCount()getSegments in interface AddressSegmentSeriespublic void getSegments(int start,
int end,
AddressSegment[] segs,
int destIndex)
AddressSegmentSeriesgetSegments in interface AddressSegmentSeriesstart - the first segment index from this series to be includedend - the segment index after first to be excludedsegs - the target arraydestIndex - where to insert the segments in the segs arraypublic abstract java.lang.Iterable<? extends IPAddressSection> getIterable()
AddressComponentAddressComponent.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSectiongetIterable in interface AddressSegmentSeriesgetIterable in interface IPAddressSegmentSeriespublic abstract java.util.Iterator<? extends IPAddressSection> nonZeroHostIterator()
nonZeroHostIterator in interface IPAddressSegmentSeriespublic abstract java.util.Iterator<? extends IPAddressSection> iterator()
AddressSegmentSeriesiterator in interface AddressComponentiterator in interface AddressSectioniterator in interface AddressSegmentSeriesiterator in interface IPAddressSegmentSeriespublic boolean isEntireAddress()
public java.lang.String toString()
toString in class AddressDivisionGroupingpublic java.lang.String[] getSegmentStrings()
AddressSegmentSeriesgetSegmentStrings in interface AddressSegmentSeriespublic java.lang.String toBinaryString()
IPAddressSegmentSeriestoBinaryString in interface IPAddressSegmentSeriespublic java.lang.String toOctalString(boolean with0Prefix)
IPAddressSegmentSeriestoOctalString in interface IPAddressSegmentSeriespublic java.lang.String toHexString(boolean with0xPrefix)
AddressComponentIf this component represents a range of values outside of the network prefix length, then this is printed as a range of two hex values.
For instance, for IPv4 addresses there are 8 hex characters, for IPv6 addresses there are 32 hex characters.
toHexString in interface AddressComponentpublic java.lang.String toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
IPAddressSegmentSeriestoNormalizedString in interface IPAddressSegmentSeriespublic static java.lang.String toNormalizedString(IPAddressSection.IPStringOptions opts, IPAddressStringDivisionSeries section)
public IPAddressPartStringCollection toStandardStringCollection()
public IPAddressPartStringCollection toAllStringCollection()
public IPAddressPartStringCollection toDatabaseSearchStringCollection()
public IPAddressStringDivisionSeries[] getParts(IPAddressSection.IPStringBuilderOptions options)
IPAddressDivisionGroupingoptions - public void getStartsWithSQLClause(java.lang.StringBuilder builder,
java.lang.String expression)
getStartsWithSQLClause(StringBuilder, String, IPAddressSQLTranslator)builder - expression - the expression that must match the condition, whether a column name or otherpublic void getStartsWithSQLClause(java.lang.StringBuilder builder,
java.lang.String expression,
IPAddressSQLTranslator translator)