public abstract class IPAddress extends Address implements IPAddressSegmentSeries, IPAddressRange
IPAddress objects are immutable and cannot change values. This also makes them thread-safe.
String creation:
There are several public classes used to customize IP address strings.
For single strings from an address or address section, you use IPAddressSection.IPStringOptions
or IPv6AddressSection.IPv6StringOptions
along with toNormalizedString(IPAddressSection.IPStringOptions)
.
Or you use one of the methods like Address.toCanonicalString()
which does the same.
For string collections from an address or address section, use IPv4AddressSection.IPv4StringBuilderOptions
, IPv6AddressSection.IPv6StringBuilderOptions
, IPAddressSection.IPStringBuilderOptions
along with toStringCollection(IPAddressSection.IPStringBuilderOptions)
or toStrings(IPAddressSection.IPStringBuilderOptions)
.
Or you use one of the methods toStandardStringCollection()
, toAllStringCollection()
, toStandardStrings()
, toAllStrings()
which does the same.
Modifier and Type | Class and Description |
---|---|
static interface |
IPAddress.IPAddressValueProvider |
static class |
IPAddress.IPVersion |
Address.AddressValueProvider, Address.SegmentValueProvider
Modifier and Type | Field and Description |
---|---|
static IPAddressConverter |
DEFAULT_ADDRESS_CONVERTER
The default way by which addresses are converted, initialized to an instance of
IPAddressConverter.DefaultAddressConverter |
static char |
PREFIX_LEN_SEPARATOR |
ADDRESS_LOW_VALUE_COMPARATOR, ALTERNATIVE_RANGE_SEPARATOR, ALTERNATIVE_RANGE_SEPARATOR_STR, ALTERNATIVE_SEGMENT_WILDCARD_STR, DEFAULT_ADDRESS_COMPARATOR, HEX_PREFIX, OCTAL_PREFIX, RANGE_SEPARATOR, RANGE_SEPARATOR_STR, SEGMENT_SQL_SINGLE_WILDCARD, SEGMENT_SQL_SINGLE_WILDCARD_STR, SEGMENT_SQL_WILDCARD, SEGMENT_SQL_WILDCARD_STR, SEGMENT_WILDCARD, SEGMENT_WILDCARD_STR
Modifier and Type | Method and Description |
---|---|
abstract IPAddress |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
abstract IPAddress |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
abstract IPAddress |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
abstract IPAddress |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
abstract IPAddress |
applyPrefixLength(int networkPrefixLength)
Applies the given prefix length to create a new segment series.
|
IPAddress |
assignMinPrefixForBlock()
Constructs an equivalent address with the smallest CIDR prefix possible (largest network),
such that the range of values are a set of subnet blocks for that prefix.
|
IPAddress |
assignPrefixForSingleBlock()
Returns the equivalent CIDR address with a prefix length for which the address subnet block matches the range of values in this address.
|
abstract IPAddress |
bitwiseOr(IPAddress mask)
Equivalent to calling
bitwiseOr(IPAddress, boolean) with the second argument as false. |
abstract IPAddress |
bitwiseOr(IPAddress mask,
boolean retainPrefix)
Does the bitwise disjunction with this address.
|
abstract IPAddress |
bitwiseOrNetwork(IPAddress mask,
int networkPrefixLength)
Does the bitwise disjunction with this address.
|
abstract java.util.Iterator<? extends IPAddress> |
blockIterator(int segmentCount)
Iterates through series that can be obtained by iterating through all the upper segments up to the given segment count.
|
boolean |
contains(IPAddress other)
Returns whether this contains all values of the given address
|
boolean |
contains(IPAddressSeqRange other)
Returns whether this range contains all addresses in the given sequential range
|
static int |
getBitCount(IPAddress.IPVersion version) |
int |
getBitsPerSegment()
Returns the number of bits comprising each segment in this series.
|
java.lang.Integer |
getBlockMaskPrefixLength(boolean network)
If this address is equivalent to the mask for a CIDR prefix block, it returns that prefix length.
|
int |
getByteCount() |
static int |
getByteCount(IPAddress.IPVersion version) |
int |
getBytesPerSegment()
Returns the number of bytes comprising each segment in this series.
|
IPAddress.IPVersion |
getIPVersion()
Returns the version of this segment series
|
abstract java.lang.Iterable<? extends IPAddress> |
getIterable()
Useful for using an instance in a "for-each loop".
|
abstract IPAddress |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
abstract IPAddress |
getLowerNonZeroHost()
Similar to
IPAddressSegmentSeries.getLower() , but will not return a series that has a prefix length and whose host value is zero. |
void |
getMatchesSQLClause(java.lang.StringBuilder builder,
java.lang.String sqlExpression)
Returns a clause for matching this address.
|
void |
getMatchesSQLClause(java.lang.StringBuilder builder,
java.lang.String sqlExpression,
IPAddressSQLTranslator translator)
Returns a clause for matching this address.
|
int |
getMaxSegmentValue() |
abstract IPAddressNetwork<?,?,?,?,?> |
getNetwork()
Returns the network object for series of the same version (eg IPv4, IPv6 and MAC each have their own network object)
|
java.lang.Integer |
getNetworkPrefixLength()
Returns the CIDR network prefix length of the series, or null if the series has no associated prefix length.
|
java.math.BigInteger |
getNonZeroHostCount()
Gets the count of single value series that this series may represent, but excluding series whose host is zero.
|
inet.ipaddr.format.string.IPAddressStringDivisionSeries[] |
getParts(IPAddressSection.IPStringBuilderOptions options)
Returns all the ways of breaking this address down into segments, as selected.
|
IPAddressSection |
getSection()
Returns the address as an address section comprising all segments in the address.
|
IPAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
|
IPAddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
|
static int |
getSegmentCount(IPAddress.IPVersion version) |
java.math.BigInteger |
getSequentialBlockCount()
provides the count of elements from the
IPAddressSegmentSeries.sequentialBlockIterator() , the minimal number of sequential subseries that comprise this series |
abstract IPAddress |
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 |
includesMaxHost()
Returns whether the series has a host of all ones.
|
boolean |
includesMaxHost(int networkPrefixLength)
Returns whether all bits past the given prefix length are all ones.
|
boolean |
includesZeroHost()
Returns whether the series has a host of zero.
|
boolean |
includesZeroHost(int networkPrefixLength)
Returns whether all bits past the given prefix length are zero.
|
abstract IPAddress |
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 IPAddress |
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. |
abstract IPAddress |
intersect(IPAddress other)
Produces the subnet whose addresses are found in both this and the given subnet argument, or null if no such addresses.
|
boolean |
isAnyLocal()
Returns whether this address is the address which binds to any address on the local host.
|
boolean |
isIPv4() |
abstract boolean |
isIPv4Convertible()
Determines whether this address can be converted to IPv4, if not IPv4 already.
|
boolean |
isIPv6() |
abstract boolean |
isIPv6Convertible()
Determines whether an address can be converted to IPv6, if not IPv6 already.
|
abstract boolean |
isLinkLocal()
Returns whether the address is link local, whether unicast or multicast.
|
abstract boolean |
isLocal()
Returns true if the address is link local, site local, organization local, administered locally, or unspecified.
|
abstract boolean |
isLoopback() |
boolean |
isSingleNetwork()
Returns true if the network section of the address spans just a single value
|
boolean |
isUnspecified()
The unspecified address is the address that is all zeros.
|
abstract java.util.Iterator<? extends IPAddress> |
iterator()
Iterates through the individual segment series.
|
abstract IPAddress |
mask(IPAddress mask)
Equivalent to calling
mask(IPAddress, boolean) with the second argument as false. |
abstract IPAddress |
mask(IPAddress mask,
boolean retainPrefix)
Applies the given mask to all addresses represented by this IPAddress.
|
abstract IPAddress |
maskNetwork(IPAddress mask,
int networkPrefixLength)
Applies the given mask to all addresses represented by this IPAddress while also applying the given prefix length at the same time.
|
boolean |
matches(IPAddressString otherString) |
boolean |
matchesWithMask(IPAddress other,
IPAddress mask)
Applies the mask to this address and then compares values with the given address
|
abstract IPAddress[] |
mergeToPrefixBlocks(IPAddress... addresses)
Merges this with the list of addresses to produce the smallest list of prefix blocks
|
abstract IPAddress[] |
mergeToSequentialBlocks(IPAddress... addresses)
Merges this with the list of subnets to produce the smallest list of block subnets that are sequential.
|
abstract java.util.Iterator<? extends IPAddress> |
nonZeroHostIterator()
Similar to the prefix block iterator, but series with a host of zero are skipped.
|
abstract java.util.Iterator<? extends IPAddress> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
abstract java.util.Iterator<? extends IPAddress> |
prefixIterator()
Iterates through the individual prefixes.
|
abstract IPAddress |
removePrefixLength()
Removes the prefix length while zeroing out the existing host.
|
abstract IPAddress |
removePrefixLength(boolean zeroed)
Removes the prefix length.
|
abstract IPAddress |
reverseBits(boolean perByte)
Returns a new segment series with the bits reversed.
|
abstract IPAddress |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
abstract IPAddress |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
abstract IPAddress |
reverseSegments()
Returns a new segment series with the segments reversed.
|
java.util.Iterator<? extends IPAddress> |
sequentialBlockIterator()
Iterates through the sequential series that make up this series.
|
abstract IPAddress |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
abstract IPAddress |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
abstract IPAddress[] |
spanWithPrefixBlocks(IPAddress other)
Produces the list of prefix block subnets that span from this subnet to the given subnet.
|
abstract IPAddressSeqRange |
spanWithRange(IPAddress other)
Produces an IPAddressRange instance that spans this subnet to the given subnet.
|
abstract IPAddress[] |
spanWithSequentialBlocks(IPAddress other)
Produces a list of sequential block subnets that span all values from this subnet to the given subnet.
|
abstract IPAddress[] |
subtract(IPAddress other)
Subtract the given subnet from this subnet, returning an array of subnets for the result (the subnets will not be contiguous so an array is required).
|
IPAddressString |
toAddressString()
Generates an IPAddressString object for this IPAddress object.
|
IPAddressPartStringCollection |
toAllStringCollection() |
java.lang.String[] |
toAllStrings()
Produces almost all possible string variations
|
java.lang.String |
toBinaryString()
Writes this address as a single binary value with always the exact same number of characters
|
HostName |
toCanonicalHostName()
Does a reverse name lookup to get the canonical host name.
|
java.lang.String |
toCanonicalWildcardString()
This produces a string similar to the canonical string but avoids the CIDR prefix.
|
java.lang.String |
toCompressedWildcardString()
This is similar to toNormalizedWildcardString, avoiding the CIDR prefix, but with compression as well.
|
java.lang.String |
toConvertedString()
Returns a mixed string if it represents a convertible IPv4 address, returns the normalized string otherwise.
|
static java.lang.String |
toDelimitedSQLStrs(java.lang.String[] strs) |
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.
|
HostName |
toHostName()
If this address was resolved from a host, returns that host.
|
java.net.InetAddress |
toInetAddress()
Converts the lowest value of this address to an InetAddress
|
IPv4Address |
toIPv4()
If this address is IPv4, or can be converted to IPv4, returns that
IPv4Address . |
IPv6Address |
toIPv6() |
abstract IPAddress |
toMaxHost()
Returns the segment series with a host of all ones.
|
abstract IPAddress |
toMaxHost(int prefixLength)
Produces the series with host values of all one bits for the given prefix length.
|
static java.lang.String |
toNormalizedString(IPAddress.IPAddressValueProvider provider)
Allows for the creation of a normalized string without creating a full IP address object first.
|
static void |
toNormalizedString(IPAddress.IPAddressValueProvider provider,
java.lang.StringBuilder builder)
Allows for the creation of a normalized string without creating a full IP address object first.
|
java.lang.String |
toNormalizedString(IPAddressSection.IPStringOptions params)
Constructs a string representing this address according to the given parameters
|
java.lang.String |
toNormalizedWildcardString()
This produces a string similar to the normalized string but avoids the CIDR prefix.
|
java.lang.String |
toOctalString(boolean with0Prefix)
Writes this address as a single octal value with always the exact same number of characters, with or without a preceding 0 prefix.
|
abstract IPAddress |
toPrefixBlock()
Returns the subnet associated with the prefix length of this address.
|
abstract IPAddress |
toPrefixBlock(int networkPrefixLength)
Returns the segment series of the same length that spans all hosts.
|
java.lang.String |
toPrefixLengthString()
Returns a string with a CIDR network prefix length if this address has a network prefix length.
|
java.lang.String |
toReverseDNSLookupString()
Generates the reverse DNS lookup string
|
abstract IPAddressSeqRange |
toSequentialRange()
Creates a sequential range instance from the lowest and highest addresses in this subnet
|
abstract IPAddressSeqRange |
toSequentialRange(IPAddress other)
|
java.lang.String |
toSQLWildcardString()
This is the same as the string from toNormalizedWildcardString except that
it uses
Address.SEGMENT_SQL_WILDCARD instead of Address.SEGMENT_WILDCARD and also uses Address.SEGMENT_SQL_SINGLE_WILDCARD |
IPAddressPartStringCollection |
toStandardStringCollection() |
java.lang.String[] |
toStandardStrings()
Returns at most a few dozen string representations:
-mixed (1:2:3:4:5:6:1.2.3.4)
-full compressions (a:0:b:c:d:0:e:f or a::b:c:d:0:e:f or a:0:b:c:d::e:f)
-full leading zeros (000a:0000:000b:000c:000d:0000:000e:000f)
-all uppercase and all lowercase (a::a can be A::A)
-combinations thereof
|
IPAddressPartStringCollection |
toStringCollection(IPAddressSection.IPStringBuilderOptions options) |
java.lang.String[] |
toStrings(IPAddressSection.IPStringBuilderOptions options)
Rather than using toAllStrings or StandardStrings,
you can use this method to customize the list of strings produced for this address
|
java.lang.String |
toSubnetString()
Produces a consistent subnet string that looks like 1.2.*.* or 1:2::/16
In the case of IPv4, this means that wildcards are used instead of a network prefix when a network prefix has been supplied.
|
abstract java.lang.String |
toUNCHostName()
Generates the Microsoft UNC path component for this address
|
java.net.InetAddress |
toUpperInetAddress()
Converts the highest value of this address to an InetAddress.
|
abstract IPAddress |
toZeroHost()
Returns the segment series with a host of zero.
|
abstract IPAddress |
toZeroHost(int prefixLength)
Produces the series with host values of 0 for the given prefix length.
|
abstract IPAddress |
withoutPrefixLength()
Provides the same address with no prefix.
|
contains, containsPrefixBlock, containsSinglePrefixBlock, defaultIpv4Network, defaultIpv6Network, defaultMACNetwork, equals, getBitCount, getBlockCount, getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixCount, getPrefixCount, getPrefixLength, getPrefixLengthForSingleBlock, getSegmentCount, getSegments, getSegments, getSegmentStrings, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, includesMax, includesZero, isFullRange, isMax, isMore, isMulticast, isMultiple, isPrefixBlock, isPrefixed, isSameAddress, isSequential, isSinglePrefixBlock, isZero, prefixEquals, toCanonicalString, toCompressedString, toHexString, toNormalizedString, toString
getHostSection, getHostSection, getNetworkSection, getNetworkSection, getNetworkSection, getSegment, getSegments, segmentsIterator, segmentsNonZeroHostIterator
getDivision
getPrefixLength, isPrefixBlock, isPrefixed
getSegmentCount, getSegments, getSegments, getSegmentStrings, toCanonicalString, toCompressedString
getBitCount, getBlockCount, getCount, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, isMore, isPrefixBlock, isPrefixed, isSequential, isSinglePrefixBlock
getDivisionCount
toHexString, toNormalizedString
compareTo, containsPrefixBlock, containsSinglePrefixBlock, getBytes, getBytes, getBytes, getMinPrefixLengthForBlock, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero, testRange, testRange
prefixBlockIterator, prefixIterator, spanWithPrefixBlocks, spanWithSequentialBlocks, toCanonicalString, toNormalizedString
public static final char PREFIX_LEN_SEPARATOR
public static final IPAddressConverter DEFAULT_ADDRESS_CONVERTER
IPAddressConverter.DefaultAddressConverter
public HostName toHostName()
public HostName toCanonicalHostName()
InetAddress.getCanonicalHostName()
In particular, on some systems the loopback address has canonical host localhost and on others the canonical host is the same loopback address.public abstract IPAddressNetwork<?,?,?,?,?> getNetwork()
AddressSegmentSeries
getNetwork
in interface AddressSegmentSeries
getNetwork
in interface inet.ipaddr.format.string.IPAddressStringDivisionSeries
getNetwork
in interface IPAddressSegmentSeries
public IPAddressSection getSection()
getSection
in interface AddressSegmentSeries
getSection
in interface IPAddressSegmentSeries
getSection
in class Address
public IPAddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in interface IPAddressSegmentSeries
public IPAddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in interface IPAddressSegmentSeries
public inet.ipaddr.format.string.IPAddressStringDivisionSeries[] getParts(IPAddressSection.IPStringBuilderOptions options)
public int getMaxSegmentValue()
getMaxSegmentValue
in interface AddressSegmentSeries
public java.math.BigInteger getNonZeroHostCount()
IPAddressSegmentSeries
If this address series has no range of values, then there is only one such address, or none if it has a zero host.
If this has no CIDR network prefix length, then it is equivalent to AddressDivisionSeries.getCount()
.
getNonZeroHostCount
in interface IPAddressSegmentSeries
public int getBytesPerSegment()
AddressSegmentSeries
getBytesPerSegment
in interface AddressSegmentSeries
public int getBitsPerSegment()
AddressSegmentSeries
getBitsPerSegment
in interface AddressSegmentSeries
public int getByteCount()
getByteCount
in interface AddressItem
getByteCount
in class Address
public static int getByteCount(IPAddress.IPVersion version)
public static int getSegmentCount(IPAddress.IPVersion version)
public static int getBitCount(IPAddress.IPVersion version)
public abstract IPAddress getLowerNonZeroHost()
IPAddressSegmentSeries
IPAddressSegmentSeries.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 IPAddressSegmentSeries
public abstract IPAddress getLower()
AddressSegmentSeries
getLower
in interface AddressComponent
getLower
in interface AddressSegmentSeries
getLower
in interface AddressItemRange
getLower
in interface IPAddressRange
getLower
in interface IPAddressSegmentSeries
getLower
in class Address
public abstract IPAddress getUpper()
AddressSegmentSeries
getUpper
in interface AddressComponent
getUpper
in interface AddressSegmentSeries
getUpper
in interface AddressItemRange
getUpper
in interface IPAddressRange
getUpper
in interface IPAddressSegmentSeries
getUpper
in class Address
public abstract IPAddress reverseBits(boolean perByte)
AddressSegmentSeries
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegmentSeries
reverseBits
in interface IPAddressSegmentSeries
reverseBits
in class Address
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic abstract IPAddress reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegmentSeries
reverseBytes
in interface IPAddressSegmentSeries
reverseBytes
in class Address
public abstract IPAddress reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSegmentSeries
reverseBytesPerSegment
in interface IPAddressSegmentSeries
reverseBytesPerSegment
in class Address
public abstract IPAddress reverseSegments()
AddressSegmentSeries
IncompatibleAddressException
since all address series can reverse their segments.reverseSegments
in interface AddressSegmentSeries
reverseSegments
in interface IPAddressSegmentSeries
reverseSegments
in class Address
public abstract java.util.Iterator<? extends IPAddress> iterator()
AddressSegmentSeries
iterator
in interface AddressComponent
iterator
in interface AddressSegmentSeries
iterator
in interface AddressItemRange
iterator
in interface IPAddressRange
iterator
in interface IPAddressSegmentSeries
iterator
in class Address
public abstract java.util.Iterator<? extends IPAddress> nonZeroHostIterator()
IPAddressSegmentSeries
nonZeroHostIterator
in interface IPAddressSegmentSeries
public abstract java.util.Iterator<? extends IPAddress> prefixIterator()
AddressSegmentSeries
AddressSegmentSeries.iterator()
prefixIterator
in interface AddressSegmentSeries
prefixIterator
in interface IPAddressSegmentSeries
prefixIterator
in class Address
public abstract java.util.Iterator<? extends IPAddress> prefixBlockIterator()
AddressSegmentSeries
AddressSegmentSeries.iterator()
prefixBlockIterator
in interface AddressSegmentSeries
prefixBlockIterator
in interface IPAddressSegmentSeries
prefixBlockIterator
in class Address
public abstract java.util.Iterator<? extends IPAddress> blockIterator(int segmentCount)
IPAddressSegmentSeries
For instance, given the IPv4 subnet 1-2.3-4.5-6.7, given the count argument 2, it will iterate through 1.3.5-6.7, 1.4.5-6.7, 2.3.5-6.7, 2.4.5-6.7
blockIterator
in interface IPAddressSegmentSeries
public java.util.Iterator<? extends IPAddress> sequentialBlockIterator()
IPAddressSegmentSeries
IPAddressSegmentSeries.blockIterator(int)
with that segment count.
For instance, given the IPv4 subnet 1-2.3-4.5-6.7-8, it will iterate through 1.3.5.7-8, 1.3.6.7-8, 1.4.5.7-8, 1.4.6.7-8, 2.3.5.7-8, 2.3.6.7-8, 2.4.6.7-8, 2.4.6.7-8
sequentialBlockIterator
in interface IPAddressSegmentSeries
public java.math.BigInteger getSequentialBlockCount()
IPAddressSegmentSeries
IPAddressSegmentSeries.sequentialBlockIterator()
, the minimal number of sequential subseries that comprise this seriesgetSequentialBlockCount
in interface IPAddressSegmentSeries
public abstract java.lang.Iterable<? extends IPAddress> getIterable()
AddressItemRange
AddressItemRange.iterator()
directly.getIterable
in interface AddressComponent
getIterable
in interface AddressSegmentSeries
getIterable
in interface AddressItemRange
getIterable
in interface IPAddressRange
getIterable
in interface IPAddressSegmentSeries
getIterable
in class Address
public abstract IPAddress 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
increment
in interface IPAddressSegmentSeries
increment
in class Address
AddressValueException
- in case of underflow or overflowpublic abstract IPAddress 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
incrementBoundary
in interface IPAddressSegmentSeries
incrementBoundary
in class Address
AddressValueException
- in case of underflow or overflowpublic boolean isIPv4()
public boolean isIPv6()
public IPAddress.IPVersion getIPVersion()
IPAddressSegmentSeries
getIPVersion
in interface IPAddressSegmentSeries
public IPv4Address toIPv4()
IPv4Address
. Otherwise, returns null.isIPv4Convertible()
public IPv6Address toIPv6()
IPv6Address
. Otherwise, returns null.isIPv6Convertible()
public abstract boolean isIPv4Convertible()
IPv6Address.isIPv4Mapped()
You should also override toIPv4()
to match the conversion.
This method returns true for all IPv4 addresses.public abstract boolean isIPv6Convertible()
IPv4Address.getIPv4MappedAddress()
You should also override toIPv6()
to match the conversion.
This method returns true for all IPv6 addresses.public abstract boolean isLinkLocal()
InetAddress.isLinkLocalAddress()
public abstract boolean isLocal()
public boolean isUnspecified()
public boolean isAnyLocal()
InetAddress.isAnyLocalAddress()
public abstract boolean isLoopback()
InetAddress.isLoopbackAddress()
public java.net.InetAddress toUpperInetAddress()
toInetAddress()
public java.net.InetAddress toInetAddress()
public abstract IPAddressSeqRange toSequentialRange()
The two will represent the same set of addresses if and only if Address.isSequential()
is true
If this represents just a single address then the returned instance covers just that single address as well.
public abstract IPAddressSeqRange toSequentialRange(IPAddress other)
toIPv4()
or toIPv6()
public boolean matches(IPAddressString otherString)
public boolean contains(IPAddressSeqRange other)
IPAddressRange
contains
in interface IPAddressRange
public boolean contains(IPAddress other)
contains
in interface IPAddressRange
other
- public boolean matchesWithMask(IPAddress other, IPAddress mask)
mask
- other
- public static void toNormalizedString(IPAddress.IPAddressValueProvider provider, java.lang.StringBuilder builder)
IPAddress.IPAddressValueProvider
interface in whatever way is most efficient.
The string is appended to the provided StringBuilder
instance.provider
- builder
- public static java.lang.String toNormalizedString(IPAddress.IPAddressValueProvider provider)
IPAddress.IPAddressValueProvider
interface in whatever way is most efficient.provider
- public java.lang.String toFullString()
toFullString
in interface IPAddressSegmentSeries
public java.lang.String toSubnetString()
toSubnetString
in interface IPAddressSegmentSeries
public java.lang.String toNormalizedWildcardString()
toNormalizedWildcardString
in interface IPAddressSegmentSeries
public java.lang.String toCanonicalWildcardString()
toCanonicalWildcardString
in interface IPAddressSegmentSeries
public java.lang.String toCompressedWildcardString()
toCompressedWildcardString
in interface IPAddressSegmentSeries
public java.lang.String toSQLWildcardString()
Address.SEGMENT_SQL_WILDCARD
instead of Address.SEGMENT_WILDCARD
and also uses Address.SEGMENT_SQL_SINGLE_WILDCARD
toSQLWildcardString
in interface IPAddressSegmentSeries
public java.lang.String toPrefixLengthString()
toPrefixLengthString
in interface IPAddressSegmentSeries
public java.lang.String toConvertedString()
public abstract java.lang.String toUNCHostName()
public java.lang.String toReverseDNSLookupString()
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
toReverseDNSLookupString
in interface IPAddressSegmentSeries
IncompatibleAddressException
- if this address is a subnetpublic java.lang.String toBinaryString()
If this section represents a range of values not corresponding to a prefix, then this is printed as a range of two hex values.
toBinaryString
in interface IPAddressSegmentSeries
public java.lang.String toOctalString(boolean with0Prefix)
If this section represents a range of values not corresponding to a prefix, then this is printed as a range of two hex values.
toOctalString
in interface IPAddressSegmentSeries
public java.lang.String toNormalizedString(IPAddressSection.IPStringOptions params)
toNormalizedString
in interface IPAddressSegmentSeries
params
- the parameters for the address stringIncompatibleAddressException
- for cases in which the requested string cannot be produced, which can generally only occur with specific strings from specific subnets.public java.lang.String[] toStandardStrings()
public java.lang.String[] toAllStrings()
Use this method with care... a single IPv6 address can have thousands of string representations.
Examples:
Variations included in this method:
toStandardStrings()
public java.lang.String[] toStrings(IPAddressSection.IPStringBuilderOptions options)
public IPAddressPartStringCollection toStandardStringCollection()
public IPAddressPartStringCollection toAllStringCollection()
public IPAddressPartStringCollection toStringCollection(IPAddressSection.IPStringBuilderOptions options)
toStringCollection
in interface IPAddressSegmentSeries
public IPAddressString toAddressString()
This same IPAddress object can be retrieved from the resulting IPAddressString object using IPAddressString.getAddress()
In general, users are intended to create IPAddress objects from IPAddressString objects, while the reverse direction is generally not all that useful.
However, the reverse direction can be useful under certain circumstances.
Not all IPAddressString objects can be converted to IPAddress objects, as is the case with IPAddressString objects corresponding to the types IPType.INVALID and IPType.EMPTY.
Not all IPAddressString objects can be converted to IPAddress objects without specifying the IP version, as is the case with IPAddressString objects corresponding to the types IPType.PREFIX and IPType.ALL.
So in the event you wish to store a collection of IPAddress objects with a collection of IPAddressString objects, and not all the IPAddressString objects can be converted to IPAddress objects, then you may wish to use a collection of only IPAddressString objects, in which case this method is useful.
toAddressString
in class Address
public static java.lang.String toDelimitedSQLStrs(java.lang.String[] strs)
public java.lang.Integer getNetworkPrefixLength()
IPAddressDivisionSeries
Equivalent to AddressDivisionSeries.getPrefixLength()
,
which is the more general concept of set of address series that share the same set of leading bits.
For IP addresses and sections the prefix length and the CIDR network prefix length are the same thing.
For IP addresses and sections each individual segment has an associated prefix length which is determine by the network prefix length. The segment prefix lengths follow the pattern: null, null, ...., null, x, 0, 0, ..., 0
For instance, an IPv4 address 1.2.3.4/16 has the network prefix length 16. The segment prefix lengths are [null, 8, 0, 0] The segment prefix lengths of 1.2.3.4/22 are [null, null, 6, 0]
getNetworkPrefixLength
in interface IPAddressDivisionSeries
public boolean includesZeroHost()
IPAddressSegmentSeries
includesZeroHost
in interface IPAddressSegmentSeries
public boolean includesZeroHost(int networkPrefixLength)
IPAddressSegmentSeries
includesZeroHost
in interface IPAddressSegmentSeries
public abstract IPAddress toZeroHost(int prefixLength)
IPAddressSegmentSeries
If this series has the same prefix length, then the resulting series will too, otherwise the resulting series will have no prefix length.
This is nearly equivalent to doing the mask (bitwise conjunction) of this address series with the network mask for the given prefix length, but without the possibility of IncompatibleAddressException that can occur when applying a mask to a range of values. Instead, in this case, if the resulting series has a range of values, then the resulting series range boundaries will have host values of 0, but not necessarily the intervening values.
For instance, you can get the network address for a subnet of prefix length 16 as follows:
String addrStr = "1.2.3.4";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress networkAddress = address.toZeroHost(16); //1.2.0.0
toZeroHost
in interface IPAddressSegmentSeries
public abstract IPAddress toZeroHost()
IPAddressSegmentSeries
The resultant series will have the same prefix length if AddressNetwork.getPrefixConfiguration()
is not AddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
,
otherwise it will no longer have a prefix length.
For instance, you can get the network address for a subnet as follows:
String addrStr = "1.2.3.4/16";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress networkAddress = address.toZeroHost(); //1.2.0.0
toZeroHost
in interface IPAddressSegmentSeries
public abstract IPAddress toMaxHost(int prefixLength)
IPAddressSegmentSeries
If this series has the same prefix length, then the resulting series will too, otherwise the resulting series will have no prefix length.
This is nearly equivalent to doing the bitwise or (bitwise disjunction) of this address series with the network mask for the given prefix length, but without the possibility of IncompatibleAddressException that can occur when applying a mask to a range of values. Instead, in this case, if the resulting series has a range of values, then the resulting series range boundaries will have host values of all ones, but not necessarily the intervening values.
For instance, you can get the broadcast address for a subnet of prefix length 16 as follows:
String addrStr = "1.2.3.4";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress broadcastAddress = address.toMaxHost(16); //1.2.255.255
toMaxHost
in interface IPAddressSegmentSeries
public abstract IPAddress toMaxHost()
IPAddressSegmentSeries
The resultant series will have the same prefix length if AddressNetwork.getPrefixConfiguration()
is not AddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
,
otherwise it will no longer have a prefix length.
For instance, you can get the broadcast address for a subnet as follows:
String addrStr = "1.2.3.4/16";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress broadcastAddress = address.toMaxHost(); //1.2.255.255
toMaxHost
in interface IPAddressSegmentSeries
public boolean includesMaxHost()
IPAddressSegmentSeries
includesMaxHost
in interface IPAddressSegmentSeries
public boolean includesMaxHost(int networkPrefixLength)
IPAddressSegmentSeries
includesMaxHost
in interface IPAddressSegmentSeries
public boolean isSingleNetwork()
For example, return true for 1.2.3.4/16 and false for 1.2-3.3.4/16
public abstract IPAddress toPrefixBlock()
For example, if the address is 1.2.3.4/16 it returns the subnet 1.2.*.* /16
toPrefixBlock
in interface AddressSegmentSeries
toPrefixBlock
in interface IPAddressSegmentSeries
toPrefixBlock
in class Address
public abstract IPAddress toPrefixBlock(int networkPrefixLength) throws PrefixLenException
IPAddressSegmentSeries
toPrefixBlock
in interface IPAddressSegmentSeries
PrefixLenException
public IPAddress assignPrefixForSingleBlock()
If no such prefix length exists, returns null.
Examples:
1.2.3.4 returns 1.2.3.4/32
1.2.*.* returns 1.2.0.0/16
1.2.*.0/24 returns 1.2.0.0/16
1.2.*.4 returns null
1.2.252-255.* returns 1.2.252.0/22
1.2.3.4/x returns the same address
assignPrefixForSingleBlock
in interface IPAddressSegmentSeries
IPAddressSegmentSeries.toPrefixBlock()
,
IPAddressSegmentSeries.assignMinPrefixForBlock()
public IPAddress assignMinPrefixForBlock()
assignMinPrefixForBlock
in interface IPAddressSegmentSeries
IPAddressSegmentSeries.toPrefixBlock()
,
IPAddressSegmentSeries.assignPrefixForSingleBlock()
public java.lang.Integer getBlockMaskPrefixLength(boolean network)
network
- whether to check if we are a network mask or a host maskpublic abstract IPAddress[] spanWithPrefixBlocks(IPAddress other) throws AddressConversionException
If the other address is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
The resulting array is sorted from lowest address value to highest, regardless of the size of each prefix block.
From the list of returned subnets you can recover the original range (this and other) by converting each to IPAddressRange with toSequentialRange()
and them joining them into a single range with IPAddressSeqRange.join(IPAddressSeqRange...)
other
- AddressConversionException
public abstract IPAddress[] spanWithSequentialBlocks(IPAddress other) throws AddressConversionException
Individual block subnets come in the form 1-3.1-4.5.6-8, however that particular subnet is not sequential since address 1.1.5.8 is in the subnet, the next sequential address 1.1.5.9 is not in the subnet, and a higher address 1.2.5.6 is in the subnet. Blocks are sequential when the first segment with a range of values is followed by segments that span all values.
If the other address is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
The resulting array is sorted from lowest address value to highest, regardless of the size of each prefix block.
From the list of returned subnets you can recover the original range (this and other) by converting each to IPAddressRange with toSequentialRange()
and them joining them into a single range with IPAddressSeqRange.join(IPAddressSeqRange...)
other
- AddressConversionException
public abstract IPAddressSeqRange spanWithRange(IPAddress other) throws AddressConversionException
If the other address is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
other
- AddressConversionException
public abstract IPAddress[] mergeToPrefixBlocks(IPAddress... addresses) throws AddressConversionException
For the smallest list of subnets use mergeToSequentialBlocks(IPAddress...)
.
If any other address in the list is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
,
which can result in AddressConversionException
The result is sorted from single address to smallest blocks to largest blocks.
addresses
- the addresses to merge with thisAddressConversionException
public abstract IPAddress[] mergeToSequentialBlocks(IPAddress... addresses) throws AddressConversionException
Block subnets come in the form 1-3.1-4.5.6-8, however that subnet is not sequential since address 1.1.5.8 is in the subnet, the next sequential address 1.1.5.9 is not in the subnet, and a higher address 1.2.5.6 is in the subnet. Blocks are sequential when the first segment with a range of values is followed by segments that span all values.
This list will eliminate overlaps to produce the smallest list of sequential block subnets, which is the same size or smaller than the list of prefix blocks produced by mergeToPrefixBlocks(IPAddress...)
If the incoming blocks are not sequential, the result could be a longer list, since the list is divided into sequential blocks before merging.
If any other address in the list is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
,
which can result in AddressConversionException
The result is sorted from smallest blocks (possibly single address) to largest blocks.
addresses
- the addresses to merge with thisAddressConversionException
public abstract IPAddress intersect(IPAddress other) throws AddressConversionException
This is also known as the conjunction of the two sets of addresses.
If the address is not the same version, the default conversion will be applied using toIPv4()
or toIPv6()
, and it that fails, AddressConversionException
will be thrown.
other
- AddressConversionException
- if the address argument could not be converted to the same address version as thispublic abstract IPAddress[] subtract(IPAddress other) throws AddressConversionException
Computes the subnet difference, the set of addresses in this address subnet but not in the provided subnet. This is also known as the relative complement of the given argument in this subnet.
If the address is not the same version, the default conversion will be applied using toIPv4()
or toIPv6()
, and it that fails, AddressConversionException
will be thrown.
other
- AddressConversionException
- if the address argument could not be converted to the same address version as thispublic abstract IPAddress mask(IPAddress mask) throws AddressConversionException, IncompatibleAddressException
mask(IPAddress, boolean)
with the second argument as false.
If the mask is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
mask
- IncompatibleAddressException
- if this is a range of addresses and applying the mask results in an address that cannot be represented as a contiguous range within each segmentAddressConversionException
- if the address argument could not be converted to the same address version as thispublic abstract IPAddress mask(IPAddress mask, boolean retainPrefix) throws AddressConversionException, IncompatibleAddressException
If the mask is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
If this represents multiple addresses, and applying the mask to all addresses creates a set of addresses
that cannot be represented as a contiguous range within each segment, then IncompatibleAddressException
is thrown.
mask
- IncompatibleAddressException
- if this is a range of addresses and applying the mask results in an address that cannot be represented as a contiguous range within each segmentAddressConversionException
- if the address argument could not be converted to the same address version as thispublic abstract IPAddress maskNetwork(IPAddress mask, int networkPrefixLength) throws AddressConversionException, IncompatibleAddressException
Any existing prefix length is removed as the mask and new prefix length is applied to all individual addresses.
If the mask is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
If this represents multiple addresses, and applying the mask to all addresses creates a set of addresses
that cannot be represented as a contiguous range within each segment, then IncompatibleAddressException
is thrown.
IncompatibleAddressException
- if this is a range of addresses and applying the mask results in an address that cannot be represented as a contiguous range within each segmentAddressConversionException
- if the address argument could not be converted to the same address version as thispublic abstract IPAddress bitwiseOr(IPAddress mask) throws AddressConversionException, IncompatibleAddressException
bitwiseOr(IPAddress, boolean)
with the second argument as false.
If the mask is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
mask
- AddressConversionException
- if the address argument could not be converted to the same address version as thisIncompatibleAddressException
- if this is a range of addresses and applying the mask results in an address that cannot be represented as a contiguous range within each segmentpublic abstract IPAddress bitwiseOr(IPAddress mask, boolean retainPrefix) throws AddressConversionException, IncompatibleAddressException
The mask is applied to all individual addresses, similar to how the method mask(IPAddress, boolean)
applies the bitwise conjunction.
Any existing prefix length is removed beforehand. If the retainPrefix argument is true, then the existing prefix length will be applied to the result.
If the mask is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
If you wish to mask a portion of the network, use bitwiseOrNetwork(IPAddress, int)
For instance, you can get the broadcast address for a subnet as follows:
String addrStr = "1.2.3.4/16";
IPAddress address = new IPAddressString(addrStr).getAddress();
IPAddress hostMask = address.getNetwork().getHostMask(address.getNetworkPrefixLength());//0.0.255.255
IPAddress broadcastAddress = address.bitwiseOr(hostMask); //1.2.255.255
mask
- retainPrefix
- AddressConversionException
- if the address argument could not be converted to the same address version as thisIncompatibleAddressException
- if this is a range of addresses and applying the mask results in an address that cannot be represented as a contiguous range within each segmentpublic abstract IPAddress bitwiseOrNetwork(IPAddress mask, int networkPrefixLength) throws AddressConversionException, IncompatibleAddressException
If the mask is a different version than this, then the default conversion is applied to the other address first using toIPv4()
or toIPv6()
Any existing prefix length is dropped for the new prefix length and the mask is applied up to the end the new prefix length.
It is similar to how the maskNetwork(IPAddress, int)
method does the bitwise conjunction.
mask
- networkPrefixLength
- the new prefix length for the addressIncompatibleAddressException
- if this is a range of addresses and applying the mask results in an address that cannot be represented as a contiguous range within each segmentAddressConversionException
- if the address argument could not be converted to the same address version as thispublic abstract IPAddress removePrefixLength()
AddressSegmentSeries
If the series already has a prefix length, the bits outside the prefix become zero.
Equivalent to calling removePrefixLength(true)
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in interface IPAddressSegmentSeries
removePrefixLength
in class Address
IPAddressSegmentSeries.removePrefixLength(boolean)
public abstract IPAddress removePrefixLength(boolean zeroed)
AddressSegmentSeries
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in interface IPAddressSegmentSeries
removePrefixLength
in class Address
zeroed
- whether the bits outside the prefix become zeropublic abstract IPAddress withoutPrefixLength()
AddressSegmentSeries
withoutPrefixLength
in interface AddressSegmentSeries
withoutPrefixLength
in interface IPAddressSegmentSeries
withoutPrefixLength
in class Address
public abstract IPAddress 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.
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in interface IPAddressSegmentSeries
adjustPrefixBySegment
in class Address
nextSegment
- whether to move prefix to previous or following segment coundarypublic abstract IPAddress adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in interface IPAddressSegmentSeries
adjustPrefixBySegment
in class Address
nextSegment
- whether to move prefix to previous or following segment coundaryzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuespublic abstract IPAddress adjustPrefixLength(int adjustment)
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,
and if the entire host address contains the zero address,
then the resulting address is determined AddressNetwork.getPrefixConfiguration()
.
For example, 1.2.0.0/16 adjusted by -8 becomes 1.0.0.0/8.
1.2.0.0/16 adjusted by 8 becomes 1.2.0.0/24
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in interface IPAddressSegmentSeries
adjustPrefixLength
in class Address
adjustment
- public abstract IPAddress adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in interface IPAddressSegmentSeries
adjustPrefixLength
in class Address
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 IPAddress 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.
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
setPrefixLength
in interface IPAddressSegmentSeries
setPrefixLength
in class Address
AddressSegmentSeries.applyPrefixLength(int)
public abstract IPAddress setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeries
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength
in interface AddressSegmentSeries
setPrefixLength
in interface IPAddressSegmentSeries
setPrefixLength
in class Address
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.public abstract IPAddress 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
applyPrefixLength
in interface IPAddressSegmentSeries
applyPrefixLength
in class Address
AddressSegmentSeries.setPrefixLength(int)
public void getMatchesSQLClause(java.lang.StringBuilder builder, java.lang.String sqlExpression)
If this address is a subnet, this method will attempt to match every address in the subnet. Therefore it is much more efficient to use getNetworkSection().getStartsWithSQLClause() for a CIDR subnet.
builder
- sqlExpression
- public void getMatchesSQLClause(java.lang.StringBuilder builder, java.lang.String sqlExpression, IPAddressSQLTranslator translator)
Similar to getMatchesSQLClause(StringBuilder builder, String sqlExpression) but allows you to tailor the SQL produced.
builder
- sqlExpression
- translator
-