public class MACAddress extends Address implements Iterable<MACAddress>
You can construct a MAC address from a byte array, from a long, from a Address.SegmentValueProvider
,
from a NetworkInterface
, from a MACAddressSection
of 6 or 8 segments, or from an array of 6 or 8 MACAddressSegment
objects.
To construct one from a String
use
MACAddressString.toAddress()
or MACAddressString.getAddress()
Address.AddressValueProvider, Address.SegmentValueProvider
ADDRESS_HIGH_VALUE_COMPARATOR, ADDRESS_LOW_VALUE_COMPARATOR, ALTERNATIVE_RANGE_SEPARATOR, ALTERNATIVE_RANGE_SEPARATOR_STR, ALTERNATIVE_SEGMENT_WILDCARD_STR, DEFAULT_ADDRESS_COMPARATOR, HEX_PREFIX, OCTAL_PREFIX, RANGE_SEPARATOR, RANGE_SEPARATOR_STR, SEGMENT_SQL_SINGLE_WILDCARD, SEGMENT_SQL_SINGLE_WILDCARD_STR, SEGMENT_SQL_WILDCARD, SEGMENT_SQL_WILDCARD_STR, SEGMENT_WILDCARD, SEGMENT_WILDCARD_STR
Constructor and Description |
---|
MACAddress(Address.SegmentValueProvider valueProvider)
Constructs a MAC address
|
MACAddress(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider)
Constructs a MAC address
|
MACAddress(Address.SegmentValueProvider lowerValueProvider,
Address.SegmentValueProvider upperValueProvider,
boolean extended)
Constructs a MAC address
|
MACAddress(Address.SegmentValueProvider valueProvider,
boolean extended)
Constructs a MAC address
|
MACAddress(byte[] bytes)
Constructs a MAC address.
|
MACAddress(long address)
Constructs a MAC address.
|
MACAddress(long address,
boolean extended)
Constructs a MAC address.
|
MACAddress(MACAddressSection section)
Constructs a MAC address.
|
MACAddress(MACAddressSegment[] segments)
Constructs a MAC address.
|
MACAddress(NetworkInterface ni)
Constructs a MAC address for a network interface.
|
Modifier and Type | Method and Description |
---|---|
MACAddress |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
MACAddress |
adjustPrefixBySegment(boolean nextSegment,
boolean zeroed)
Increases or decreases prefix length to the next segment boundary.
|
MACAddress |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
MACAddress |
adjustPrefixLength(int adjustment,
boolean zeroed)
Increases or decreases prefix length by the given increment.
|
MACAddress |
applyPrefixLength(int prefixLength)
Deprecated.
|
BigInteger |
enumerate(Address other)
Indicates where an address sits relative to the subnet ordering.
|
MACAddressNetwork.MACAddressCreator |
getAddressCreator() |
int |
getBitCount()
Provides the number of bits comprising this address item
|
int |
getBitsPerSegment()
Returns the number of bits comprising each segment in this series.
|
int |
getByteCount()
Provides the number of bytes required for this address item, rounding up if the bit count is not a multiple of 8
|
int |
getBytesPerSegment()
Returns the number of bytes comprising each segment in this series.
|
MACAddressSegment |
getDivision(int index) |
AddressDivisionGrouping |
getDottedAddress() |
IPv6AddressNetwork |
getIPv6Network() |
Iterable<MACAddress> |
getIterable()
Useful for using an instance in a "for-each loop".
|
MACAddress |
getLower()
If this represents a series with ranging values, returns a series representing the lower values of the range.
|
int |
getMaxSegmentValue()
Returns the maximum possible segment value for this type of address.
|
MACAddressNetwork |
getNetwork()
Returns the network object for components of the same version (eg IPv4, IPv6 and MAC each have their own network object)
|
MACAddressSection |
getODISection() |
MACAddressSection |
getOUISection() |
MACAddressSection |
getSection()
Gets the subsection from the series that comprises all segments
|
MACAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
The first segment is at index 0.
|
MACAddressSection |
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.
|
MACAddressSegment |
getSegment(int index)
Returns the segment from this series at the given index.
|
MACAddressSegment[] |
getSegments()
Returns the segments of this series of segments as an array.
|
MACAddress |
getUpper()
If this represents a series with ranging values, returns a series representing the upper values of the range.
|
MACAddress |
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.
|
MACAddress |
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 |
isAllAddresses() |
boolean |
isEUI64(boolean asMAC)
Whether this section is consistent with an IPv6 EUI64 section,
which means it came from an extended 8 byte address,
and the corresponding segments in the middle match 0xff and 0xff/fe for MAC/not-MAC
|
boolean |
isExtended() |
boolean |
isLocal()
Local MAC addresses have the second least significant bit of the first octet set to 1.
|
boolean |
isMACAddress()
Returns whether this address is a MAC address
|
boolean |
isMulticast()
Multicast MAC addresses have the least significant bit of the first octet set to 1.
|
boolean |
isUnicast() |
boolean |
isUniversal()
Universal MAC addresses have second the least significant bit of the first octet set to 0.
|
Iterator<MACAddress> |
iterator()
Iterates through the individual address components.
|
long |
longValue() |
static int |
maxSegmentValue() |
Iterator<MACAddress> |
prefixBlockIterator()
Iterates through the individual prefix blocks.
|
AddressComponentSpliterator<MACAddress> |
prefixBlockSpliterator()
Partitions and traverses through the individual prefix blocks for the prefix length of this series.
|
Stream<MACAddress> |
prefixBlockStream()
Returns a sequential stream of the individual prefix blocks for the prefix length of this series.
|
Iterator<MACAddress> |
prefixIterator()
Iterates through the individual prefixes.
|
AddressComponentSpliterator<MACAddress> |
prefixSpliterator()
Partitions and traverses through the individual prefixes for the prefix length of this series.
|
Stream<MACAddress> |
prefixStream()
Returns a sequential stream of the individual prefixes for the prefix length of this series.
|
MACAddress |
removePrefixLength()
Deprecated.
|
MACAddress |
removePrefixLength(boolean zeroed)
Deprecated.
|
MACAddress |
replace(int startIndex,
int endIndex,
MACAddress replacement,
int replacementIndex)
Replaces segments starting from startIndex and ending before endIndex with the same number of segments starting at replacementStartIndex from the replacement section
|
MACAddress |
replace(int startIndex,
MACAddressSection replacement)
Replaces segments starting from startIndex with as many segments as possible from the replacement section
|
MACAddress |
reverseBits(boolean perByte)
Use to produce:
"MSB format", "IBM format", "Token-Ring format", and "non-canonical form"
See RFC 2469 section 2
Also see https://en.wikipedia.org/wiki/MAC_address
|
MACAddress |
reverseBytes()
Returns a new segment series with the bytes reversed.
|
MACAddress |
reverseBytesPerSegment()
Returns a new segment series with the bytes reversed within each segment.
|
MACAddress |
reverseSegments()
Returns a new segment series with the segments reversed.
|
Iterator<MACAddressSegment[]> |
segmentsIterator()
Iterates through the individual segments.
|
AddressComponentRangeSpliterator<MACAddress,MACAddressSegment[]> |
segmentsSpliterator()
Partitions and traverses through the individual segment arrays.
|
Stream<MACAddressSegment[]> |
segmentsStream()
Returns a sequential stream of the individual segment arrays.
|
MACAddress |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
MACAddress |
setPrefixLength(int prefixLength,
boolean zeroed)
Sets the prefix length.
|
AddressComponentSpliterator<MACAddress> |
spliterator()
Partitions and traverses through the individual address components.
|
Stream<MACAddress> |
stream()
Returns a sequential stream of the individual address components.
|
MACAddressString |
toAddressString()
Returns a host identifier string representation for this address,
which will be already validated.
|
String |
toColonDelimitedString() |
String |
toDashedString() |
String |
toDottedString() |
MACAddress |
toEUI64(boolean asMAC)
Convert to IPv6 EUI-64 section
http://standards.ieee.org/develop/regauth/tut/eui64.pdf
|
IPv6AddressSection |
toEUI64IPv6()
Converts to an Ipv6 address section.
|
IPv6Address |
toLinkLocalIPv6()
Converts to a link-local Ipv6 address.
|
MACAddress |
toMACAddress()
If this address is a MAC address, returns that
MACAddress . |
String |
toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions) |
MACAddress |
toOUIPrefixBlock()
Returns an address in which the range of values match the block for the OUI (organizationally unique identifier)
|
MACAddress |
toPrefixBlock()
If this series has a prefix length, returns the block for that prefix.
|
String |
toSpaceDelimitedString() |
String |
toString() |
long |
upperLongValue() |
MACAddress |
withoutPrefixLength()
Provides the same address with no prefix.
|
contains, containsPrefixBlock, containsSinglePrefixBlock, defaultIpv4Network, defaultIpv6Network, defaultMACNetwork, equals, getBlockCount, getBytes, getBytes, getBytes, getCount, getDivisionCount, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixCount, getPrefixCount, getPrefixLength, getPrefixLengthForSingleBlock, getSegmentCount, getSegments, getSegments, getSegmentStrings, getUpperBytes, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, includesMax, includesZero, isFullRange, isIPAddress, isMax, isMultiple, isPrefixBlock, isPrefixed, isSameAddress, isSequential, isSinglePrefixBlock, isZero, matchOrdered, matchUnordered, overlaps, prefixEquals, toCanonicalString, toCompressedString, toHexString, toIPAddress, toNormalizedString
isOneBit, testBit
getSequentialBlockIndex, isMore
stream, stream
compareTo, getBitsForCount, getBlockSize
public static final char COLON_SEGMENT_SEPARATOR
public static final char DASH_SEGMENT_SEPARATOR
public static final char SPACE_SEGMENT_SEPARATOR
public static final char DOTTED_SEGMENT_SEPARATOR
public static final char DASHED_SEGMENT_RANGE_SEPARATOR
public static final String DASHED_SEGMENT_RANGE_SEPARATOR_STR
public static final int BITS_PER_SEGMENT
public static final int BYTES_PER_SEGMENT
public static final int MEDIA_ACCESS_CONTROL_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_BIT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_64_SEGMENT_COUNT
public static final int MEDIA_ACCESS_CONTROL_DOTTED_BITS_PER_SEGMENT
public static final int MEDIA_ACCESS_CONTROL_SINGLE_DASHED_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_48_BIT_COUNT
public static final int EXTENDED_UNIQUE_IDENTIFIER_64_BIT_COUNT
public static final int DEFAULT_TEXTUAL_RADIX
public static final int MAX_VALUE_PER_SEGMENT
public static final int MAX_VALUE_PER_DOTTED_SEGMENT
public static final int ORGANIZATIONAL_UNIQUE_IDENTIFIER_SEGMENT_COUNT
public static final int ORGANIZATIONAL_UNIQUE_IDENTIFIER_BIT_COUNT
public MACAddress(MACAddressSegment[] segments) throws AddressValueException
segments
- the address segmentsAddressValueException
public MACAddress(MACAddressSection section) throws AddressValueException
section
- the address segmentsAddressValueException
public MACAddress(long address) throws AddressValueException
AddressValueException
public MACAddress(NetworkInterface ni) throws SocketException
SocketException
public MACAddress(long address, boolean extended) throws AddressValueException
AddressValueException
public MACAddress(byte[] bytes) throws AddressValueException
AddressValueException
public MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider, boolean extended)
lowerValueProvider
- supplies the 1 byte lower values for each segmentupperValueProvider
- supplies the 1 byte upper values for each segmentpublic MACAddress(Address.SegmentValueProvider lowerValueProvider, Address.SegmentValueProvider upperValueProvider)
lowerValueProvider
- supplies the 1 byte lower values for each segmentupperValueProvider
- supplies the 1 byte upper values for each segmentpublic MACAddress(Address.SegmentValueProvider valueProvider, boolean extended) throws AddressValueException
valueProvider
- supplies the 1 byte value for each segmentAddressValueException
public MACAddress(Address.SegmentValueProvider valueProvider)
valueProvider
- supplies the 1 byte value for each segmentpublic BigInteger enumerate(Address other)
Address
Determines how many address elements of a subnet precede the given address element, if the address is in the subnet. If above the subnet range, it is the distance to the upper boundary added to the subnet address count less one, and if below the subnet range, the distance to the lower boundary.
In other words, if the given address is not in the subnet but above it, returns the number of addresses preceding the address from the upper subnet boundary, added to one less than the total number of subnet addresses. If the given address is not in the subnet but below it, returns the number of addresses following the address to the lower subnet boundary.
enumerate returns null when the argument is a multi-valued subnet. The argument must be an individual address.
When this address is also single-valued, the returned value is the distance (difference) between this address and the argument address.
enumerate is the inverse of the increment method:
If the given address does not have the same version or type as this subnet or address, then null is returned.
public MACAddressNetwork getNetwork()
AddressComponent
getNetwork
in interface AddressComponent
public IPv6AddressNetwork getIPv6Network()
public MACAddressNetwork.MACAddressCreator getAddressCreator()
public boolean isExtended()
public boolean isMACAddress()
Address
isMACAddress
in class Address
public MACAddress toMACAddress()
Address
MACAddress
. Otherwise, returns null.toMACAddress
in class Address
public boolean isAllAddresses()
public MACAddressSection getSection()
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
getSection
in class Address
public MACAddressSegment getDivision(int index)
getDivision
in interface AddressDivisionSeries
getDivision
in interface AddressStringDivisionSeries
public MACAddressSegment getSegment(int index)
AddressSegmentSeries
AddressDivisionSeries.getDivision(int)
, the difference being that all segments in a given series are the same bit count, while divisions can have variable length.getSegment
in interface AddressSegmentSeries
public MACAddressSegment[] getSegments()
AddressSegmentSeries
AddressSegmentSeries.getSegment(int)
and AddressSegmentSeries.getSegmentCount()
instead when feasible.getSegments
in interface AddressSegmentSeries
public static int maxSegmentValue()
public int getMaxSegmentValue()
AddressSegmentSeries
getMaxSegmentValue
in interface AddressSegmentSeries
public int getByteCount()
AddressItem
getByteCount
in interface AddressItem
getByteCount
in class Address
public int getBitCount()
AddressItem
getBitCount
in interface AddressDivisionSeries
getBitCount
in interface AddressItem
getBitCount
in class Address
public int getBytesPerSegment()
AddressSegmentSeries
getBytesPerSegment
in interface AddressSegmentSeries
public int getBitsPerSegment()
AddressSegmentSeries
getBitsPerSegment
in interface AddressSegmentSeries
public Iterable<MACAddress> getIterable()
AddressComponentRange
AddressComponentRange.iterator()
directly.getIterable
in interface AddressSegmentSeries
getIterable
in interface AddressComponentRange
getIterable
in class Address
public Iterator<MACAddress> iterator()
AddressComponentRange
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, or AddressItem.getCount()
for the count.
iterator
in interface AddressSegmentSeries
iterator
in interface AddressComponentRange
iterator
in interface Iterable<MACAddress>
iterator
in class Address
public AddressComponentSpliterator<MACAddress> spliterator()
AddressComponentRange
spliterator
in interface AddressComponent
spliterator
in interface AddressSegmentSeries
spliterator
in interface AddressComponentRange
spliterator
in interface Iterable<MACAddress>
spliterator
in class Address
public Stream<MACAddress> stream()
AddressComponentRange
BaseStream.parallel()
on the returned stream.stream
in interface AddressSegmentSeries
stream
in interface AddressComponentRange
stream
in class Address
public Iterator<MACAddress> prefixBlockIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixBlockIterator
in interface AddressSegmentSeries
prefixBlockIterator
in class Address
public AddressComponentSpliterator<MACAddress> prefixBlockSpliterator()
AddressSegmentSeries
prefixBlockSpliterator
in interface AddressSegmentSeries
prefixBlockSpliterator
in class Address
public Stream<MACAddress> prefixBlockStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixBlockStream
in interface AddressSegmentSeries
prefixBlockStream
in class Address
public Iterator<MACAddress> prefixIterator()
AddressSegmentSeries
If the series has no prefix length, then this is equivalent to AddressSegmentSeries.iterator()
prefixIterator
in interface AddressSegmentSeries
prefixIterator
in class Address
public AddressComponentSpliterator<MACAddress> prefixSpliterator()
AddressSegmentSeries
prefixSpliterator
in interface AddressSegmentSeries
prefixSpliterator
in class Address
public Stream<MACAddress> prefixStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.prefixStream
in interface AddressSegmentSeries
prefixStream
in class Address
public Iterator<MACAddressSegment[]> segmentsIterator()
AddressSegmentSeries
segmentsIterator
in interface AddressSegmentSeries
public AddressComponentRangeSpliterator<MACAddress,MACAddressSegment[]> segmentsSpliterator()
AddressSegmentSeries
segmentsSpliterator
in interface AddressSegmentSeries
public Stream<MACAddressSegment[]> segmentsStream()
AddressSegmentSeries
BaseStream.parallel()
on the returned stream.segmentsStream
in interface AddressSegmentSeries
public MACAddress increment(long increment)
AddressSegmentSeries
If the subnet has multiple values and the increment exceeds the subnet size, then the amount by which it exceeds the size - 1 is added to the upper series of the range (the final iterator value).
If the increment is negative, it is added to the lower series of the range (the first iterator value).
If the subnet is just a single address values, the series is simply incremented by the given value, positive or negative.
If a subnet has multiple values, a positive increment value is equivalent to the same number of values from the AddressSegmentSeries.iterator()
For instance, a increment of 0 is the first value from the iterator, an increment of 1 is the second value from the iterator, and so on.
A negative increment added to the subnet count is equivalent to the same number of values preceding the upper bound of the iterator.
For instance, an increment of count - 1 is the last value from the iterator, an increment of count - 2 is the second last value, and so on.
An increment of size count gives you the series just above the highest series of the subnet. To get the series just below the lowest series of the subnet, use the increment -1.
increment
in interface AddressSegmentSeries
increment
in class Address
public MACAddress incrementBoundary(long increment)
AddressSegmentSeries
AddressSegmentSeries.getUpper()
) in the subnet range to produce a new series.
If the given increment is negative, adds the value to the lower series (AddressSegmentSeries.getLower()
) in the subnet range to produce a new series.
If the increment is zero, returns this.
In the case where the series is a single value, this simply returns the address produced by adding the given increment to this address series.
incrementBoundary
in interface AddressSegmentSeries
incrementBoundary
in class Address
public MACAddress getLower()
AddressSegmentSeries
getLower
in interface AddressSegmentSeries
getLower
in interface AddressComponentRange
getLower
in class Address
public MACAddress getUpper()
AddressSegmentSeries
getUpper
in interface AddressSegmentSeries
getUpper
in interface AddressComponentRange
getUpper
in class Address
public long longValue()
public long upperLongValue()
public MACAddress reverseBits(boolean perByte)
reverseBits
in interface AddressComponent
reverseBits
in interface AddressSegmentSeries
reverseBits
in class Address
perByte
- if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic MACAddress reverseBytes()
AddressSegmentSeries
reverseBytes
in interface AddressComponent
reverseBytes
in interface AddressSegmentSeries
reverseBytes
in class Address
public MACAddress reverseBytesPerSegment()
AddressSegmentSeries
reverseBytesPerSegment
in interface AddressSegmentSeries
reverseBytesPerSegment
in class Address
public MACAddress reverseSegments()
AddressSegmentSeries
IncompatibleAddressException
since all address series can reverse their segments.reverseSegments
in interface AddressSegmentSeries
reverseSegments
in class Address
@Deprecated public MACAddress removePrefixLength()
AddressSegmentSeries
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)
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in class Address
for an alternative which does not change the address series values.
public MACAddress withoutPrefixLength()
AddressSegmentSeries
Use AddressSegmentSeries.removePrefixLength()
as an alternative that deletes the host at the same time by zeroing the host values.
withoutPrefixLength
in interface AddressSegmentSeries
withoutPrefixLength
in class Address
@Deprecated public MACAddress removePrefixLength(boolean zeroed)
AddressSegmentSeries
AddressSegmentSeries.removePrefixLength()
removePrefixLength
in interface AddressSegmentSeries
removePrefixLength
in class Address
zeroed
- whether the bits outside the prefix become zero@Deprecated public MACAddress applyPrefixLength(int prefixLength)
AddressSegmentSeries
Similar to AddressSegmentSeries.setPrefixLength(int)
except that prefix lengths are never increased.
When this series already has a prefix length that is less than or equal to the requested prefix length, this series is returned.
Otherwise the returned series has the given prefix length.
The bits moved outside the prefix will become zero in the returned series.
applyPrefixLength
in interface AddressSegmentSeries
applyPrefixLength
in class Address
AddressSegmentSeries.setPrefixLength(int)
public MACAddress adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeries
Follows the same rules as AddressSegmentSeries.adjustPrefixLength(int)
:
When prefix length is increased, the bits moved within the prefix become zero.
When a prefix length is decreased, the bits moved outside the prefix become zero.
To avoid the zeroing behaviour, use AddressSegmentSeries.adjustPrefixBySegment(boolean, boolean)
with second arg false.
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in class Address
nextSegment
- whether to move prefix to previous or following segment boundarypublic MACAddress adjustPrefixBySegment(boolean nextSegment, boolean zeroed)
AddressSegmentSeries
adjustPrefixBySegment
in interface AddressSegmentSeries
adjustPrefixBySegment
in class Address
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 valuespublic MACAddress adjustPrefixLength(int adjustment)
AddressSegmentSeries
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.
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in class Address
public MACAddress adjustPrefixLength(int adjustment, boolean zeroed)
AddressSegmentSeries
adjustPrefixLength
in interface AddressSegmentSeries
adjustPrefixLength
in class Address
adjustment
- the incrementzeroed
- whether the bits that move from one side of the prefix to the other become zero or retain their original valuespublic MACAddress setPrefixLength(int prefixLength)
AddressSegmentSeries
If this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero.
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.
setPrefixLength
in interface AddressSegmentSeries
setPrefixLength
in class Address
public MACAddress setPrefixLength(int prefixLength, boolean zeroed)
AddressSegmentSeries
When the prefix is extended beyond the segment series boundary, it is removed.
setPrefixLength
in interface AddressSegmentSeries
setPrefixLength
in class Address
zeroed
- whether the bits that move from one side of the prefix length to the other (ie bits moved into the prefix or outside the prefix) are zeroed.public MACAddressSection getSection(int index)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
public MACAddressSection getSection(int index, int endIndex)
AddressSegmentSeries
getSection
in interface AddressSegmentSeries
public MACAddressSection getODISection()
public MACAddressSection getOUISection()
public MACAddress toOUIPrefixBlock()
public MACAddress toPrefixBlock()
AddressSegmentSeries
toPrefixBlock
in interface AddressSegmentSeries
toPrefixBlock
in class Address
public IPv6Address toLinkLocalIPv6()
public IPv6AddressSection toEUI64IPv6()
public boolean isEUI64(boolean asMAC)
asMAC
- public MACAddress toEUI64(boolean asMAC)
asMAC
- if true, this address is considered MAC and the EUI-64 is extended using ff-ff, otherwise this address is considered EUI-48 and extended using ff-fe
Note that IPv6 treats MAC as EUI-48 and extends MAC to IPv6 addresses using ff-fepublic MACAddress replace(int startIndex, int endIndex, MACAddress replacement, int replacementIndex)
startIndex
- endIndex
- replacement
- replacementIndex
- IndexOutOfBoundsException
public MACAddress replace(int startIndex, MACAddressSection replacement)
startIndex
- replacement
- IndexOutOfBoundsException
public AddressDivisionGrouping getDottedAddress()
public MACAddressString toAddressString()
Address
toAddressString
in class Address
public String toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions)
public String toDottedString() throws IncompatibleAddressException
IncompatibleAddressException
public String toDashedString()
public String toColonDelimitedString()
public String toSpaceDelimitedString()
public boolean isUnicast()
public boolean isMulticast()
isMulticast
in class Address
InetAddress.isMulticastAddress()
public boolean isUniversal()