Class IPAddressSection
- 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 classThis user-facing class is designed to be a clear way to create a collection of strings.static classRepresents a clear way to create a specific type of string.static interfacestatic interfacestatic interfacestatic classNested classes/interfaces inherited from class IPAddressDivisionGrouping
IPAddressDivisionGrouping.Range, IPAddressDivisionGrouping.RangeListNested classes/interfaces inherited from class AddressDivisionGrouping
AddressDivisionGrouping.DivisionLengthProvider, AddressDivisionGrouping.DivisionValueProvider, AddressDivisionGrouping.StringOptions -
Method Summary
Modifier and TypeMethodDescriptionabstract IPAddressSectionadjustPrefixBySegment(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 IPAddressSectionadjustPrefixLength(int adjustment) Increases or decreases prefix length by the given increment.abstract IPAddressSectionadjustPrefixLength(int adjustment, boolean zeroed) Increases or decreases prefix length by the given increment.abstract IPAddressSectionapplyPrefixLength(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 intbitsPerSegment(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 intbytesPerSegment(IPAddress.IPVersion version) booleancontains(AddressSection other) Determines if one section contains another.booleanReturns whether this address contains the non-zero host addresses in other.booleancontainsPrefixBlock(int prefixLength) Returns whether the values of this division grouping contain the prefix block for the given prefix lengthabstract IPAddressSectionReturns the minimal-size prefix block that covers all the values in this series.intProvides 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.intProvides 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 IPAddressSectiongetLower()If this represents a series with ranging values, returns a series representing the lower values of the range.abstract IPAddressSectionSimilar toIPAddressSegmentSeries.getLower(), but will not return a series that has a prefix length and whose host value is zero.intReturns the maximum possible segment value for this type of address.intReturns 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 IPAddressSectiongetSection(int index) Gets the subsection from the series starting from the given index The first segment is at index 0.abstract IPAddressSectiongetSection(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.intReturns the number of segments in this series.voidgetSegments(int start, int end, AddressSegment[] segs, int destIndex) get the segments from start to end and insert into the segs array at the given indexvoidgetSegments(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 seriesvoidgetStartsWithSQLClause(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.voidgetStartsWithSQLClause(StringBuilder builder, String expression, IPAddressSQLTranslator translator) abstract IPAddressSectiongetUpper()If this represents a series with ranging values, returns a series representing the upper values of the range.booleanReturns whether the series has a host of all ones.booleanincludesMaxHost(int networkPrefixLength) Returns whether all bits past the given prefix length are all ones.booleanReturns whether the series has a host of zero.booleanincludesZeroHost(int networkPrefixLength) Returns whether all bits past the given prefix length are zero.abstract IPAddressSectionincrement(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 IPAddressSectionincrementBoundary(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.booleanbooleanwhether this address item represents all possible values attainable by an address item of this typebooleanisIPv4()booleanisIPv6()booleanbooleanReturns whether the division grouping range matches the block of values for its prefix length.booleanReturns 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.booleanisZeroHost(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.booleanmatchesWithMask(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 booleanprefixContains(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 IPAddressSectionDeprecated.abstract IPAddressSectionremovePrefixLength(boolean zeroed) Deprecated.abstract IPAddressSectionreverseBits(boolean perByte) Returns a new series which has the bits reversed.abstract IPAddressSectionReturns a new segment series with the bytes reversed.abstract IPAddressSectionReturns a new segment series with the bytes reversed within each segment.abstract IPAddressSectionReturns 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 IPAddressSectionsetPrefixLength(int prefixLength) Sets the prefix length.abstract IPAddressSectionsetPrefixLength(int prefixLength, boolean zeroed) Sets the prefix length.abstract IPAddressSectionsetPrefixLength(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 IPAddressSectionReturns the segment series with a host of all ones.abstract IPAddressSectiontoMaxHost(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 StringtoOctalString(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 IPAddressSectionIf this series has a prefix length, returns the subnet block for that prefix.abstract IPAddressSectiontoPrefixBlock(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 IPAddressSectionReturns the segment series with a host of zero, the host being the bits following the prefix length.abstract IPAddressSectiontoZeroHost(int prefixLength) Produces the series with host values of 0 for the given prefix length.abstract IPAddressSectionReturns the segment series with a network of zero, the network being the bits within the prefix length.abstract IPAddressSectionProvides the same address with no prefix.Methods inherited from class IPAddressDivisionGrouping
containsSinglePrefixBlock, equals, getLeadingBitCount, getNetwork, getNetworkPrefixLength, getPrefixLength, getTrailingBitCount, getZeroRangeSegments, getZeroSegments, isMore, isPrefixBlockMethods inherited from class AddressDivisionGrouping
hashCodeMethods inherited from class AddressDivisionGroupingBase
getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getPrefixCount, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isPrefixed, isSequential, isZeroMethods inherited from interface AddressComponent
getNetwork, toNormalizedStringMethods inherited from interface AddressDivisionSeries
getCount, getDivisionStrings, getPrefixCount, getPrefixCount, getPrefixLength, getSequentialBlockIndex, isMore, isPrefixBlock, isPrefixed, isSequentialMethods inherited from interface AddressItem
compareTo, containsSinglePrefixBlock, getBytes, getBytes, getBytes, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isMax, isMultiple, isZeroMethods inherited from interface AddressSection
enumerate, overlaps, prefixEqualsMethods inherited from interface AddressSegmentSeries
getBitsPerSegment, getBytesPerSegment, isOneBit, testBit, toCanonicalString, toCompressedStringMethods inherited from interface AddressStringDivisionSeries
getDivisionCountMethods inherited from interface IPAddressDivisionSeries
getNetworkPrefixLengthMethods inherited from interface 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, toSubnetStringMethods inherited from interface IPAddressStringDivisionSeries
getPrefixLength, isPrefixBlock, isPrefixed
-
Method Details
-
isSinglePrefixBlock
public boolean isSinglePrefixBlock()Description copied from class:IPAddressDivisionGroupingReturns 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:
isSinglePrefixBlockin interfaceAddressDivisionSeries- Overrides:
isSinglePrefixBlockin classIPAddressDivisionGrouping- Returns:
-
getBitCount
public int getBitCount()Description copied from interface:AddressItemProvides the number of bits comprising this address item- Specified by:
getBitCountin interfaceAddressDivisionSeries- Specified by:
getBitCountin interfaceAddressItem- Returns:
- the number of bits
-
getByteCount
public int getByteCount()Description copied from interface:AddressItemProvides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8- Specified by:
getByteCountin interfaceAddressItem- Returns:
- the number of bytes
-
bitsPerSegment
-
bytesPerSegment
-
getNonZeroHostCount
Description copied from interface:IPAddressSegmentSeriesGets 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:
getNonZeroHostCountin interfaceIPAddressSegmentSeries- Returns:
-
getCountImpl
-
getBlockCount
Description copied from interface:AddressDivisionSeriesReturns the count of values in the initial (higher) count of divisions.- Specified by:
getBlockCountin interfaceAddressDivisionSeries- Returns:
-
isIPv4
public boolean isIPv4() -
isIPv6
public boolean isIPv6() -
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegmentSeriesReturns 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:
getMaxSegmentValuein 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:AddressSegmentSeriesReturns the number of segments in this series.- Specified by:
getSegmentCountin interfaceAddressSegmentSeries- Returns:
-
getSegment
Description copied from interface:AddressSegmentSeriesReturns 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:
getSegmentin interfaceAddressSegmentSeries- Specified by:
getSegmentin interfaceIPAddressSegmentSeries- Returns:
-
getDivision
- Specified by:
getDivisionin interfaceAddressDivisionSeries- Specified by:
getDivisionin interfaceAddressStringDivisionSeries- Specified by:
getDivisionin interfaceIPAddressDivisionSeries- Specified by:
getDivisionin interfaceIPAddressStringDivisionSeries- Overrides:
getDivisionin classIPAddressDivisionGrouping- Returns:
- the given division in this series. The first is at index 0.
-
containsPrefixBlock
public boolean containsPrefixBlock(int prefixLength) Description copied from class:AddressDivisionGroupingReturns whether the values of this division grouping contain the prefix block for the given prefix length- Specified by:
containsPrefixBlockin interfaceAddressItem- Overrides:
containsPrefixBlockin classIPAddressDivisionGrouping- Parameters:
prefixLength-- Returns:
-
contains
Description copied from interface:AddressSectionDetermines 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:
containsin 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:AddressItemwhether this address item represents all possible values attainable by an address item of this type- Specified by:
isFullRangein interfaceAddressItem- Overrides:
isFullRangein 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:IPAddressSegmentSeriesReturns 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:
toZeroHostin interfaceIPAddressSegmentSeries- Returns:
- See Also:
-
toZeroHost
Description copied from interface:IPAddressSegmentSeriesProduces 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:
toZeroHostin interfaceIPAddressSegmentSeries- Parameters:
prefixLength-- Returns:
-
toZeroNetwork
Description copied from interface:IPAddressSegmentSeriesReturns 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:
toZeroNetworkin interfaceIPAddressSegmentSeries- Returns:
- See Also:
-
toMaxHost
Description copied from interface:IPAddressSegmentSeriesReturns 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:
toMaxHostin interfaceIPAddressSegmentSeries- Returns:
-
toMaxHost
Description copied from interface:IPAddressSegmentSeriesProduces 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:
toMaxHostin interfaceIPAddressSegmentSeries- Parameters:
prefixLength-- Returns:
-
applyPrefixLength
@Deprecated public abstract IPAddressSection applyPrefixLength(int networkPrefixLength) throws PrefixLenException Deprecated.Description copied from interface:AddressSegmentSeriesApplies 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:
applyPrefixLengthin interfaceAddressSection- Specified by:
applyPrefixLengthin interfaceAddressSegmentSeries- Specified by:
applyPrefixLengthin interfaceIPAddressSegmentSeries- Parameters:
networkPrefixLength-- Returns:
- Throws:
PrefixLenException- See Also:
-
coverWithPrefixBlock
Description copied from interface:IPAddressSegmentSeriesReturns 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:
coverWithPrefixBlockin interfaceIPAddressSegmentSeries
-
toPrefixBlock
Description copied from interface:IPAddressSegmentSeriesIf 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:
toPrefixBlockin interfaceAddressSection- Specified by:
toPrefixBlockin interfaceAddressSegmentSeries- Specified by:
toPrefixBlockin interfaceIPAddressSegmentSeries- Returns:
- the subnet block for the prefix length
-
toPrefixBlock
Description copied from interface:IPAddressSegmentSeriesReturns 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:
toPrefixBlockin interfaceIPAddressSegmentSeries- Parameters:
networkPrefixLength-- Returns:
-
getHostMask
Description copied from interface:IPAddressSegmentSeriesReturns 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:
getHostMaskin interfaceIPAddressSegmentSeries- Returns:
-
getNetworkMask
Description copied from interface:IPAddressSegmentSeriesReturns 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:
getNetworkMaskin 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:
assignPrefixForSingleBlockin 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:
assignMinPrefixForBlockin interfaceIPAddressSegmentSeries- Returns:
- See Also:
-
includesZeroHost
public boolean includesZeroHost()Description copied from interface:IPAddressSegmentSeriesReturns 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:
includesZeroHostin interfaceIPAddressSegmentSeries- Overrides:
includesZeroHostin classIPAddressDivisionGrouping- Returns:
-
includesZeroHost
public boolean includesZeroHost(int networkPrefixLength) Description copied from interface:IPAddressSegmentSeriesReturns whether all bits past the given prefix length are zero.- Specified by:
includesZeroHostin interfaceIPAddressSegmentSeries- Returns:
-
includesMaxHost
public boolean includesMaxHost()Description copied from interface:IPAddressSegmentSeriesReturns 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:
includesMaxHostin interfaceIPAddressSegmentSeries- Returns:
-
includesMaxHost
public boolean includesMaxHost(int networkPrefixLength) Description copied from interface:IPAddressSegmentSeriesReturns whether all bits past the given prefix length are all ones.- Specified by:
includesMaxHostin 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:AddressSegmentSeriesRemoves the prefix length. If zeroed is false, the bits that were host bits do not become zero, unlikeAddressSegmentSeries.removePrefixLength()- Specified by:
removePrefixLengthin interfaceAddressSection- Specified by:
removePrefixLengthin interfaceAddressSegmentSeries- Specified by:
removePrefixLengthin interfaceIPAddressSegmentSeries- Parameters:
zeroed- whether the bits outside the prefix become zero- Returns:
-
removePrefixLength
Deprecated.Description copied from interface:AddressSegmentSeriesRemoves 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:
removePrefixLengthin interfaceAddressSection- Specified by:
removePrefixLengthin interfaceAddressSegmentSeries- Specified by:
removePrefixLengthin interfaceIPAddressSegmentSeries- Returns:
- See Also:
-
withoutPrefixLength
Description copied from interface:AddressSegmentSeriesProvides 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:
withoutPrefixLengthin interfaceAddressSection- Specified by:
withoutPrefixLengthin interfaceAddressSegmentSeries- Specified by:
withoutPrefixLengthin interfaceIPAddressSegmentSeries
-
adjustPrefixBySegment
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length to the next segment boundary.- Specified by:
adjustPrefixBySegmentin interfaceAddressSection- Specified by:
adjustPrefixBySegmentin interfaceAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin 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:AddressSegmentSeriesIncreases 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:
adjustPrefixBySegmentin interfaceAddressSection- Specified by:
adjustPrefixBySegmentin interfaceAddressSegmentSeries- Specified by:
adjustPrefixBySegmentin interfaceIPAddressSegmentSeries- Parameters:
nextSegment- whether to move prefix to previous or following segment boundary- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeriesIncreases 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:
adjustPrefixLengthin interfaceAddressSection- Specified by:
adjustPrefixLengthin interfaceAddressSegmentSeries- Specified by:
adjustPrefixLengthin interfaceIPAddressSegmentSeries- Parameters:
adjustment-- Returns:
-
adjustPrefixLength
Description copied from interface:AddressSegmentSeriesIncreases or decreases prefix length by the given increment.- Specified by:
adjustPrefixLengthin interfaceAddressSection- Specified by:
adjustPrefixLengthin interfaceAddressSegmentSeries- Specified by:
adjustPrefixLengthin 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:AddressSegmentSeriesSets 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:
setPrefixLengthin interfaceAddressSection- Specified by:
setPrefixLengthin interfaceAddressSegmentSeries- Specified by:
setPrefixLengthin interfaceIPAddressSegmentSeries- Parameters:
prefixLength-- Returns:
-
setPrefixLength
Description copied from interface:AddressSegmentSeriesSets the prefix length.When the prefix is extended beyond the segment series boundary, it is removed.
- Specified by:
setPrefixLengthin interfaceAddressSection- Specified by:
setPrefixLengthin interfaceAddressSegmentSeries- Specified by:
setPrefixLengthin 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:
getMinPrefixLengthForBlockin interfaceAddressItem- Overrides:
getMinPrefixLengthForBlockin 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:
getPrefixLengthForSingleBlockin interfaceAddressItem- Overrides:
getPrefixLengthForSingleBlockin classIPAddressDivisionGrouping- Returns:
- the prefix length or null
-
getLowerNonZeroHost
Description copied from interface:IPAddressSegmentSeriesSimilar 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:
getLowerNonZeroHostin 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:AddressSegmentSeriesIf 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:
getLowerin interfaceAddressComponentRange- Specified by:
getLowerin interfaceAddressSection- Specified by:
getLowerin interfaceAddressSegmentSeries- Specified by:
getLowerin interfaceIPAddressSegmentSeries- Returns:
-
getUpper
Description copied from interface:AddressSegmentSeriesIf 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:
getUpperin interfaceAddressComponentRange- Specified by:
getUpperin interfaceAddressSection- Specified by:
getUpperin interfaceAddressSegmentSeries- Specified by:
getUpperin interfaceIPAddressSegmentSeries- Returns:
-
reverseSegments
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the segments reversed. This does not throwIncompatibleAddressExceptionsince all address series can reverse their segments.- Specified by:
reverseSegmentsin interfaceAddressSection- Specified by:
reverseSegmentsin interfaceAddressSegmentSeries- Specified by:
reverseSegmentsin interfaceIPAddressSegmentSeries- Returns:
-
reverseBits
Description copied from interface:IPAddressSegmentSeriesReturns 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:
reverseBitsin interfaceAddressComponent- Specified by:
reverseBitsin interfaceAddressSection- Specified by:
reverseBitsin interfaceAddressSegmentSeries- Specified by:
reverseBitsin 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:AddressSegmentSeriesReturns a new segment series with the bytes reversed.- Specified by:
reverseBytesin interfaceAddressComponent- Specified by:
reverseBytesin interfaceAddressSection- Specified by:
reverseBytesin interfaceAddressSegmentSeries- Specified by:
reverseBytesin interfaceIPAddressSegmentSeries- Returns:
-
reverseBytesPerSegment
Description copied from interface:AddressSegmentSeriesReturns a new segment series with the bytes reversed within each segment.- Specified by:
reverseBytesPerSegmentin interfaceAddressSection- Specified by:
reverseBytesPerSegmentin interfaceAddressSegmentSeries- Specified by:
reverseBytesPerSegmentin interfaceIPAddressSegmentSeries- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets the subsection from the series starting from the given index The first segment is at index 0.- Specified by:
getSectionin interfaceAddressSegmentSeries- Specified by:
getSectionin interfaceIPAddressSegmentSeries- Parameters:
index-- Returns:
-
getSection
Description copied from interface:AddressSegmentSeriesGets 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:
getSectionin interfaceAddressSegmentSeries- Specified by:
getSectionin interfaceIPAddressSegmentSeries- Parameters:
index-endIndex-- Returns:
-
getSegments
Description copied from interface:AddressSegmentSeriesCopies the existing segments into the given array. The array size should be at least as large asAddressSegmentSeries.getSegmentCount()- Specified by:
getSegmentsin interfaceAddressSegmentSeries
-
getSegments
Description copied from interface:AddressSegmentSeriesget the segments from start to end and insert into the segs array at the given index- Specified by:
getSegmentsin 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:AddressComponentRangeUseful for using an instance in a "for-each loop". Otherwise just callAddressComponentRange.iterator()directly.- Specified by:
getIterablein interfaceAddressComponentRange- Specified by:
getIterablein interfaceAddressSection- Specified by:
getIterablein interfaceAddressSegmentSeries- Specified by:
getIterablein interfaceIPAddressSegmentSeries- Returns:
-
nonZeroHostIterator
Description copied from interface:IPAddressSegmentSeriesSimilar to the iterator, but series with a host of zero are skipped.- Specified by:
nonZeroHostIteratorin interfaceIPAddressSegmentSeries- Returns:
-
iterator
Description copied from interface:AddressComponentRangeIterates 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:
iteratorin interfaceAddressComponentRange- Specified by:
iteratorin interfaceAddressSection- Specified by:
iteratorin interfaceAddressSegmentSeries- Specified by:
iteratorin interfaceIPAddressSegmentSeries- Returns:
-
spliterator
Description copied from interface:AddressComponentRangePartitions and traverses through the individual address components.- Specified by:
spliteratorin interfaceAddressComponent- Specified by:
spliteratorin interfaceAddressComponentRange- Specified by:
spliteratorin interfaceAddressSection- Specified by:
spliteratorin interfaceAddressSegmentSeries- Specified by:
spliteratorin interfaceIPAddressSegmentSeries- Returns:
-
stream
Description copied from interface:AddressComponentRangeReturns a sequential stream of the individual address components. For a parallel stream, callBaseStream.parallel()on the returned stream.- Specified by:
streamin interfaceAddressComponentRange- Specified by:
streamin interfaceAddressSection- Specified by:
streamin interfaceAddressSegmentSeries- Specified by:
streamin interfaceIPAddressSegmentSeries- Returns:
-
prefixIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual prefixes.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()- Specified by:
prefixIteratorin interfaceAddressSection- Specified by:
prefixIteratorin interfaceAddressSegmentSeries- Specified by:
prefixIteratorin interfaceIPAddressSegmentSeries
-
prefixSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual prefixes for the prefix length of this series.- Specified by:
prefixSpliteratorin interfaceAddressSection- Specified by:
prefixSpliteratorin interfaceAddressSegmentSeries- Specified by:
prefixSpliteratorin interfaceIPAddressSegmentSeries- Returns:
-
prefixStream
Description copied from interface:AddressSegmentSeriesReturns 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:
prefixStreamin interfaceAddressSection- Specified by:
prefixStreamin interfaceAddressSegmentSeries- Specified by:
prefixStreamin interfaceIPAddressSegmentSeries- Returns:
-
prefixBlockIterator
Description copied from interface:AddressSegmentSeriesIterates through the individual prefix blocks.If the series has no prefix length, then this is equivalent to
AddressSegmentSeries.iterator()- Specified by:
prefixBlockIteratorin interfaceAddressSection- Specified by:
prefixBlockIteratorin interfaceAddressSegmentSeries- Specified by:
prefixBlockIteratorin interfaceIPAddressSegmentSeries
-
prefixBlockSpliterator
Description copied from interface:AddressSegmentSeriesPartitions and traverses through the individual prefix blocks for the prefix length of this series.- Specified by:
prefixBlockSpliteratorin interfaceAddressSection- Specified by:
prefixBlockSpliteratorin interfaceAddressSegmentSeries- Specified by:
prefixBlockSpliteratorin interfaceIPAddressSegmentSeries- Returns:
-
prefixBlockStream
Description copied from interface:AddressSegmentSeriesReturns 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:
prefixBlockStreamin interfaceAddressSection- Specified by:
prefixBlockStreamin interfaceAddressSegmentSeries- Specified by:
prefixBlockStreamin interfaceIPAddressSegmentSeries- Returns:
-
blockIterator
Description copied from interface:IPAddressSegmentSeriesIterates 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:
blockIteratorin interfaceIPAddressSegmentSeries- Parameters:
segmentCount-- Returns:
-
blockSpliterator
public abstract AddressComponentSpliterator<? extends IPAddressSection> blockSpliterator(int segmentCount) Description copied from interface:IPAddressSegmentSeriesPartitions and traverses through the individual sequential blocks created from each of the individual values up to the given segment count.- Specified by:
blockSpliteratorin interfaceIPAddressSegmentSeries- Returns:
-
blockStream
Description copied from interface:IPAddressSegmentSeriesReturns 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:
blockStreamin interfaceIPAddressSegmentSeries- Returns:
-
sequentialBlockIterator
Description copied from interface:IPAddressSegmentSeriesIterates 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:
sequentialBlockIteratorin interfaceIPAddressSegmentSeries- Returns:
-
sequentialBlockSpliterator
Description copied from interface:IPAddressSegmentSeriesPartitions and traverses through the individual sequential blocks.- Specified by:
sequentialBlockSpliteratorin interfaceIPAddressSegmentSeries- Returns:
-
sequentialBlockStream
Description copied from interface:IPAddressSegmentSeriesReturns 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:
sequentialBlockStreamin interfaceIPAddressSegmentSeries- Returns:
-
getSequentialBlockCount
Description copied from interface:IPAddressSegmentSeriesprovides the count of elements from theIPAddressSegmentSeries.sequentialBlockIterator(), the minimal number of sequential sub-series that comprise this series- Specified by:
getSequentialBlockCountin interfaceIPAddressSegmentSeries- Returns:
-
increment
Description copied from interface:AddressSegmentSeriesReturns 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:
incrementin interfaceAddressSection- Specified by:
incrementin interfaceAddressSegmentSeries- Specified by:
incrementin interfaceIPAddressSegmentSeries- Parameters:
increment-- Returns:
-
incrementBoundary
Description copied from interface:AddressSegmentSeriesIf 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:
incrementBoundaryin interfaceAddressSection- Specified by:
incrementBoundaryin interfaceAddressSegmentSeries- Specified by:
incrementBoundaryin 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:
toStringin classAddressDivisionGroupingBase
-
getSegmentStrings
Description copied from interface:AddressSegmentSeriesReturns the an array with the values of each segment as they would appear in the normalized with wildcards string.- Specified by:
getSegmentStringsin interfaceAddressSegmentSeries- Returns:
-
toBinaryString
Description copied from interface:IPAddressSegmentSeriesWrites 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:
toBinaryStringin interfaceIPAddressSegmentSeries- Throws:
IncompatibleAddressException
-
toOctalString
Description copied from interface:IPAddressSegmentSeriesWrites 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:
toOctalStringin interfaceIPAddressSegmentSeries- Throws:
IncompatibleAddressException
-
toHexString
Description copied from interface:AddressComponentWrites 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:
toHexStringin interfaceAddressComponent- Throws:
IncompatibleAddressException
-
toNormalizedString
Description copied from interface:IPAddressSegmentSeriesCreates a customized string from this series.- Specified by:
toNormalizedStringin 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)
-