|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.net.EthernetMacAddress
public class EthernetMacAddress
This class stores an ethernet MAC (hardware) address as a byte[].
To get a machine's Ethernet MAC (Hardware) Address using DOS (is unix similar?):
1) from a command line, ping the target machine; for example: ping 192.168.1.101 (So, you need to know the target machine's hostname or ip address before can do this.) 2) then execute arp -a on the command line to list the ip-->mac address table; for example, should see output like Interface: 192.168.1.100 --- 0x2 Internet Address Physical Address Type 192.168.1.101 00-03-47-73-dd-a5 dynamic
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Nested Class Summary | |
---|---|
static class |
EthernetMacAddress.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Field Summary | |
---|---|
private byte[] |
bytes
Array of 6 bytes which stores the 48 bit ethernet MAC address. |
static char |
byteSeparatorChar
Preferred char used to separate the bytes in an ethernet MAC address's String representation. |
Constructor Summary | |
---|---|
EthernetMacAddress(String address)
Constructor which parse the bytes from a String valued address. |
Method Summary | |
---|---|
static String |
byteToString(byte b)
|
byte[] |
getBytes()
Returns a clone of the internal byte[] (to maintain encapsulation). |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final char byteSeparatorChar
There appear to be 2 conventions: a dash (i.e. '-') or a colon (i.e. ':') char. The value of this constant is a dash (i.e. '-'), because that is what Windows uses.
private final byte[] bytes
Constructor Detail |
---|
public EthernetMacAddress(String address) throws IllegalArgumentException, NumberFormatException
IllegalArgumentException
- if address is blank; address.length() != 17; address does not split into 6 tokens (bytes)
NumberFormatException
- if one of the byte tokens is not a byte in hexadecimal formatMethod Detail |
---|
public byte[] getBytes()
public String toString()
toString
in class Object
public static String byteToString(byte b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |