public class EthernetAddress extends Object implements Serializable, Cloneable, Comparable
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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(Object o)
Method that compares this EthernetAddress to one passed in as
argument.
|
boolean |
equals(Object o) |
static void |
main(String[] args) |
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.
|
public EthernetAddress(String addrStr) throws NumberFormatException
addrStr - String representation of the ethernet addressNumberFormatExceptionpublic EthernetAddress(byte[] addr)
throws NumberFormatException
NumberFormatExceptionpublic EthernetAddress(long addr)
addr - long that contains the MAC address in 6 least significant
bytes.public Object clone()
public int compareTo(Object o)
compareTo in interface Comparablepublic String toString()
public byte[] asByteArray()
public byte[] toByteArray()
public void toByteArray(byte[] array)
public void toByteArray(byte[] array,
int pos)
public long toLong()
public static EthernetAddress valueOf(byte[] addr) throws NumberFormatException
addr - Binary representation of the ethernet addressNumberFormatException - 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 addressNumberFormatException - 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 addressNumberFormatException - if addr representation is invalidpublic static EthernetAddress valueOf(long addr)
addr - Long int representation of the ethernet addresspublic static void main(String[] args)