- All Implemented Interfaces:
AddressComponent
,AddressSection
,AddressSegmentSeries
,AddressComponentRange
,AddressDivisionSeries
,AddressItem
,AddressItemRange
,IPAddressDivisionSeries
,AddressStringDivisionSeries
,IPAddressStringDivisionSeries
,IPAddressSegmentSeries
,Serializable
,Comparable<AddressItem>
- Direct Known Subclasses:
IPv4AddressSection
,IPv6AddressSection
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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
This user-facing class is designed to be a clear way to create a collection of strings.static class
Represents a clear way to create a specific type of string.static interface
static interface
static interface
static class
Nested classes/interfaces inherited from class inet.ipaddr.format.standard.IPAddressDivisionGrouping
IPAddressDivisionGrouping.Range, IPAddressDivisionGrouping.RangeList
Nested classes/interfaces inherited from class inet.ipaddr.format.standard.AddressDivisionGrouping
AddressDivisionGrouping.DivisionLengthProvider, AddressDivisionGrouping.DivisionValueProvider, AddressDivisionGrouping.StringOptions
-
Method Summary
Modifier and TypeMethodDescriptionabstract IPAddressSection
adjustPrefixBySegment
(boolean nextSegment) Increases or decreases prefix length to the next segment boundary.adjustPrefixBySegment
(boolean nextSegment, boolean zeroed) 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
adjustPrefixLength
(int adjustment, boolean zeroed) Increases or decreases prefix length by the given increment.abstract IPAddressSection
applyPrefixLength
(int networkPrefixLength) Deprecated.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.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) abstract Iterator
<? extends IPAddressSection> blockIterator
(int segmentCount) Iterates through series that can be obtained by iterating through all the upper segments up to the given segment count.abstract AddressComponentSpliterator
<? extends IPAddressSection> blockSpliterator
(int segmentCount) Partitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.abstract Stream
<? extends IPAddressSection> blockStream
(int segmentCount) Returns a sequential stream of the individual blocks created from each of the individual values up to the given segment count.static int
bytesPerSegment
(IPAddress.IPVersion version) boolean
contains
(AddressSection other) Determines if one section contains another.boolean
Returns whether this address contains the non-zero host addresses in other.boolean
containsPrefixBlock
(int prefixLength) Returns whether the values of this division grouping contain the prefix block for the given prefix lengthabstract IPAddressSection
Returns the minimal-size prefix block that covers all the values in this series.int
Provides the number of bits comprising this address itemgetBlockCount
(int segmentCount) Returns the count of values in the initial (higher) count of divisions.getBlockMaskPrefixLength
(boolean network) If this address section is equivalent to the mask for a CIDR prefix block, it returns that prefix length.int
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8getDivision
(int index) Returns the host mask associated with the CIDR network prefix length of this series.abstract Iterable
<? extends IPAddressSection> 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
Similar toIPAddressSegmentSeries.getLower()
, but will not return a series that has a prefix length and whose host value is zero.int
Returns the maximum possible segment value for this type of address.int
Returns the smallest CIDR prefix length possible (largest network) for which this includes the block of address sections for that prefix.Returns the network mask associated with the CIDR network prefix length of this series.Gets the count of single value series that this series may represent, but excluding series whose host is zero.Get all representations of this address including this IPAddressSection.Returns a prefix length for which the range of this address section matches the block of addresses for that prefix.abstract IPAddressSection
getSection
(int index) Gets the subsection from the series starting from the given index The first segment is at index 0.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 The first segment is at index 0.getSegment
(int index) Returns the segment from this series at the given index.int
Returns the number of segments in this series.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 given indexvoid
getSegments
(AddressSegment[] segs) Copies the existing segments into the given array.String[]
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.provides the count of elements from theIPAddressSegmentSeries.sequentialBlockIterator()
, the minimal number of sequential sub-series that comprise this seriesvoid
getStartsWithSQLClause
(StringBuilder builder, 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
(StringBuilder builder, 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
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
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 IPAddressSection
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 IPAddressSection
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.boolean
boolean
whether this address item represents all possible values attainable by an address item of this typeboolean
isIPv4()
boolean
isIPv6()
boolean
boolean
Returns whether the division grouping range matches the block of values for its prefix length.boolean
Returns whether this section has a prefix length and if so, whether the host section is zero for this section or all sections in this set of address sections.boolean
isZeroHost
(int prefixLength) Returns whether the host is zero for the given prefix length for this section or all sections in this set of address sections.abstract Iterator
<? extends IPAddressSection> iterator()
Iterates through the individual address components.boolean
matchesWithMask
(IPAddressSection other, IPAddressSection mask) Applies the mask to this address section and then compares values with the given address sectionabstract Iterator
<? extends IPAddressSection> Similar to the iterator, but series with a host of zero are skipped.abstract Iterator
<? extends IPAddressSection> Iterates through the individual prefix blocks.abstract AddressComponentSpliterator
<? extends IPAddressSection> Partitions and traverses through the individual prefix blocks for the prefix length of this series.abstract Stream
<? extends IPAddressSection> Returns a sequential stream of the individual prefix blocks for the prefix length of this series.abstract boolean
prefixContains
(IPAddressSection other) Returns whether the prefix of this address contains all values of the same bits in the given address or subnetabstract Iterator
<? extends IPAddressSection> Iterates through the individual prefixes.abstract AddressComponentSpliterator
<? extends IPAddressSection> Partitions and traverses through the individual prefixes for the prefix length of this series.abstract Stream
<? extends IPAddressSection> Returns a sequential stream of the individual prefixes for the prefix length of this series.abstract IPAddressSection
Deprecated.abstract IPAddressSection
removePrefixLength
(boolean zeroed) Deprecated.abstract IPAddressSection
reverseBits
(boolean perByte) Returns a new series which has the bits reversed.abstract IPAddressSection
Returns a new segment series with the bytes reversed.abstract IPAddressSection
Returns a new segment series with the bytes reversed within each segment.abstract IPAddressSection
Returns a new segment series with the segments reversed.Iterator
<? extends IPAddressSection> Iterates through the sequential series that make up this series.AddressComponentSpliterator
<? extends IPAddressSection> Partitions and traverses through the individual sequential blocks.Stream
<? extends IPAddressSection> Returns a sequential stream of the individual sequential blocks.abstract IPAddressSection
setPrefixLength
(int prefixLength) Sets the prefix length.abstract IPAddressSection
setPrefixLength
(int prefixLength, boolean zeroed) Sets the prefix length.abstract IPAddressSection
setPrefixLength
(int prefixLength, boolean zeroed, boolean zeroHostIsBlock) Sets the prefix length while allowing the caller to control whether bits moved in or out of the prefix become zero, and whether a zero host for the new prefix bits can be translated into a prefix block.abstract AddressComponentSpliterator
<? extends IPAddressSection> Partitions and traverses through the individual address components.abstract Stream
<? extends IPAddressSection> stream()
Returns a sequential stream of the individual address components.Use this method with care...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 binary values.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-insensitivetoHexString
(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.abstract IPAddressSection
Returns the segment series with a host of all ones.abstract IPAddressSection
toMaxHost
(int prefixLength) Produces the series with host values of all one bits for the given prefix length.toNormalizedString
(IPAddressSection.IPStringOptions stringOptions) Creates a customized string from this series.static 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
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.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 thereoftoString()
abstract IPAddressSection
Returns the segment series with a host of zero, the host being the bits following the prefix length.abstract IPAddressSection
toZeroHost
(int prefixLength) Produces the series with host values of 0 for the given prefix length.abstract IPAddressSection
Returns the segment series with a network of zero, the network being the bits within the prefix length.abstract IPAddressSection
Provides the same address with no prefix.Methods inherited from class inet.ipaddr.format.standard.IPAddressDivisionGrouping
containsSinglePrefixBlock, equals, getLeadingBitCount, getNetwork, getNetworkPrefixLength, getPrefixLength, getTrailingBitCount, getZeroRangeSegments, getZeroSegments, isMore, isPrefixBlock
Methods inherited from class inet.ipaddr.format.standard.AddressDivisionGrouping
hashCode
Methods inherited from class inet.ipaddr.format.AddressDivisionGroupingBase
getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getPrefixCount, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isPrefixed, isZero
Methods inherited from interface inet.ipaddr.AddressComponent
getNetwork, toNormalizedString
Methods inherited from interface inet.ipaddr.format.AddressDivisionSeries
getCount, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequential
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, containsSinglePrefixBlock, getBytes, getBytes, getBytes, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isZero
Methods inherited from interface inet.ipaddr.AddressSection
prefixEquals
Methods inherited from interface inet.ipaddr.AddressSegmentSeries
getBitsPerSegment, getBytesPerSegment, isOneBit, testBit, toCanonicalString, toCompressedString
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivisionSeries
getDivisionCount
Methods inherited from interface inet.ipaddr.format.IPAddressDivisionSeries
getNetworkPrefixLength
Methods inherited from interface inet.ipaddr.IPAddressSegmentSeries
getHostSection, getHostSection, getIPVersion, getNetwork, getNetworkSection, getNetworkSection, getNetworkSection, getSection, getSegments, segmentsIterator, segmentsNonZeroHostIterator, segmentsSpliterator, segmentsStream, spanWithPrefixBlocks, spanWithSequentialBlocks, toCanonicalWildcardString, toCompressedWildcardString, toFullString, toNormalizedWildcardString, toPrefixLengthString, toReverseDNSLookupString, toSegmentedBinaryString, toSQLWildcardString, toStringCollection, toSubnetString
Methods inherited from interface inet.ipaddr.format.string.IPAddressStringDivisionSeries
getPrefixLength, isPrefixBlock, isPrefixed
-
Method Details
-
isSinglePrefixBlock
public boolean isSinglePrefixBlock()Description copied from class:IPAddressDivisionGrouping
Returns whether the division grouping range matches the block of values for its prefix length. In other words, returns true if and only if it has a prefix length and it has just a single prefix.- Specified by:
isSinglePrefixBlock
in interfaceAddressDivisionSeries
- Overrides:
isSinglePrefixBlock
in classIPAddressDivisionGrouping
- Returns:
-
getBitCount
public int getBitCount()Description copied from interface:AddressItem
Provides the number of bits comprising this address item- Specified by:
getBitCount
in interfaceAddressDivisionSeries
- Specified by:
getBitCount
in interfaceAddressItem
- Returns:
- the number of bits
-
getByteCount
public int getByteCount()Description copied from interface:AddressItem
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8- Specified by:
getByteCount
in interfaceAddressItem
- Returns:
- the number of bytes
-
bitsPerSegment
-
bytesPerSegment
-
getNonZeroHostCount
Description copied from interface:IPAddressSegmentSeries
Gets the count of single value series that this series may represent, but excluding series whose host is zero. The host is determined by the CIDR prefix length, if there is one.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()
.- Specified by:
getNonZeroHostCount
in interfaceIPAddressSegmentSeries
- Returns:
-
getCountImpl
-
getBlockCount
Description copied from interface:AddressDivisionSeries
Returns the count of values in the initial (higher) count of divisions.- Specified by:
getBlockCount
in interfaceAddressDivisionSeries
- Returns:
-
isIPv4
public boolean isIPv4() -
isIPv6
public boolean isIPv6() -
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegmentSeries
Returns the maximum possible segment value for this type of address. Note this is not the maximum value of the range of segment values in this specific address, this is the maximum value of any segment for this address type, and is usually determined by the number of bits per segment.- Specified by:
getMaxSegmentValue
in interfaceAddressSegmentSeries
- Returns:
- the maximum possible segment value for a series of the same type
-
getBlockMaskPrefixLength
If this address section is equivalent to the mask for a CIDR prefix block, it returns that prefix length. Otherwise, it returns null. A CIDR network mask is an address with all 1s in the network section and then all 0s in the host section. A CIDR host mask is an address with all 0s in the network section and then all 1s in the host section. The prefix length is the length of the network section. Also, keep in mind that the prefix length returned by this method is not equivalent to the prefix length used to construct this object. The prefix length used to construct indicates the network and host section of this address. The prefix length returned here indicates the whether the value of this address can be used as a mask for the network and host section of any other address. Therefore the two values can be different values, or one can be null while the other is not. This method applies only to the lower value of the range if this section represents multiple values.- Parameters:
network
- whether to check for a network mask or a host mask- Returns:
- the prefix length corresponding to this mask, or null if there is no such prefix length
-
getSegmentCount
public int getSegmentCount()Description copied from interface:AddressSegmentSeries
Returns the number of segments in this series.- Specified by:
getSegmentCount
in interfaceAddressSegmentSeries
- Returns:
-
getSegment
Description copied from interface:AddressSegmentSeries
Returns the segment from this series at the given index. The first segment is at index 0. A segment is an address division, seeAddressDivisionSeries.getDivision(int)
, the difference being that all segments in a given series are the same bit count, while divisions can have variable length.- Specified by:
getSegment
in interfaceAddressSegmentSeries
- Specified by:
getSegment
in interfaceIPAddressSegmentSeries
- Returns:
-
getDivision
- Specified by:
getDivision
in interfaceAddressDivisionSeries
- Specified by:
getDivision
in interfaceAddressStringDivisionSeries
- Specified by:
getDivision
in interfaceIPAddressDivisionSeries
- Specified by:
getDivision
in interfaceIPAddressStringDivisionSeries
- Overrides:
getDivision
in classIPAddressDivisionGrouping
- Returns:
- the given division in this series. The first is at index 0.
-
containsPrefixBlock
public boolean containsPrefixBlock(int prefixLength) Description copied from class:AddressDivisionGrouping
Returns whether the values of this division grouping contain the prefix block for the given prefix length- Specified by:
containsPrefixBlock
in interfaceAddressItem
- Overrides:
containsPrefixBlock
in classIPAddressDivisionGrouping
- Parameters:
prefixLength
-- Returns:
-
contains
Description copied from interface:AddressSection
Determines if one section contains another.Sections must have the same number of segments to be comparable.
For sections which are aware of their position in an address (IPv6 and MAC), their respective positions must match to be comparable.
- Specified by:
contains
in interfaceAddressSection
- Parameters:
other
-- Returns:
- whether this subnet contains the given address section
-
containsNonZeroHosts
Returns whether this address contains the non-zero host addresses in other.- Parameters:
other
-- Returns:
-
prefixContains
Returns whether the prefix of this address contains all values of the same bits in the given address or subnet- Parameters:
other
-- Returns:
-
isFullRange
public boolean isFullRange()Description copied from interface:AddressItem
whether this address item represents all possible values attainable by an address item of this type- Specified by:
isFullRange
in interfaceAddressItem
- Overrides:
isFullRange
in classAddressDivisionGroupingBase
- Returns:
- whether this address item represents all possible values attainable by an address item of this type, or in other words, both includesZero() and includesMax() return true
-
toZeroHost
Description copied from interface:IPAddressSegmentSeries
Returns the segment series with a host of zero, the host being the bits following the prefix length. If the series has no prefix length, then it returns an all-zero series.The default behaviour is that the resultant series will have the same prefix length. The resultant series will not have a prefix length if
AddressNetwork.getPrefixConfiguration()
isAddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
.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
- Specified by:
toZeroHost
in interfaceIPAddressSegmentSeries
- Returns:
- See Also:
-
toZeroHost
Description copied from interface:IPAddressSegmentSeries
Produces the series with host values of 0 for the given prefix length.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
- Specified by:
toZeroHost
in interfaceIPAddressSegmentSeries
- Parameters:
prefixLength
-- Returns:
-
toZeroNetwork
Description copied from interface:IPAddressSegmentSeries
Returns the segment series with a network of zero, the network being the bits within the prefix length. If the series has no prefix length, then it returns an all-zero series.The default behaviour is that the resultant series will have the same prefix length. The resultant series will not have a prefix length if
AddressNetwork.getPrefixConfiguration()
isAddressNetwork.PrefixConfiguration.ALL_PREFIXED_ADDRESSES_ARE_SUBNETS
.- Specified by:
toZeroNetwork
in interfaceIPAddressSegmentSeries
- Returns:
- See Also:
-
toMaxHost
Description copied from interface:IPAddressSegmentSeries
Returns the segment series with a host of all ones. If the series has no prefix length, then it returns an all-ones series.The resultant series will have the same prefix length if
AddressNetwork.getPrefixConfiguration()
is notAddressNetwork.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
- Specified by:
toMaxHost
in interfaceIPAddressSegmentSeries
- Returns:
-
toMaxHost
Description copied from interface:IPAddressSegmentSeries
Produces the series with host values of all one bits for the given prefix length.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
- Specified by:
toMaxHost
in interfaceIPAddressSegmentSeries
- Parameters:
prefixLength
-- Returns:
-
applyPrefixLength
@Deprecated public abstract IPAddressSection applyPrefixLength(int networkPrefixLength) throws PrefixLenException Deprecated.Description copied from interface:AddressSegmentSeries
Applies the given prefix length to create a new segment series.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.
- Specified by:
applyPrefixLength
in interfaceAddressSection
- Specified by:
applyPrefixLength
in interfaceAddressSegmentSeries
- Specified by:
applyPrefixLength
in interfaceIPAddressSegmentSeries
- Parameters:
networkPrefixLength
-- Returns:
- Throws:
PrefixLenException
- See Also:
-
coverWithPrefixBlock
Description copied from interface:IPAddressSegmentSeries
Returns the minimal-size prefix block that covers all the values in this series. The resulting block will have a larger series count than this, unless this series is already a prefix block.- Specified by:
coverWithPrefixBlock
in interfaceIPAddressSegmentSeries
-
toPrefixBlock
Description copied from interface:IPAddressSegmentSeries
If this series has a prefix length, returns the subnet block for that prefix. If this series has no prefix length, this series is returned.- Specified by:
toPrefixBlock
in interfaceAddressSection
- Specified by:
toPrefixBlock
in interfaceAddressSegmentSeries
- Specified by:
toPrefixBlock
in interfaceIPAddressSegmentSeries
- Returns:
- the subnet block for the prefix length
-
toPrefixBlock
Description copied from interface:IPAddressSegmentSeries
Returns the segment series of the same length that spans all hosts. The network prefix length will be the one provided, and the network values will match the same of this series.- Specified by:
toPrefixBlock
in interfaceIPAddressSegmentSeries
- Parameters:
networkPrefixLength
-- Returns:
-
getHostMask
Description copied from interface:IPAddressSegmentSeries
Returns the host mask associated with the CIDR network prefix length of this series. If this series has no prefix length, then the whole series is considered a host and the all ones host mask is returned.- Specified by:
getHostMask
in interfaceIPAddressSegmentSeries
- Returns:
-
getNetworkMask
Description copied from interface:IPAddressSegmentSeries
Returns the network mask associated with the CIDR network prefix length of this series. If this series has no prefix length, then the whole series is considered network and the all ones network mask is returned.- Specified by:
getNetworkMask
in interfaceIPAddressSegmentSeries
- Returns:
-
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.If no such prefix length exists, returns null.
If this address represents just a single address, "this" is returned.
- Specified by:
assignPrefixForSingleBlock
in interfaceIPAddressSegmentSeries
- Returns:
- See Also:
-
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.- Specified by:
assignMinPrefixForBlock
in interfaceIPAddressSegmentSeries
- Returns:
- See Also:
-
includesZeroHost
public boolean includesZeroHost()Description copied from interface:IPAddressSegmentSeries
Returns whether the series has a host of zero. If the series has no prefix length, or the prefix length matches the bit count, then returns false. Otherwise, it checks whether all bits past the prefix are zero.- Specified by:
includesZeroHost
in interfaceIPAddressSegmentSeries
- Overrides:
includesZeroHost
in classIPAddressDivisionGrouping
- Returns:
-
includesZeroHost
public boolean includesZeroHost(int networkPrefixLength) Description copied from interface:IPAddressSegmentSeries
Returns whether all bits past the given prefix length are zero.- Specified by:
includesZeroHost
in interfaceIPAddressSegmentSeries
- Returns:
-
includesMaxHost
public boolean includesMaxHost()Description copied from interface:IPAddressSegmentSeries
Returns whether the series has a host of all ones. If the series has no prefix length, or the prefix length matches the bit count, then returns false. Otherwise, it checks whether all bits past the prefix are ones.- Specified by:
includesMaxHost
in interfaceIPAddressSegmentSeries
- Returns:
-
includesMaxHost
public boolean includesMaxHost(int networkPrefixLength) Description copied from interface:IPAddressSegmentSeries
Returns whether all bits past the given prefix length are all ones.- Specified by:
includesMaxHost
in interfaceIPAddressSegmentSeries
- Returns:
-
isSingleNetwork
public boolean isSingleNetwork()- Returns:
- whether the network section of the address, the prefix, consists of a single value
-
matchesWithMask
Applies the mask to this address section and then compares values with the given address section- Parameters:
other
-mask
-- Returns:
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeries
Removes the prefix length. If zeroed is false, the bits that were host bits do not become zero, unlikeAddressSegmentSeries.removePrefixLength()
- Specified by:
removePrefixLength
in interfaceAddressSection
- Specified by:
removePrefixLength
in interfaceAddressSegmentSeries
- Specified by:
removePrefixLength
in interfaceIPAddressSegmentSeries
- Parameters:
zeroed
- whether the bits outside the prefix become zero- Returns:
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeries
Removes the prefix length while zeroing out the bits beyond the prefix.If the series already has a prefix length, the bits outside the prefix become zero. Use
AddressSegmentSeries.withoutPrefixLength()
to remove the prefix length without changing the series values.Equivalent to calling removePrefixLength(true)
- Specified by:
removePrefixLength
in interfaceAddressSection
- Specified by:
removePrefixLength
in interfaceAddressSegmentSeries
- Specified by:
removePrefixLength
in interfaceIPAddressSegmentSeries
- Returns:
- See Also:
-
withoutPrefixLength
Description copied from interface:AddressSegmentSeries
Provides the same address with no prefix. The values remain unchanged.Use
AddressSegmentSeries.removePrefixLength()
as an alternative that deletes the host at the same time by zeroing the host values.- Specified by:
withoutPrefixLength
in interfaceAddressSection
- Specified by:
withoutPrefixLength
in interfaceAddressSegmentSeries
- Specified by:
withoutPrefixLength
in interfaceIPAddressSegmentSeries
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length to the next segment boundary.- Specified by:
adjustPrefixBySegment
in interfaceAddressSection
- Specified by:
adjustPrefixBySegment
in interfaceAddressSegmentSeries
- Specified by:
adjustPrefixBySegment
in interfaceIPAddressSegmentSeries
- Parameters:
nextSegment
- whether to move prefix to previous or following segment boundaryzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original values- Returns:
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length to the next segment boundary.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. To avoid the zeroing behaviour, useAddressSegmentSeries.adjustPrefixBySegment(boolean, boolean)
with second arg false.- Specified by:
adjustPrefixBySegment
in interfaceAddressSection
- Specified by:
adjustPrefixBySegment
in interfaceAddressSegmentSeries
- Specified by:
adjustPrefixBySegment
in interfaceIPAddressSegmentSeries
- Parameters:
nextSegment
- whether to move prefix to previous or following segment boundary- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length by the given increment.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. To avoid the zeroing behaviour, use
AddressSegmentSeries.adjustPrefixLength(int, boolean)
with second arg false.- Specified by:
adjustPrefixLength
in interfaceAddressSection
- Specified by:
adjustPrefixLength
in interfaceAddressSegmentSeries
- Specified by:
adjustPrefixLength
in interfaceIPAddressSegmentSeries
- Parameters:
adjustment
-- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeries
Increases or decreases prefix length by the given increment.- Specified by:
adjustPrefixLength
in interfaceAddressSection
- Specified by:
adjustPrefixLength
in interfaceAddressSegmentSeries
- Specified by:
adjustPrefixLength
in interfaceIPAddressSegmentSeries
- Parameters:
adjustment
- the incrementzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original values- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeries
Sets the prefix length.If this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero. For an alternative that does not set bits to zero, use
AddressSegmentSeries.setPrefixLength(int, boolean)
with the second argument as false.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.
- Specified by:
setPrefixLength
in interfaceAddressSection
- Specified by:
setPrefixLength
in interfaceAddressSegmentSeries
- Specified by:
setPrefixLength
in interfaceIPAddressSegmentSeries
- Parameters:
prefixLength
-- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeries
Sets the prefix length.When the prefix is extended beyond the segment series boundary, it is removed.
- Specified by:
setPrefixLength
in interfaceAddressSection
- Specified by:
setPrefixLength
in interfaceAddressSegmentSeries
- Specified by:
setPrefixLength
in interfaceIPAddressSegmentSeries
- Parameters:
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.- Returns:
-
setPrefixLength
public abstract IPAddressSection setPrefixLength(int prefixLength, boolean zeroed, boolean zeroHostIsBlock) Sets the prefix length while allowing the caller to control whether bits moved in or out of the prefix become zero, and whether a zero host for the new prefix bits can be translated into a prefix block. The latter behaviour only applies to the default prefix handling configuration, PREFIXED_ZERO_HOSTS_ARE_SUBNETS. The methodssetPrefixLength(int, boolean)
andsetPrefixLength(int)
use a value of true for zeroed and for zeroHostIsBlock.For example, when zeroHostIsBlock is true, applying to 1.2.0.0 the prefix length 16 results in 1.2.*.*/16
Or if you start with 1.2.0.0/24, setting the prefix length to 16 results in a zero host followed by the existing prefix block, which is then converted to a full prefix block, 1.2.*.*/16
When both zeroed and zeroHostIsBlock are true, applying the prefix length of 16 to 1.2.4.0/24 also results in a zero host followed by the existing prefix block, which is then converted to a full prefix block, 1.2.*.*/16.
When both zeroed and zeroHostIsBlock are false, the resulting address always encompasses the same set of addresses as the original, albeit with a different prefix length.
- Parameters:
prefixLength
-zeroed
-zeroHostIsBlock
-- Returns:
-
getMinPrefixLengthForBlock
public int getMinPrefixLengthForBlock()Returns the smallest CIDR prefix length possible (largest network) for which this includes the block of address sections for that prefix.- Specified by:
getMinPrefixLengthForBlock
in interfaceAddressItem
- Overrides:
getMinPrefixLengthForBlock
in classAddressDivisionGroupingBase
- Returns:
- See Also:
-
getPrefixLengthForSingleBlock
Returns a prefix length for which the range of this address section matches the block of addresses for that prefix.If no such prefix exists, returns null
If this address section represents a single value, returns the bit length
- Specified by:
getPrefixLengthForSingleBlock
in interfaceAddressItem
- Overrides:
getPrefixLengthForSingleBlock
in classIPAddressDivisionGrouping
- Returns:
- the prefix length or null
-
getLowerNonZeroHost
Description copied from interface:IPAddressSegmentSeries
Similar toIPAddressSegmentSeries.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 asIPAddressSegmentSeries.getLower()
.- Specified by:
getLowerNonZeroHost
in interfaceIPAddressSegmentSeries
- Returns:
- the lowest IP address series whose host is non-zero, or null if no such address section exists.
-
getLower
Description copied from interface:AddressSegmentSeries
If this represents a series with ranging values, returns a series representing the lower values of the range. If this represents an series with a single value in each segment, returns this.- Specified by:
getLower
in interfaceAddressComponentRange
- Specified by:
getLower
in interfaceAddressSection
- Specified by:
getLower
in interfaceAddressSegmentSeries
- Specified by:
getLower
in interfaceIPAddressSegmentSeries
- Returns:
-
getUpper
Description copied from interface:AddressSegmentSeries
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.- Specified by:
getUpper
in interfaceAddressComponentRange
- Specified by:
getUpper
in interfaceAddressSection
- Specified by:
getUpper
in interfaceAddressSegmentSeries
- Specified by:
getUpper
in interfaceIPAddressSegmentSeries
- Returns:
-
reverseSegments
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the segments reversed. This does not throwIncompatibleAddressException
since all address series can reverse their segments.- Specified by:
reverseSegments
in interfaceAddressSection
- Specified by:
reverseSegments
in interfaceAddressSegmentSeries
- Specified by:
reverseSegments
in interfaceIPAddressSegmentSeries
- Returns:
-
reverseBits
Description copied from interface:IPAddressSegmentSeries
Returns a new series which has the bits reversed.If 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 callIPAddressSegmentSeries.iterator()
,IPAddressSegmentSeries.getLower()
,IPAddressSegmentSeries.getUpper()
or some other method to transform the address into an address representing a single value before reversing.- Specified by:
reverseBits
in interfaceAddressComponent
- Specified by:
reverseBits
in interfaceAddressSection
- Specified by:
reverseBits
in interfaceAddressSegmentSeries
- Specified by:
reverseBits
in interfaceIPAddressSegmentSeries
- Parameters:
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the address are reversed- Returns:
-
reverseBytes
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bytes reversed.- Specified by:
reverseBytes
in interfaceAddressComponent
- Specified by:
reverseBytes
in interfaceAddressSection
- Specified by:
reverseBytes
in interfaceAddressSegmentSeries
- Specified by:
reverseBytes
in interfaceIPAddressSegmentSeries
- Returns:
-
reverseBytesPerSegment
Description copied from interface:AddressSegmentSeries
Returns a new segment series with the bytes reversed within each segment.- Specified by:
reverseBytesPerSegment
in interfaceAddressSection
- Specified by:
reverseBytesPerSegment
in interfaceAddressSegmentSeries
- Specified by:
reverseBytesPerSegment
in interfaceIPAddressSegmentSeries
- Returns:
-
getSection
Description copied from interface:AddressSegmentSeries
Gets the subsection from the series starting from the given index The first segment is at index 0.- Specified by:
getSection
in interfaceAddressSegmentSeries
- Specified by:
getSection
in interfaceIPAddressSegmentSeries
- Parameters:
index
-- Returns:
-
getSection
Description copied from interface:AddressSegmentSeries
Gets the subsection from the series starting from the given index and ending just before the give endIndex The first segment is at index 0.- Specified by:
getSection
in interfaceAddressSegmentSeries
- Specified by:
getSection
in interfaceIPAddressSegmentSeries
- Parameters:
index
-endIndex
-- Returns:
-
getSegments
Description copied from interface:AddressSegmentSeries
Copies the existing segments into the given array. The array size should be at least as large asAddressSegmentSeries.getSegmentCount()
- Specified by:
getSegments
in interfaceAddressSegmentSeries
-
getSegments
Description copied from interface:AddressSegmentSeries
get the segments from start to end and insert into the segs array at the given index- Specified by:
getSegments
in interfaceAddressSegmentSeries
- Parameters:
start
- the first segment index from this series to be includedend
- the first segment index to be excludedsegs
- the target arraydestIndex
- where to insert the segments in the segs array
-
getIterable
Description copied from interface:AddressComponentRange
Useful for using an instance in a "for-each loop". Otherwise just callAddressComponentRange.iterator()
directly.- Specified by:
getIterable
in interfaceAddressComponentRange
- Specified by:
getIterable
in interfaceAddressSection
- Specified by:
getIterable
in interfaceAddressSegmentSeries
- Specified by:
getIterable
in interfaceIPAddressSegmentSeries
- Returns:
-
nonZeroHostIterator
Description copied from interface:IPAddressSegmentSeries
Similar to the iterator, but series with a host of zero are skipped.- Specified by:
nonZeroHostIterator
in interfaceIPAddressSegmentSeries
- Returns:
-
iterator
Description copied from interface:AddressComponentRange
Iterates through the individual address components.An address component can represent an individual segment, address, or section, or it can represent multiple, typically a subnet of addresses or a range of segment or section values.
Call
AddressItem.isMultiple()
to determine if this instance represents multiple, orAddressItem.getCount()
for the count.- Specified by:
iterator
in interfaceAddressComponentRange
- Specified by:
iterator
in interfaceAddressSection
- Specified by:
iterator
in interfaceAddressSegmentSeries
- Specified by:
iterator
in interfaceIPAddressSegmentSeries
- Returns:
-
spliterator
Description copied from interface:AddressComponentRange
Partitions and traverses through the individual address components.- Specified by:
spliterator
in interfaceAddressComponent
- Specified by:
spliterator
in interfaceAddressComponentRange
- Specified by:
spliterator
in interfaceAddressSection
- Specified by:
spliterator
in interfaceAddressSegmentSeries
- Specified by:
spliterator
in interfaceIPAddressSegmentSeries
- Returns:
-
stream
Description copied from interface:AddressComponentRange
Returns a sequential stream of the individual address components. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
stream
in interfaceAddressComponentRange
- Specified by:
stream
in interfaceAddressSection
- Specified by:
stream
in interfaceAddressSegmentSeries
- Specified by:
stream
in interfaceIPAddressSegmentSeries
- Returns:
-
prefixIterator
Description copied from interface:AddressSegmentSeries
Iterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()
- Specified by:
prefixIterator
in interfaceAddressSection
- Specified by:
prefixIterator
in interfaceAddressSegmentSeries
- Specified by:
prefixIterator
in interfaceIPAddressSegmentSeries
-
prefixSpliterator
Description copied from interface:AddressSegmentSeries
Partitions and traverses through the individual prefixes for the prefix length of this series.- Specified by:
prefixSpliterator
in interfaceAddressSection
- Specified by:
prefixSpliterator
in interfaceAddressSegmentSeries
- Specified by:
prefixSpliterator
in interfaceIPAddressSegmentSeries
- Returns:
-
prefixStream
Description copied from interface:AddressSegmentSeries
Returns a sequential stream of the individual prefixes for the prefix length of this series. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
prefixStream
in interfaceAddressSection
- Specified by:
prefixStream
in interfaceAddressSegmentSeries
- Specified by:
prefixStream
in interfaceIPAddressSegmentSeries
- Returns:
-
prefixBlockIterator
Description copied from interface:AddressSegmentSeries
Iterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()
- Specified by:
prefixBlockIterator
in interfaceAddressSection
- Specified by:
prefixBlockIterator
in interfaceAddressSegmentSeries
- Specified by:
prefixBlockIterator
in interfaceIPAddressSegmentSeries
-
prefixBlockSpliterator
Description copied from interface:AddressSegmentSeries
Partitions and traverses through the individual prefix blocks for the prefix length of this series.- Specified by:
prefixBlockSpliterator
in interfaceAddressSection
- Specified by:
prefixBlockSpliterator
in interfaceAddressSegmentSeries
- Specified by:
prefixBlockSpliterator
in interfaceIPAddressSegmentSeries
- Returns:
-
prefixBlockStream
Description copied from interface:AddressSegmentSeries
Returns a sequential stream of the individual prefix blocks for the prefix length of this series. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
prefixBlockStream
in interfaceAddressSection
- Specified by:
prefixBlockStream
in interfaceAddressSegmentSeries
- Specified by:
prefixBlockStream
in interfaceIPAddressSegmentSeries
- Returns:
-
blockIterator
Description copied from interface:IPAddressSegmentSeries
Iterates through series that can be obtained by iterating through all the upper segments up to the given segment count. Segments following remain the same in all iterated series.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
- Specified by:
blockIterator
in interfaceIPAddressSegmentSeries
- Parameters:
segmentCount
-- Returns:
-
blockSpliterator
public abstract AddressComponentSpliterator<? extends IPAddressSection> blockSpliterator(int segmentCount) Description copied from interface:IPAddressSegmentSeries
Partitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.- Specified by:
blockSpliterator
in interfaceIPAddressSegmentSeries
- Returns:
-
blockStream
Description copied from interface:IPAddressSegmentSeries
Returns a sequential stream of the individual blocks created from each of the individual values up to the given segment count. For a parallel stream, callBaseStream.parallel()
on the returned stream.- Specified by:
blockStream
in interfaceIPAddressSegmentSeries
- Returns:
-
sequentialBlockIterator
Description copied from interface:IPAddressSegmentSeries
Iterates through the sequential series that make up this series. Generally this means finding the count of segments for which the segments that follow are not full range, and then usingIPAddressSegmentSeries.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.
Use
IPAddressSegmentSeries.getSequentialBlockCount()
to get the count of iterated elements.- Specified by:
sequentialBlockIterator
in interfaceIPAddressSegmentSeries
- Returns:
-
sequentialBlockSpliterator
Description copied from interface:IPAddressSegmentSeries
Partitions and traverses through the individual sequential blocks.- Specified by:
sequentialBlockSpliterator
in interfaceIPAddressSegmentSeries
- Returns:
-
sequentialBlockStream
Description copied from interface:IPAddressSegmentSeries
Returns a sequential stream of the individual sequential blocks. For a parallel stream, callBaseStream.parallel()
on the returned stream.Use
IPAddressSegmentSeries.getSequentialBlockCount()
to get the count of streamed elements.- Specified by:
sequentialBlockStream
in interfaceIPAddressSegmentSeries
- Returns:
-
getSequentialBlockCount
Description copied from interface:IPAddressSegmentSeries
provides the count of elements from theIPAddressSegmentSeries.sequentialBlockIterator()
, the minimal number of sequential sub-series that comprise this series- Specified by:
getSequentialBlockCount
in interfaceIPAddressSegmentSeries
- Returns:
-
increment
Description copied from interface:AddressSegmentSeries
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.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.
- Specified by:
increment
in interfaceAddressSection
- Specified by:
increment
in interfaceAddressSegmentSeries
- Specified by:
increment
in interfaceIPAddressSegmentSeries
- Parameters:
increment
-- Returns:
-
incrementBoundary
Description copied from interface:AddressSegmentSeries
If the given increment is positive, adds the value to the upper series (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.
- Specified by:
incrementBoundary
in interfaceAddressSection
- Specified by:
incrementBoundary
in interfaceAddressSegmentSeries
- Specified by:
incrementBoundary
in interfaceIPAddressSegmentSeries
- Parameters:
increment
-- Returns:
-
isEntireAddress
public boolean isEntireAddress() -
isZeroHost
public boolean isZeroHost()Returns whether this section has a prefix length and if so, whether the host section is zero for this section or all sections in this set of address sections. If the host section is zero length (there are no host bits at all), returns false.- Returns:
-
isZeroHost
public boolean isZeroHost(int prefixLength) Returns whether the host is zero for the given prefix length for this section or all sections in this set of address sections. If this section already has a prefix length, then that prefix length is ignored. If the host section is zero length (there are no host bits at all), returns false.- Returns:
-
toString
- Overrides:
toString
in classAddressDivisionGroupingBase
-
getSegmentStrings
Description copied from interface:AddressSegmentSeries
Returns the an array with the values of each segment as they would appear in the normalized with wildcards string.- Specified by:
getSegmentStrings
in interfaceAddressSegmentSeries
- Returns:
-
toBinaryString
Description copied from interface:IPAddressSegmentSeries
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 binary values.- Specified by:
toBinaryString
in interfaceIPAddressSegmentSeries
- Throws:
IncompatibleAddressException
-
toOctalString
Description copied from interface:IPAddressSegmentSeries
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. 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.- Specified by:
toOctalString
in interfaceIPAddressSegmentSeries
- Throws:
IncompatibleAddressException
-
toHexString
Description copied from interface:AddressComponent
Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.If 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.
- Specified by:
toHexString
in interfaceAddressComponent
- Throws:
IncompatibleAddressException
-
toNormalizedString
Description copied from interface:IPAddressSegmentSeries
Creates a customized string from this series.- Specified by:
toNormalizedString
in interfaceIPAddressSegmentSeries
- Parameters:
stringOptions
-- Returns:
-
toNormalizedString
public static String toNormalizedString(IPAddressSection.IPStringOptions opts, IPAddressStringDivisionSeries section) -
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- Returns:
-
toAllStringCollection
Use this method with care... a single IPv6 address can have thousands of string representations. Examples: "::" has 1297 such variations, but only 9 are considered standard "a:b:c:0:d:e:f:1" has 1920 variations, but only 12 are standard Variations included in this method: -all standard variations -choosing specific segments for full leading zeros (::a:b can be ::000a:b, ::a:000b, or ::000a:000b) -choosing which zero-segments to compress (0:0:a:: can be ::a:0:0:0:0:0 or 0:0:a::) -mixed representation (1:2:3:4:5:6:1.2.3.4) -all combinations of such variations Variations omitted from this method: -mixed case of a-f, which you can easily handle yourself with String.equalsIgnoreCase -adding a variable number of leading zeros (::a can be ::0a, ::00a, ::000a) -choosing any number of zero-segments anywhere to compress (:: can be 0:0:0::0:0)- Returns:
-
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- Returns:
-
getParts
Get all representations of this address including this IPAddressSection. This includes:- alternative segment groupings expressed as
IPAddressDivisionGrouping
- conversions to IPv6, and alternative representations of those IPv6 addresses
- Parameters:
options
-- Returns:
- alternative segment groupings expressed as
-
getStartsWithSQLClause
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. This is not as simple as it sounds, because the same address can be written in different ways (especially for IPv6) and in addition, addresses in the same network can have different beginnings (eg 1.0.0.0/7 are all addresses from 0.0.0.0 to 1.255.255.255), so you can see they start with both 1 and 0. You can reduce the number of possible beginnings by choosing a segment boundary for the network prefix. The SQL produced works for MySQL. For a different database type, usegetStartsWithSQLClause(StringBuilder, String, IPAddressSQLTranslator)
- Parameters:
builder
-expression
- the expression that must match the condition, whether a column name or other
-
getStartsWithSQLClause
public void getStartsWithSQLClause(StringBuilder builder, String expression, IPAddressSQLTranslator translator)
-