- All Implemented Interfaces:
AddressComponent
,AddressSegment
,AddressComponentRange
,AddressGenericDivision
,AddressItem
,AddressItemRange
,AddressStringDivision
,Serializable
,Comparable<AddressItem>
,Iterable<MACAddressSegment>
- Author:
- sfoley
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class inet.ipaddr.format.standard.AddressDivision
AddressDivision.BitwiseOrResult, AddressDivision.MaskResult
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMACAddressSegment
(int value) Constructs a segment of an IPv4 or IPv6 address with the given value.MACAddressSegment
(int lower, int upper) Constructs a segment of a MAC address that represents a range of values. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(AddressSegment other) boolean
contains
(MACAddressSegment other) boolean
containsPrefixBlock
(int divisionPrefixLen) Returns whether the values of this series contains the prefix block for the given prefix length.boolean
containsSinglePrefixBlock
(int divisionPrefixLen) Returns whether the division range matches exactly the block of values for the given prefix length.boolean
Two divisions are equal if they: - they match type/version (ipv4, ipv6, mac, or a specific division class) - match bit counts - match values Prefix lengths, for those divisions that have them, are ignored.int
Provides the number of bits comprising this address itemint
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8int
long
long
Useful for using an instance in a "for-each loop".getLower()
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.int
int
Gets the maximum possible value for this type of segment (for the highest range value of this particular segment, useAddressSegment.getUpper()
long
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)int
returns the lower valuegetUpper()
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.long
int
returns the upper valueint
int
hashCode()
boolean
isBoundedBy
(int value) Returns true if the possible values of this division fall below the given value.iterator()
Iterates through the individual address components.boolean
matches
(int value) boolean
matchesWithMask
(int value, int mask) boolean
matchesWithMask
(int lowerValue, int upperValue, int mask) boolean
prefixEquals
(AddressSegment o, int segmentPrefixLength) Returns whether the given prefix bits match the same bits of the given segment.reverseBits
(boolean perByte) Returns a new AddressComponent with the bits reversed.Returns an AddressComponent with the bytes reversed.Partitions and traverses through the individual address components.stream()
Returns a sequential stream of the individual address components.toHexString
(boolean with0xPrefix) Writes this address component as a single hexadecimal value with always the exact same number of characters, with or without a preceding 0x prefix.Produces a string that is consistent for all address components of the same type and version, and is also similar to the canonical stringAddressSegmentSeries.toCanonicalString()
inAddressComponent
instances that are alsoAddressSegmentSeries
instances.Methods inherited from class inet.ipaddr.format.standard.AddressDivision
bitwiseOrRange, getCount, getDigitCount, getDivisionPrefixCount, getMaxDigitCount, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperValue, getValue, hasUppercaseVariations, includesMax, includesZero, isBitwiseOrCompatibleWithRange, isMaskCompatibleWithRange, isMax, isMultiple, isZero, maskRange, matches, matchesWithMask, matchesWithMask
Methods inherited from class inet.ipaddr.format.AddressDivisionBase
getBytes, getBytes, getBytes, getDigitCount, getLowerStandardString, getStandardString, getUpperBytes, getUpperBytes, getUpperBytes, toString
Methods inherited from interface inet.ipaddr.format.AddressItem
compareTo, getBytes, getBytes, getBytes, getCount, getMinPrefixLengthForBlock, getPrefixCount, getPrefixLengthForSingleBlock, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, includesMax, includesZero, isFullRange, isMax, isMultiple, isZero
Methods inherited from interface inet.ipaddr.AddressSegment
isOneBit, testBit
Methods inherited from interface inet.ipaddr.format.string.AddressStringDivision
getDigitCount, getLowerStandardString, getMaxDigitCount, getStandardString
-
Field Details
-
MAX_CHARS
public static final int MAX_CHARS- See Also:
-
-
Constructor Details
-
MACAddressSegment
public MACAddressSegment(int value) Constructs a segment of an IPv4 or IPv6 address with the given value.- Parameters:
value
- the value of the segment- Throws:
AddressValueException
- if value is negative or too large
-
MACAddressSegment
public MACAddressSegment(int lower, int upper) Constructs a segment of a MAC address that represents a range of values.- Parameters:
lower
- the lower value of the range of values represented by the segment.upper
- the upper value of the range of values represented by the segment.- Throws:
AddressValueException
- if value is negative or too large
-
-
Method Details
-
getNetwork
Description copied from interface:AddressComponent
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)- Specified by:
getNetwork
in interfaceAddressComponent
- Returns:
-
getValueCount
public int getValueCount()- Specified by:
getValueCount
in interfaceAddressSegment
- Returns:
- the same value as
AddressItem.getCount()
as an integer
-
getDivisionValueCount
public long getDivisionValueCount()- Overrides:
getDivisionValueCount
in classAddressDivision
-
getBitCount
public int getBitCount()Description copied from interface:AddressItem
Provides the number of bits comprising this address item- 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
-
getMaxValue
public long getMaxValue()- Overrides:
getMaxValue
in classAddressDivision
-
getDivisionValue
public long getDivisionValue()- Specified by:
getDivisionValue
in classAddressDivision
-
getUpperDivisionValue
public long getUpperDivisionValue()- Specified by:
getUpperDivisionValue
in classAddressDivision
-
getSegmentValue
public int getSegmentValue()returns the lower value- Specified by:
getSegmentValue
in interfaceAddressSegment
-
getUpperSegmentValue
public int getUpperSegmentValue()returns the upper value- Specified by:
getUpperSegmentValue
in interfaceAddressSegment
-
getLower
Description copied from interface:AddressSegment
If this segment represents a range of values, returns a segment representing just the lowest value in the range, otherwise returns this.- Specified by:
getLower
in interfaceAddressComponentRange
- Specified by:
getLower
in interfaceAddressSegment
- Returns:
-
getUpper
Description copied from interface:AddressSegment
If this segment represents a range of values, returns a segment representing just the highest value in the range, otherwise returns this.- Specified by:
getUpper
in interfaceAddressComponentRange
- Specified by:
getUpper
in interfaceAddressSegment
- Returns:
-
reverseBits
Description copied from interface:AddressComponent
Returns a new AddressComponent with the bits reversed. If this component represents a range of values that cannot be reversed, then this throwsIncompatibleAddressException
. In a range the most significant bits stay constant while the least significant bits range over different values, so reversing that scenario results in a series of non-consecutive values, in most cases, which cannot be represented with a single AddressComponent object.In such cases where isMultiple() is true, call iterator(), getLower(), getUpper() or some other methods to break the series down into a series representing a single value.
- Specified by:
reverseBits
in interfaceAddressComponent
- Specified by:
reverseBits
in interfaceAddressSegment
- Parameters:
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversed- Returns:
-
reverseBits
-
reverseBytes
Description copied from interface:AddressComponent
Returns an AddressComponent with the bytes reversed. If this component represents a range of values that cannot be reversed, then this throwsIncompatibleAddressException
. In a range the most significant bits stay constant while the least significant bits range over different values, so reversing that scenario results in a series of non-consecutive values, in most cases, which cannot be represented with a single AddressComponent object.In such cases where isMultiple() is true, call iterator(), getLower(), getUpper() or some other methods to break the series down into a series representing a single value.
- Specified by:
reverseBytes
in interfaceAddressComponent
- Specified by:
reverseBytes
in interfaceAddressSegment
- Returns:
-
isBoundedBy
public boolean isBoundedBy(int value) Description copied from class:AddressDivision
Returns true if the possible values of this division fall below the given value.- Specified by:
isBoundedBy
in interfaceAddressStringDivision
- Overrides:
isBoundedBy
in classAddressDivision
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAddressDivision
-
equals
Description copied from class:AddressDivisionBase
Two divisions are equal if they: - they match type/version (ipv4, ipv6, mac, or a specific division class) - match bit counts - match values Prefix lengths, for those divisions that have them, are ignored.- Specified by:
equals
in interfaceAddressSegment
- Overrides:
equals
in classAddressDivision
-
contains
- Parameters:
other
-- Returns:
- whether this subnet segment contains the given address segment
-
getDefaultTextualRadix
public int getDefaultTextualRadix() -
getMaxDigitCount
public int getMaxDigitCount() -
matches
public boolean matches(int value) - Specified by:
matches
in interfaceAddressSegment
-
matchesWithMask
public boolean matchesWithMask(int value, int mask) - Specified by:
matchesWithMask
in interfaceAddressSegment
-
matchesWithMask
public boolean matchesWithMask(int lowerValue, int upperValue, int mask) - Specified by:
matchesWithMask
in interfaceAddressSegment
-
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 interfaceAddressSegment
- 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 interfaceAddressSegment
- Specified by:
iterator
in interfaceIterable<MACAddressSegment>
- 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 interfaceAddressSegment
- Specified by:
spliterator
in interfaceIterable<MACAddressSegment>
- 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 interfaceAddressSegment
- Returns:
-
getMaxSegmentValue
public int getMaxSegmentValue()Description copied from interface:AddressSegment
Gets the maximum possible value for this type of segment (for the highest range value of this particular segment, useAddressSegment.getUpper()
- Specified by:
getMaxSegmentValue
in interfaceAddressSegment
- Returns:
-
prefixEquals
Description copied from interface:AddressSegment
Returns whether the given prefix bits match the same bits of the given segment.- Specified by:
prefixEquals
in interfaceAddressSegment
- Parameters:
o
-segmentPrefixLength
-- Returns:
-
contains
- Specified by:
contains
in interfaceAddressSegment
-
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
-
toNormalizedString
Description copied from interface:AddressComponent
Produces a string that is consistent for all address components of the same type and version, and is also similar to the canonical stringAddressSegmentSeries.toCanonicalString()
inAddressComponent
instances that are alsoAddressSegmentSeries
instances.- Specified by:
toNormalizedString
in interfaceAddressComponent
- Returns:
-
toNormalizedString
-
containsPrefixBlock
public boolean containsPrefixBlock(int divisionPrefixLen) Description copied from interface:AddressItem
Returns whether the values of this series contains the prefix block for the given prefix length.Use
AddressItem.getMinPrefixLengthForBlock()
to determine the smallest prefix length for which this method returns true.- Specified by:
containsPrefixBlock
in interfaceAddressItem
- Parameters:
divisionPrefixLen
-- Returns:
- whether the division range includes the block of values for the given prefix length
-
containsSinglePrefixBlock
public boolean containsSinglePrefixBlock(int divisionPrefixLen) Returns whether the division range matches exactly the block of values for the given prefix length.- Specified by:
containsSinglePrefixBlock
in interfaceAddressItem
- Parameters:
divisionPrefixLen
-- Returns:
- whether the range of this division matches the range for a single prefix with a single value and the given prefix length.
-