public class EthernetAddress
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, java.lang.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(java.lang.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)
|
java.lang.Object |
clone()
Default cloning behaviour (bitwise copy) is just fine...
|
int |
compareTo(java.lang.Object o)
Method that compares this EthernetAddress to one passed in as
argument.
|
boolean |
equals(java.lang.Object o) |
static void |
main(java.lang.String[] args) |
byte[] |
toByteArray()
Synonym to 'asByteArray()'
|
void |
toByteArray(byte[] array) |
void |
toByteArray(byte[] array,
int pos) |
long |
toLong() |
java.lang.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(java.lang.String addrStr)
Constructs a new EthernetAddress given a string representation of
the ethernet address.
|
public EthernetAddress(java.lang.String addrStr) throws java.lang.NumberFormatException
addrStr
- String representation of the ethernet addressjava.lang.NumberFormatException
public EthernetAddress(byte[] addr) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public EthernetAddress(long addr)
addr
- long that contains the MAC address in 6 least significant
bytes.public java.lang.Object clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
public java.lang.String toString()
toString
in class java.lang.Object
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 java.lang.NumberFormatException
addr
- Binary representation of the ethernet addressjava.lang.NumberFormatException
- if addr is invalid (less or more than
6 bytes in array)public static EthernetAddress valueOf(int[] addr) throws java.lang.NumberFormatException
addr
- Binary representation of the ethernet addressjava.lang.NumberFormatException
- if addr is invalid (less or more than
6 ints in array)public static EthernetAddress valueOf(java.lang.String addrStr) throws java.lang.NumberFormatException
addrStr
- String representation of the ethernet addressjava.lang.NumberFormatException
- if addr representation is invalidpublic static EthernetAddress valueOf(long addr)
addr
- Long int representation of the ethernet addresspublic static void main(java.lang.String[] args)