public class Mac extends Object
| Constructor and Description |
|---|
Mac(byte[] macBytes)
Creates an instance representing the MAC address
|
Mac(String macStr)
Creates an instance representing the MAC address
|
| Modifier and Type | Method and Description |
|---|---|
static String |
bytesToMacStr(byte[] macBytes)
Converts MAC address bytes into String
|
byte[] |
getMac()
Returns the MAC address in bytes array
|
String |
getMacString()
Returns the MAC address represented in String
|
static boolean |
isMACValid(byte[] macBytes)
Returns whether the specified MAC bytes array is valid with the following
conditions:
1. |
static byte[] |
macStrToBytes(String macStr)
Converts MAC address String into bytes
|
String |
toString() |
public Mac(byte[] macBytes)
throws MacFormatException
macBytes - The 6-byte MAC address in byte arrayMacFormatException - If the MAC address bytes array specified is not with length 6
or nullpublic Mac(String macStr) throws MacFormatException
macStr - MAC address represented in String seperated by cottons (
:) (e.g. 00:00:00:00:00:00)MacFormatException - If the MAC address does not have a valid format:
does not have a hex (e.g. 0f) in the macStr, or,
does not have 6 hex separated by cottons (:), or, a
null is specified
public byte[] getMac()
public String getMacString()
public static byte[] macStrToBytes(String macStr) throws MacFormatException
macStr - The 6-byte MAC Address (00:00:00:00:00:00) in String separated
by cottons (:)MacFormatException - If the MAC address does not have a valid format:
does not have a hex (e.g. 0f) in the macStr, or,
does not have 6 hex separated by cottons (:), or, a
null is specified
public static boolean isMACValid(byte[] macBytes)
macBytes not nullmacBytes's length is equal to 6macBytes - The byte array to be validatedpublic static String bytesToMacStr(byte[] macBytes) throws MacFormatException
macBytes - The 6-byte MAC Address in byte arrayMacFormatException - If the MAC address bytes array specified is not with length 6
or nullCopyright © 2018. All rights reserved.