- java.lang.Object
-
- org.arakhne.afc.vmutil.MACNumber
-
public final class MACNumber extends Object
A MACNumber is the unique number associated to a network interface.- Since:
- 4.2
- Version:
- 17.0 2020-01-04 14:41:35
- Author:
- Stéphane GALLAND
- See Also:
NetworkInterface
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- vmutils
-
-
Field Summary
Fields Modifier and Type Field Description 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".
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
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()
-
-
-
Field Detail
-
MACNUMBER_SEPARATOR
public static final char MACNUMBER_SEPARATOR
Character that is used as separator inside MAC addresses.- See Also:
- Constant Field Values
-
-
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
@Pure 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
@Pure 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
@Pure 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
@Pure 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
@Pure 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
@Pure public static MACNumber getPrimaryAdapter()
Try to determine the primary ethernet address of the machine.- Returns:
- the primary MACNumber or
null
-
getPrimaryAdapterAddresses
@Pure 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.
-
isNull
@Pure 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
@Pure public byte[] getBytes()
Replies the bytes that compose this MAC Address.- Returns:
- a copy of the current bytes.
-
-