net.floodlightcontroller.util
Class MACAddress

java.lang.Object
  extended by net.floodlightcontroller.util.MACAddress

public class MACAddress
extends java.lang.Object

The class representing MAC address.

Author:
Sho Shimizu (sho.shimizu@gmail.com)

Field Summary
static int MAC_ADDRESS_LENGTH
           
 
Constructor Summary
MACAddress(byte[] address)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 boolean isBroadcast()
          Returns true if the MAC address is the broadcast address.
 boolean isMulticast()
          Returns true if the MAC address is the multicast address.
 int length()
          Returns the length of the MACAddress.
 byte[] toBytes()
          Returns the value of the MACAddress as a byte array.
 long toLong()
          Returns the value of the MACAddress as a long.
 java.lang.String toString()
           
static MACAddress valueOf(byte[] address)
          Returns a MAC address instance representing the specified byte array.
static MACAddress valueOf(long address)
          Returns a MAC address instance representing the specified long value.
static MACAddress valueOf(java.lang.String address)
          Returns a MAC address instance representing the value of the specified String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAC_ADDRESS_LENGTH

public static final int MAC_ADDRESS_LENGTH
See Also:
Constant Field Values
Constructor Detail

MACAddress

public MACAddress(byte[] address)
Method Detail

valueOf

public static MACAddress valueOf(java.lang.String address)
Returns a MAC address instance representing the value of the specified String.

Parameters:
address - the String representation of the MAC Address to be parsed.
Returns:
a MAC Address instance representing the value of the specified String.
Throws:
java.lang.IllegalArgumentException - if the string cannot be parsed as a MAC address.

valueOf

public static MACAddress valueOf(byte[] address)
Returns a MAC address instance representing the specified byte array.

Parameters:
address - the byte array to be parsed.
Returns:
a MAC address instance representing the specified byte array.
Throws:
java.lang.IllegalArgumentException - if the byte array cannot be parsed as a MAC address.

valueOf

public static MACAddress valueOf(long address)
Returns a MAC address instance representing the specified long value. The lower 48 bits of the long value are used to parse as a MAC address.

Parameters:
address - the long value to be parsed. The lower 48 bits are used for a MAC address.
Returns:
a MAC address instance representing the specified long value.
Throws:
java.lang.IllegalArgumentException - if the long value cannot be parsed as a MAC address.

length

public int length()
Returns the length of the MACAddress.

Returns:
the length of the MACAddress.

toBytes

public byte[] toBytes()
Returns the value of the MACAddress as a byte array.

Returns:
the numeric value represented by this object after conversion to type byte array.

toLong

public long toLong()
Returns the value of the MACAddress as a long.

Returns:
the numeric value represented by this object after conversion to type long.

isBroadcast

public boolean isBroadcast()
Returns true if the MAC address is the broadcast address.

Returns:
true if the MAC address is the broadcast address.

isMulticast

public boolean isMulticast()
Returns true if the MAC address is the multicast address.

Returns:
true if the MAC address is the multicast address.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object