|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fasterxml.uuid.EthernetAddress
public class EthernetAddress
EthernetAddress encapsulates the 6-byte MAC address defined in IEEE 802.1 standard.
Field Summary | |
---|---|
protected long |
_address
48-bit MAC address, stored in 6 lowest-significant bytes (in big endian notation) |
protected static Random |
_rnd
We may need a random number generator, for creating dummy ethernet address if no real interface is found. |
Constructor Summary | |
---|---|
EthernetAddress(byte[] addr)
Binary constructor that constructs an instance given the 6 byte (48-bit) address. |
|
EthernetAddress(long addr)
Another binary constructor; constructs an instance from the given long argument; the lowest 6 bytes contain the address. |
|
EthernetAddress(String addrStr)
String constructor; given a 'standard' ethernet MAC address string (like '00:C0:F0:3D:5B:7C'), constructs an EthernetAddress instance. |
Method Summary | |
---|---|
protected static Random |
_randomNumberGenerator()
Helper method for accessing configured random number generator |
byte[] |
asByteArray()
Returns 6 byte byte array that contains the binary representation of this ethernet address; byte 0 is the most significant byte (and so forth) |
Object |
clone()
Default cloning behaviour (bitwise copy) is just fine... |
int |
compareTo(EthernetAddress other)
Method that compares this EthernetAddress to one passed in as argument. |
static EthernetAddress |
constructMulticastAddress()
Factory method that can be used to construct a random multicast address; to be used in cases where there is no "real" ethernet address to use. |
static EthernetAddress |
constructMulticastAddress(Random rnd)
Factory method that can be used to construct a random multicast address; to be used in cases where there is no "real" ethernet address to use. |
boolean |
equals(Object o)
|
static EthernetAddress |
fromInterface()
Factory method that locates a network interface that has a suitable mac address (ethernet cards, and things that emulate one), and return that address. |
boolean |
isLocallyAdministeredAddress()
Method that can be used to check if this address refers to a "locally administered address" (see [http://en.wikipedia.org/wiki/MAC_address] for details). |
boolean |
isMulticastAddress()
Method that can be used to check if this address refers to a multicast address. |
byte[] |
toByteArray()
Synonym to 'asByteArray()' |
void |
toByteArray(byte[] array)
|
void |
toByteArray(byte[] array,
int pos)
|
long |
toLong()
|
String |
toString()
Returns the canonical string representation of this ethernet address. |
static EthernetAddress |
valueOf(byte[] addr)
Constructs a new EthernetAddress given the byte array that contains binary representation of the address. |
static EthernetAddress |
valueOf(int[] addr)
Constructs a new EthernetAddress given the byte array that contains binary representation of the address. |
static EthernetAddress |
valueOf(long addr)
Constructs a new EthernetAddress given the long int value (64-bit) representation of the ethernet address (of which 48 LSB contain the definition) Note that calling this method returns the same result as would using the matching constructor. |
static EthernetAddress |
valueOf(String addrStr)
Constructs a new EthernetAddress given a string representation of the ethernet address. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static Random _rnd
protected final long _address
Constructor Detail |
---|
public EthernetAddress(String addrStr) throws NumberFormatException
addrStr
- String representation of the ethernet address
NumberFormatException
public EthernetAddress(byte[] addr) throws NumberFormatException
NumberFormatException
public EthernetAddress(long addr)
addr
- long that contains the MAC address in 6 least significant
bytes.Method Detail |
---|
public Object clone()
clone
in class Object
public static EthernetAddress valueOf(byte[] addr) throws NumberFormatException
addr
- Binary representation of the ethernet address
NumberFormatException
- if addr is invalid (less or more than
6 bytes in array)public static EthernetAddress valueOf(int[] addr) throws NumberFormatException
addr
- Binary representation of the ethernet address
NumberFormatException
- if addr is invalid (less or more than
6 ints in array)public static EthernetAddress valueOf(String addrStr) throws NumberFormatException
addrStr
- String representation of the ethernet address
NumberFormatException
- if addr representation is invalidpublic static EthernetAddress valueOf(long addr)
addr
- Long int representation of the ethernet addresspublic static EthernetAddress fromInterface()
public static EthernetAddress constructMulticastAddress()
Internally a SecureRandom
instance is used for generating
random number to base address on.
public static EthernetAddress constructMulticastAddress(Random rnd)
Address is created using specified random number generator.
public byte[] asByteArray()
public byte[] toByteArray()
public void toByteArray(byte[] array)
public void toByteArray(byte[] array, int pos)
public long toLong()
public boolean isMulticastAddress()
public boolean isLocallyAdministeredAddress()
public boolean equals(Object o)
equals
in class Object
public int compareTo(EthernetAddress other)
compareTo
in interface Comparable<EthernetAddress>
public String toString()
toString
in class Object
protected static Random _randomNumberGenerator()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |