org.arakhne.vmutil
Class MACNumber

java.lang.Object
  extended by org.arakhne.vmutil.MACNumber

public final class MACNumber
extends Object

A MACNumber is the unique number associated to a network interface.

Since:
4.2
Version:
6.3 (rev:285) 2011-10-14 12:02:41
Author:
Stéphane GALLAND
See Also:
NetworkInterface
Maven Group Id:
org.arakhne.afc
Maven Artifact Id:
arakhneVmutils

Field Summary
static char MACNUMBER_SEPARATOR
          Character that is used as separator inside MAC addresses.
static MACNumber NULL
          Constant ethernet address object which has the "null address".
 
Constructor Summary
MACNumber()
          Constructs object with "null values" (address of "0:0:0:0:0:0").
MACNumber(byte[] bytes)
          Build a MACNumber from a set of bytes.
MACNumber(String address)
          Build a MACNumber from a string representation.
 
Method Summary
 boolean equals(Object o)
          
static Collection<MACNumber> getAllAdapters()
          Get all of the ethernet addresses associated with the local machine.
static Map<InetAddress,MACNumber> getAllMappings()
          Get all of the internet address and ethernet address mappings on the local machine.
 byte[] getBytes()
          Replies the bytes that compose this MAC Address.
static MACNumber getPrimaryAdapter()
          Try to determine the primary ethernet address of the machine.
static Collection<InetAddress> getPrimaryAdapterAddresses()
          Try to determine the primary ethernet address of the machine and replies the associated internet addresses.
 int hashCode()
          
 boolean isNull()
          Replies if all the MAC address number are equal to zero.
static String join(MACNumber... addresses)
          Join the specified MAC numbers to reply a string.
static MACNumber[] parse(String addresses)
          Parse the specified string an repleis the corresponding MAC numbers.
static String[] parseAsString(String addresses)
          Parse the specified string an repleis the corresponding MAC numbers.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MACNUMBER_SEPARATOR

public static final char MACNUMBER_SEPARATOR
Character that is used as separator inside MAC addresses.

See Also:
Constant Field Values

NULL

public static final MACNumber NULL
Constant ethernet address object which has the "null address".

This constant can be used when you want a non-null MACAddress object reference, but want a invalid (or null) MAC address contained.

See Also:
isNull()
Constructor Detail

MACNumber

public MACNumber()
Constructs object with "null values" (address of "0:0:0:0:0:0").


MACNumber

public MACNumber(byte[] bytes)
Build a MACNumber from a set of bytes. The byte array must contains 6 elements.

Parameters:
bytes - is the list of bytes from which the address must be built.
Throws:
IllegalArgumentException - if the byte array does not corresponds to a valid MAC Number.

MACNumber

public MACNumber(String address)
Build a MACNumber from a string representation.

Parameters:
address - is the string representation of a MAC address
Throws:
IllegalArgumentException - if the byte array does not corresponds to a valid MAC Number.
See Also:
toString()
Method Detail

parse

public static MACNumber[] parse(String addresses)
Parse the specified string an repleis the corresponding MAC numbers.

Parameters:
addresses - is the string to parse
Returns:
a list of addresses.
Throws:
IllegalArgumentException - is the argument has not the right syntax.

parseAsString

public static String[] parseAsString(String addresses)
Parse the specified string an repleis the corresponding MAC numbers.

Parameters:
addresses - is the string to parse
Returns:
a list of addresses.
Throws:
IllegalArgumentException - is the argument has not the right syntax.

join

public static String join(MACNumber... addresses)
Join the specified MAC numbers to reply a string.

Parameters:
addresses - is the list of mac addresses to join.
Returns:
the joined string.

getAllAdapters

public static Collection<MACNumber> getAllAdapters()
Get all of the ethernet addresses associated with the local machine.

This method will try and find ALL of the ethernet adapters which are currently available on the system. This is heavily OS dependent and may not be supported on all platforms. When not supported, you should still get back a collection with the primary adapter in it.

Returns:
the list of MAC numbers associated to the physical devices.
See Also:
getPrimaryAdapter()

getAllMappings

public static Map<InetAddress,MACNumber> getAllMappings()
Get all of the internet address and ethernet address mappings on the local machine.

This method will try and find ALL of the ethernet adapters which are currently available on the system. This is heavily OS dependent and may not be supported on all platforms. When not supported, you should still get back a collection with the primary adapter in it.

Returns:
the map internet address and ethernet address mapping.
See Also:
getPrimaryAdapterAddresses()

getPrimaryAdapter

public static MACNumber getPrimaryAdapter()
Try to determine the primary ethernet address of the machine.

Returns:
the primary MACNumber or null

getPrimaryAdapterAddresses

public static Collection<InetAddress> getPrimaryAdapterAddresses()
Try to determine the primary ethernet address of the machine and replies the associated internet addresses.

Returns:
the internet addresses of the primary network interface.

equals

public boolean equals(Object o)

Overrides:
equals in class Object
Parameters:
o -
Returns:

hashCode

public int hashCode()

Overrides:
hashCode in class Object
Returns:

toString

public String toString()

Overrides:
toString in class Object
Returns:

isNull

public boolean isNull()
Replies if all the MAC address number are equal to zero.

Returns:
true if all the bytes are zero.
See Also:
NULL

getBytes

public byte[] getBytes()
Replies the bytes that compose this MAC Address.

Returns:
a copy of the current bytes.


Copyright © 2006-2011 Arakhnê.org Consortium. All rights reserved under LGPL license terms.