public class MACAddress extends Address implements java.lang.Iterable<MACAddress>
Address.AddressProvider, Address.SegmentValueProvider| Modifier and Type | Field and Description |
|---|---|
static int |
BITS_PER_SEGMENT |
static int |
BYTES_PER_SEGMENT |
static char |
COLON_SEGMENT_SEPARATOR |
static char |
DASH_SEGMENT_SEPARATOR |
static char |
DASHED_SEGMENT_RANGE_SEPARATOR |
static java.lang.String |
DASHED_SEGMENT_RANGE_SEPARATOR_STR |
static int |
DEFAULT_TEXTUAL_RADIX |
static char |
DOTTED_SEGMENT_SEPARATOR |
static int |
EXTENDED_UNIQUE_IDENTIFIER_48_SEGMENT_COUNT |
static int |
EXTENDED_UNIQUE_IDENTIFIER_64_SEGMENT_COUNT |
static int |
MAX_VALUE_PER_DOTTED_SEGMENT |
static int |
MAX_VALUE_PER_SEGMENT |
static int |
MEDIA_ACCESS_CONTROL_DOTTED_64_SEGMENT_COUNT |
static int |
MEDIA_ACCESS_CONTROL_DOTTED_BITS_PER_SEGMENT |
static int |
MEDIA_ACCESS_CONTROL_DOTTED_SEGMENT_COUNT |
static int |
MEDIA_ACCESS_CONTROL_SEGMENT_COUNT |
static int |
MEDIA_ACCESS_CONTROL_SINGLE_DASHED_SEGMENT_COUNT |
static int |
ORGANIZATIONAL_UNIQUE_IDENTIFIER_BIT_COUNT |
static int |
ORGANIZATIONAL_UNIQUE_IDENTIFIER_SEGMENT_COUNT |
static char |
SPACE_SEGMENT_SEPARATOR |
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.
|
| Modifier and Type | Method and Description |
|---|---|
MACAddress |
adjustPrefixBySegment(boolean nextSegment)
Increases or decreases prefix length to the next segment boundary.
|
MACAddress |
adjustPrefixLength(int adjustment)
Increases or decreases prefix length by the given increment.
|
MACAddress |
applyPrefixLength(int prefixLength)
Applies the given prefix length to create a new segment series.
|
boolean |
contains(Address other) |
boolean |
contains(MACAddress other) |
MACAddressNetwork.MACAddressCreator |
getAddressCreator() |
int |
getBitCount() |
int |
getBitsPerSegment()
Returns the number of bits comprising each segment in this series.
|
int |
getByteCount()
returns the number of bytes in each of the address components represented by this instance
|
int |
getBytesPerSegment()
Returns the number of bytes comprising each segment in this series.
|
AddressDivisionGrouping |
getDottedAddress() |
IPv6AddressNetwork |
getIPv6Network() |
java.lang.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() |
MACAddressNetwork |
getNetwork()
Returns the network object for series of the same version (eg IPv4, IPv6 and MAC each have their own network object)
|
MACAddressSection |
getODISection() |
MACAddressSection |
getOUISection() |
MACAddressSection |
getSection() |
MACAddressSection |
getSection(int index)
Gets the subsection from the series starting from the given index
|
MACAddressSection |
getSection(int index,
int endIndex)
Gets the subsection from the series starting from the given index and ending just before the give endIndex
|
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
If this represents a series with a single value in each segment, returns this.
|
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() |
boolean |
isMulticast()
Whether the MAC address or IP address or other form of address is multicast.
|
boolean |
isUniversal() |
java.util.Iterator<MACAddress> |
iterator()
Iterates through the individual segment series.
|
long |
longValue() |
static int |
maxSegmentValue() |
MACAddress |
removePrefixLength()
Removes the prefix length.
|
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 |
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.
|
java.util.Iterator<MACAddressSegment[]> |
segmentsIterator()
Iterates through the individual segments.
|
MACAddress |
setPrefixLength(int prefixLength)
Sets the prefix length.
|
MACAddressString |
toAddressString()
Returns a host identifier string representation for this address,
which will be already validated.
|
java.lang.String |
toColonDelimitedString() |
java.lang.String |
toDashedString() |
java.lang.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.
|
java.lang.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.
|
java.lang.String |
toSpaceDelimitedString() |
long |
upperLongValue() |
compareTo, defaultIpv4Network, defaultIpv6Network, defaultMACNetwork, equals, getBytes, getBytes, getCount, getDivision, getDivisionCount, getDivisionStrings, getMinPrefixLengthForBlock, getPrefixLength, getPrefixLengthForSingleBlock, getSegmentCount, getSegments, getSegments, getSegmentStrings, getUpperBytes, getUpperBytes, getUpperValue, getValue, hashCode, isFullRange, isMore, isMultiple, isPrefixBlock, isPrefixed, isSameAddress, isSinglePrefixBlock, isZero, toCanonicalString, toCompressedString, toHexString, toNormalizedString, toStringpublic 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 java.lang.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_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 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 segmentsAddressValueExceptionpublic MACAddress(MACAddressSection section) throws AddressValueException
section - the address segmentsAddressValueExceptionpublic MACAddress(long address)
throws AddressValueException
AddressValueExceptionpublic MACAddress(long address,
boolean extended)
throws AddressValueException
AddressValueExceptionpublic MACAddress(byte[] bytes)
throws AddressValueException
AddressValueExceptionpublic 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 segmentAddressValueExceptionpublic MACAddress(Address.SegmentValueProvider valueProvider)
valueProvider - supplies the 1 byte value for each segmentpublic MACAddressNetwork getNetwork()
AddressSegmentSeriesgetNetwork in interface AddressSegmentSeriespublic IPv6AddressNetwork getIPv6Network()
public MACAddressNetwork.MACAddressCreator getAddressCreator()
public boolean isExtended()
public boolean isAllAddresses()
public MACAddressSection getSection()
getSection in class Addresspublic MACAddressSegment getSegment(int index)
AddressSegmentSeriesgetSegment in interface AddressSegmentSeriesgetSegment in class Addresspublic MACAddressSegment[] getSegments()
AddressSegmentSeriesAddressSegmentSeries.getSegment(int) and AddressSegmentSeries.getSegmentCount() instead when feasible.getSegments in interface AddressSegmentSeriesgetSegments in class Addresspublic static int maxSegmentValue()
public int getMaxSegmentValue()
getMaxSegmentValue in class Addresspublic int getByteCount()
AddressComponentgetByteCount in interface AddressComponentgetByteCount in class Addresspublic int getBitCount()
getBitCount in interface AddressItemgetBitCount in class Addresspublic int getBytesPerSegment()
AddressSegmentSeriesgetBytesPerSegment in interface AddressSegmentSeriespublic int getBitsPerSegment()
AddressSegmentSeriesgetBitsPerSegment in interface AddressSegmentSeriespublic boolean contains(MACAddress other)
other - public java.lang.Iterable<MACAddress> getIterable()
AddressComponentAddressComponent.iterator() directly.getIterable in interface AddressComponentgetIterable in interface AddressSegmentSeriesgetIterable in class Addresspublic java.util.Iterator<MACAddress> iterator()
AddressSegmentSeriesiterator in interface AddressComponentiterator in interface AddressSegmentSeriesiterator in interface java.lang.Iterable<MACAddress>iterator in class Addresspublic java.util.Iterator<MACAddressSegment[]> segmentsIterator()
AddressSegmentSeriessegmentsIterator in interface AddressSegmentSeriessegmentsIterator in class Addresspublic MACAddress getLower()
AddressSegmentSeriesgetLower in interface AddressComponentgetLower in interface AddressSegmentSeriesgetLower in class Addresspublic MACAddress getUpper()
AddressSegmentSeriesgetUpper in interface AddressComponentgetUpper in interface AddressSegmentSeriesgetUpper in class Addresspublic long longValue()
public long upperLongValue()
public MACAddress reverseBits(boolean perByte)
reverseBits in interface AddressComponentreverseBits in interface AddressSegmentSeriesreverseBits in class AddressperByte - if true, only the bits in each byte are reversed, if false, then all bits in the component are reversedpublic MACAddress reverseBytes()
AddressSegmentSeriesreverseBytes in interface AddressComponentreverseBytes in interface AddressSegmentSeriesreverseBytes in class Addresspublic MACAddress reverseBytesPerSegment()
AddressSegmentSeriesreverseBytesPerSegment in interface AddressSegmentSeriesreverseBytesPerSegment in class Addresspublic MACAddress reverseSegments()
AddressSegmentSeriesIncompatibleAddressException since all address series can reverse their segments.reverseSegments in interface AddressSegmentSeriesreverseSegments in class Addresspublic MACAddress removePrefixLength()
AddressSegmentSeriesIf the series already has a prefix length, the bits previously not within the prefix become zero.
removePrefixLength in interface AddressSegmentSeriesremovePrefixLength in class Addresspublic 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.
With some address types, the bits moved outside the prefix will become zero in the returned series.
applyPrefixLength in interface AddressSegmentSeriesapplyPrefixLength in class AddressAddressSegmentSeries.setPrefixLength(int)public MACAddress adjustPrefixBySegment(boolean nextSegment)
AddressSegmentSeriesWhen prefix length is increased, the bits moved within the prefix become zero. When a prefix length is decreased, whether the bits moved outside the prefix become zero is dependent on the address type.
adjustPrefixBySegment in interface AddressSegmentSeriesadjustPrefixBySegment in class Addresspublic MACAddress adjustPrefixLength(int adjustment)
AddressSegmentSeriesWhen 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, whether the bits moved outside the prefix become zero is dependent on the address type.
adjustPrefixLength in interface AddressSegmentSeriesadjustPrefixLength in class Addresspublic MACAddress setPrefixLength(int prefixLength)
AddressSegmentSeriesIf this series has a prefix length, and the prefix length is increased, the bits moved within the prefix become zero.
When the prefix is extended beyond the segment series boundary, it is removed.
When a prefix length is decreased, whether the bits moved outside the prefix become zero is dependent on the address type.
setPrefixLength in interface AddressSegmentSeriessetPrefixLength in class AddressAddressSegmentSeries.applyPrefixLength(int)public MACAddressSection getSection(int index)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriesgetSection in class Addresspublic MACAddressSection getSection(int index, int endIndex)
AddressSegmentSeriesgetSection in interface AddressSegmentSeriesgetSection in class Addresspublic MACAddressSection getODISection()
public MACAddressSection getOUISection()
public MACAddress toOUIPrefixBlock()
public MACAddress toPrefixBlock()
AddressSegmentSeriestoPrefixBlock in interface AddressSegmentSeriestoPrefixBlock in class Addresspublic 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 - java.lang.IndexOutOfBoundsExceptionpublic AddressDivisionGrouping getDottedAddress()
public MACAddressString toAddressString()
AddresstoAddressString in class Addresspublic java.lang.String toNormalizedString(AddressDivisionGrouping.StringOptions stringOptions)
public java.lang.String toDottedString()
public java.lang.String toDashedString()
public java.lang.String toColonDelimitedString()
public java.lang.String toSpaceDelimitedString()
public boolean isMulticast()
AddressisMulticast in class AddressInetAddress.isMulticastAddress()public boolean isUniversal()