Package wol.configuration
Class EthernetAddress
- java.lang.Object
-
- wol.configuration.EthernetAddress
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class EthernetAddress extends Object implements Serializable, Cloneable
This class represents a ethernet address.
An Ethernet Address ia a six octets (48 bits) number that uniquelly identifies every network interface card (NIC). The first three octects (24 bits) are known as the Organizationally Unique Identifier (OUI) and identifies its manufacturer.- Author:
- Steffen Moldaner
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description EthernetAddress(byte[] ethernetAddress)
Create a EthernetAddress based on the provided bytes.EthernetAddress(String ethernetAddress)
Create a EthernetAddress based on the provided address.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
byteToHexString(byte b)
Object
clone()
boolean
equals(Object obj)
int
hashCode()
protected byte[]
parseEthernetAddress(String ethernetAddress)
Parses a String representing an ethernet address into an byte array.byte[]
toBytes()
Returns the byte representation of this ethernet address.String
toString()
-
-
-
Constructor Detail
-
EthernetAddress
public EthernetAddress(String ethernetAddress) throws IllegalEthernetAddressException
Create a EthernetAddress based on the provided address. The address must be 6 hexadecimal values seperated by a colon.
E.g.: 00:50:95:10:95:F5- Parameters:
ethernetAddress
- the ethernet address- Throws:
IllegalArgumentException
- if the ethernet address could not be parsedNullPointerException
- if the ethernet address is nullIllegalEthernetAddressException
-
EthernetAddress
public EthernetAddress(byte[] ethernetAddress) throws IllegalEthernetAddressException
Create a EthernetAddress based on the provided bytes. The byte array must have a length of 6 representing the 48 bit ethernet address.- Parameters:
ethernetAddress
- the bytes. Must have length of 6!- Throws:
IllegalEthernetAddressException
- if ethernet address is of illegal length or nullNullPointerException
- if the ethernet address is null
-
-
Method Detail
-
parseEthernetAddress
protected byte[] parseEthernetAddress(String ethernetAddress) throws IllegalEthernetAddressException
Parses a String representing an ethernet address into an byte array. The String must be a list of 6 hexadecimal bytes, sepeartet by a colon.
Example: 00:50:95:10:95:F5- Parameters:
ethernetAddress
- a String representation of the ethernet address.- Returns:
- a byte array containing the byte representation of the ethernet address
- Throws:
IllegalEthernetAddressException
-
toBytes
public byte[] toBytes()
Returns the byte representation of this ethernet address.- Returns:
- the bytes
-
byteToHexString
protected String byteToHexString(byte b)
-
-