public abstract class IPAddressSection extends IPAddressDivisionGrouping implements 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 network prefix bit length.
|
static int |
bitsPerSegment(IPAddress.IPVersion version) |
static int |
bytesPerSegment(IPAddress.IPVersion version) |
boolean |
contains(IPAddressSection other) |
int |
getBitCount() |
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
abstract int |
getByteIndex(int networkPrefixLength) |
java.lang.Integer |
getEquivalentPrefix()
Returns a prefix length for which the range of this address section can be specified only using the section's lower value and the prefix length
If no such prefix exists, returns null
If this address section represents a single value, returns the bit length
|
java.lang.Integer |
getHostBits() |
abstract IPAddressSection |
getHostSection(int networkPrefixLength) |
abstract IPAddress.IPVersion |
getIPVersion() |
abstract java.lang.Iterable<? extends IPAddressSection> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract IPAddressSection |
getLower()
If this represents an address section with ranging values, returns an address section representing the lower values of the range
If this represents an address section with a single value in each segment, returns this.
|
java.lang.Integer |
getMaskPrefixLength(boolean network)
If this address section is equivalent to the mask for a CIDR prefix, it returns that prefix length.
|
int |
getMinPrefix()
Returns the smallest CIDR prefix possible (largest network),
such that this address paired with that prefix represents the exact same range of addresses.
|
abstract IPAddressNetwork |
getNetwork() |
abstract IPAddressSection |
getNetworkSection(int networkPrefixLength) |
abstract IPAddressSection |
getNetworkSection(int networkPrefixLength,
boolean withPrefixLength) |
IPAddressStringDivisionSeries[] |
getParts(IPAddressSection.IPStringBuilderOptions options)
Get all representations of this address including this IPAddressSection.
|
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) |
int |
getSegmentCount() |
abstract int |
getSegmentIndex(int networkPrefixLength) |
static java.lang.Integer |
getSegmentPrefixLength(int bitsPerSegment,
int segmentPrefixedBits)
Across the address prefixes are:
IPv6: (null):...:(null):(1 to 16):(0):...:(0)
or IPv4: ...(null).(1 to 8).(0)...
|
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)...
|
abstract IPAddressSegment[] |
getSegments() |
void |
getSegments(AddressSegment[] segs) |
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() |
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 an address section with ranging values, returns an address section representing the upper values of the range
If this represents an address section with a single value in each segment, returns this.
|
boolean |
isEntireAddress() |
boolean |
isFullRange() |
boolean |
isIPv4() |
boolean |
isIPv6() |
boolean |
isMaskCompatibleWithRange(IPAddressSection mask,
java.lang.Integer networkPrefixLength)
Returns whether the given mask and prefix combination can be used to generate a subnet.
|
abstract java.util.Iterator<? extends IPAddressSection> |
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 IPAddressSection |
removePrefixLength()
Removes the prefix.
|
abstract IPAddressSection |
removePrefixLength(boolean zeroed) |
abstract IPAddressSection |
reverseBits(boolean perByte)
Returns a new segment series with 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 java.util.Iterator<? extends IPAddressSegment[]> |
segmentsIterator() |
abstract IPAddressSection |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
abstract IPAddressSection |
setPrefixLength(int prefixLength,
boolean zeroed) |
IPAddressPartStringCollection |
toAllStringCollection()
Use this method with care...
|
java.lang.String |
toBinaryString()
Writes this address section 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.
|
abstract java.lang.String |
toCanonicalWildcardString()
This produces a string similar to the canonical string and avoids the CIDR prefix.
|
abstract java.lang.String |
toCompressedString()
This produces the shortest valid string.
|
abstract java.lang.String |
toCompressedWildcardString()
This is similar to toNormalizedWildcardString, avoiding the CIDR prefix, but with compression as well.
|
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
|
abstract java.lang.String |
toFullString()
This produces a string with no compressed segments and all segments of full length,
which is 4 characters for IPv6 segments and 3 characters for IPv4 segments.
|
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.
|
IPAddressSection |
toMinPrefixedEquivalent()
Constructs an equivalent address section with the smallest CIDR prefix length possible (largest network),
such that the address represents the exact same range of addresses.
|
java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions stringOptions) |
static java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions opts,
IPAddressStringDivisionSeries section) |
abstract java.lang.String |
toNormalizedWildcardString()
This produces a string similar to the normalized string and avoids the CIDR prefix.
|
java.lang.String |
toOctalString(boolean with0Prefix)
Writes this address as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.
|
IPAddressSection |
toPrefixedEquivalent()
Returns the CIDR address section for which the range of addresses
in this section is specified using just a single value and a prefix length in the returned section.
|
abstract java.lang.String |
toPrefixLengthString()
Returns a string with a CIDR prefix length if this section has a network prefix length.
|
abstract java.lang.String |
toReverseDNSLookupString()
Generates the reverse DNS lookup string
For 8.255.4.4 it is 4.4.255.8.in-addr.arpa
For 2001:db8::567:89ab it is b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa
|
abstract java.lang.String |
toSQLWildcardString()
This is the same as the string from toNormalizedWildcardString except that:
-it uses IPAddress.SEGMENT_SQL_WILDCARD instead of IPAddress.SEGMENT_WILDCARD
-it uses IPAddress.SEGMENT_SQL_SINGLE_WILDCARD
|
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() |
abstract IPAddressPartStringCollection |
toStringCollection(IPAddressSection.IPStringBuilderOptions options) |
abstract java.lang.String |
toSubnetString()
Produces a consistent subnet string.
|
equals, getDivision, getNetworkPrefixLength, getPrefixLength, getZeroRangeSegments, getZeroSegments, isMore, isMultipleByNetworkPrefix, isMultipleByPrefix, isPrefixed, isRangeEquivalentToPrefixcompareTo, getBytes, getBytes, getCount, getDivisionCount, getUpperBytes, getUpperBytes, hashCode, isMultiple, isRangeEquivalent, isZerocontainsgetBitsPerSegment, getBytesPerSegment, toCanonicalStringgetDivision, getPrefixLength, isMore, isMultipleByPrefix, isPrefixed, isRangeEquivalentToPrefixgetDivisionCounttoNormalizedStringgetBytes, 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 boolean isIPv4()
public boolean isIPv6()
public abstract IPAddress.IPVersion getIPVersion()
public abstract int getByteIndex(int networkPrefixLength)
public abstract int getSegmentIndex(int networkPrefixLength)
public abstract IPAddressSection getNetworkSection(int networkPrefixLength, boolean withPrefixLength)
public abstract IPAddressSection getNetworkSection(int networkPrefixLength)
public abstract IPAddressSection getHostSection(int networkPrefixLength)
public java.lang.Integer getMaskPrefixLength(boolean network)
network - whether to check for a network mask or a host maskpublic java.lang.Integer getHostBits()
public static java.lang.Integer getSegmentPrefixLength(int bitsPerSegment,
java.lang.Integer prefixLength,
int segmentIndex)
public static java.lang.Integer getSegmentPrefixLength(int bitsPerSegment,
int segmentPrefixedBits)
public abstract IPAddressNetwork getNetwork()
public int getSegmentCount()
getSegmentCount in interface AddressSegmentSeriespublic IPAddressSegment getSegment(int index)
getSegment in interface AddressSegmentSeriespublic boolean contains(IPAddressSection other)
other - public boolean isFullRange()
isFullRange in interface AddressItemisFullRange in class AddressDivisionGroupingpublic boolean isMaskCompatibleWithRange(IPAddressSection mask, java.lang.Integer networkPrefixLength)
IPAddress#isMaskCompatibleWithRange(IPAddress, Integer)mask - networkPrefixLength - public abstract IPAddressSection applyPrefixLength(int networkPrefixLength) throws AddressTypeException
applyPrefixLength in interface AddressSectionapplyPrefixLength in interface AddressSegmentSeriesAddressTypeExceptionpublic IPAddressSection toPrefixedEquivalent()
public IPAddressSection toMinPrefixedEquivalent()
public abstract IPAddressSection removePrefixLength(boolean zeroed)
public abstract IPAddressSection removePrefixLength()
AddressSegmentSeriesremovePrefixLength in interface AddressSectionremovePrefixLength in interface AddressSegmentSeriespublic IPAddressSection adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeriesadjustPrefixBySegment in interface AddressSectionadjustPrefixBySegment in interface AddressSegmentSeriespublic abstract IPAddressSection adjustPrefixLength(int adjustment)
AddressSegmentSeriesadjustPrefixLength in interface AddressSectionadjustPrefixLength in interface AddressSegmentSeriespublic abstract IPAddressSection setPrefixLength(int prefixLength)
AddressSegmentSeriessetPrefixLength in interface AddressSectionsetPrefixLength in interface AddressSegmentSeriespublic abstract IPAddressSection setPrefixLength(int prefixLength, boolean zeroed)
public int getMinPrefix()
getMinPrefix in interface AddressDivisionSeriesgetMinPrefix in class AddressDivisionGroupingIPAddressDivision.getMaskPrefixLength(boolean)public java.lang.Integer getEquivalentPrefix()
getEquivalentPrefix in interface AddressDivisionSeriesgetEquivalentPrefix in class IPAddressDivisionGroupingpublic abstract IPAddressSection getLower()
getLower in interface AddressComponentgetLower in interface AddressSectiongetLower in interface AddressSegmentSeriespublic abstract IPAddressSection getUpper()
getUpper in interface AddressComponentgetUpper in interface AddressSectiongetUpper in interface AddressSegmentSeriespublic abstract IPAddressSection reverseSegments()
AddressSegmentSeriesreverseSegments in interface AddressSectionreverseSegments in interface AddressSegmentSeriespublic abstract IPAddressSection reverseBits(boolean perByte)
AddressSegmentSeriesreverseBits in interface AddressComponentreverseBits in interface AddressSectionreverseBits in interface AddressSegmentSeriesperByte - if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic abstract IPAddressSection reverseBytes()
AddressSegmentSeriesreverseBytes in interface AddressComponentreverseBytes in interface AddressSectionreverseBytes in interface AddressSegmentSeriespublic abstract IPAddressSection reverseBytesPerSegment()
AddressSegmentSeriesreverseBytesPerSegment in interface AddressSectionreverseBytesPerSegment in interface AddressSegmentSeriespublic abstract IPAddressSegment[] getSegments()
getSegments in interface AddressSegmentSeriespublic abstract IPAddressSection getSection(int index)
AddressSegmentSeriesgetSection in interface AddressSectiongetSection in interface AddressSegmentSeriespublic abstract IPAddressSection getSection(int index, int endIndex)
AddressSegmentSeriesgetSection in interface AddressSectiongetSection in interface AddressSegmentSeriespublic void getSegments(AddressSegment[] segs)
getSegments in interface AddressSegmentSeriespublic void getSegments(int start,
int end,
AddressSegment[] segs,
int destIndex)
AddressSegmentSeriesgetSegments in interface AddressSegmentSeriespublic abstract java.lang.Iterable<? extends IPAddressSection> getIterable()
AddressComponentAddressComponent.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSectiongetIterable in interface AddressSegmentSeriespublic abstract java.util.Iterator<? extends IPAddressSection> iterator()
AddressComponentAddressItem.isMultiple() to determine if this instance represents multiple.
This method iterates through the individual elements.iterator in interface AddressComponentiterator in interface AddressSectioniterator in interface AddressSegmentSeriespublic abstract java.util.Iterator<? extends IPAddressSegment[]> segmentsIterator()
segmentsIterator in interface AddressSegmentSeriespublic boolean isEntireAddress()
public java.lang.String[] getSegmentStrings()
public java.lang.String toString()
toString in class AddressDivisionGroupingpublic abstract java.lang.String toFullString()
public abstract java.lang.String toCompressedString()
toCompressedString in interface AddressSegmentSeriespublic abstract java.lang.String toPrefixLengthString()
public abstract java.lang.String toSubnetString()
public abstract java.lang.String toNormalizedWildcardString()
public abstract java.lang.String toCanonicalWildcardString()
public abstract java.lang.String toCompressedWildcardString()
public abstract java.lang.String toSQLWildcardString()
public abstract java.lang.String toReverseDNSLookupString()
public java.lang.String toBinaryString()
public java.lang.String toOctalString(boolean with0Prefix)
public java.lang.String toHexString(boolean with0xPrefix)
toHexString in interface AddressComponentpublic java.lang.String toNormalizedString(IPAddressSection.IPStringOptions stringOptions)
public static java.lang.String toNormalizedString(IPAddressSection.IPStringOptions opts, IPAddressStringDivisionSeries section)
public IPAddressPartStringCollection toStandardStringCollection()
public IPAddressPartStringCollection toAllStringCollection()
public IPAddressPartStringCollection toDatabaseSearchStringCollection()
public abstract IPAddressPartStringCollection toStringCollection(IPAddressSection.IPStringBuilderOptions options)
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)