Class MacAddress

java.lang.Object
org.netxms.base.MacAddress

public class MacAddress extends Object
MAC address representation
  • Constructor Details

    • MacAddress

      public MacAddress()
      Create MAC address with value of 00:00:00:00:00:00
    • MacAddress

      public MacAddress(byte[] src)
      Create MAC address object from byte array
      Parameters:
      src - byte array containing MAC address value
    • MacAddress

      public MacAddress(byte[] src, int maxLength)
      Create MAC address object from byte array. Any bytes beyond maxLength will be droppped.
      Parameters:
      src - byte array containing MAC address value
      maxLength - maximum possible MAC address length.
  • Method Details

    • isNull

      public boolean isNull()
      Check if MAC address is all zeroes
      Returns:
      true if MAC address is all zeroes
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • parseMacAddress

      public static MacAddress parseMacAddress(String str) throws MacAddressFormatException
      Parse MAC address string representation. Supported representations are 6 groups of two hex digits, separated by spaces, minuses, or colons; or 4 groups of three hex digits separated by dots; or 12 non-separated digits; or 16 non-separated hex digits. Examples of valid MAC address strings: 00:10:FA:23:11:7A 01 02 fa c4 10 dc 00-90-0b-11-01-29 009.00b.110.129 0203fcd456c1 0203FCD465C1DF56
      Parameters:
      str - MAC address string
      Returns:
      MAC address object
      Throws:
      MacAddressFormatException - if MAC address sting is invalid
    • parseMacAddress

      public static MacAddress parseMacAddress(String str, boolean fullMac) throws MacAddressFormatException
      Parse MAC address string representation. Supported representations are 6 groups of two hex digits, separated by spaces, minuses, or colons; or 4 groups of three hex digits separated by dots; or 12 non-separated digits; or 16 non-separated hex digits. Examples of valid MAC address strings: 00:10:FA:23:11:7A 01 02 fa c4 10 dc 00-90-0b-11-01-29 009.00b.110.129 0203fcd456c1 0203FCD465C1DF56 For partial MAC match at least two pairs is required or odd number of triples
      Parameters:
      str - MAC address string
      fullMac - if should match full mac address
      Returns:
      MAC address object
      Throws:
      MacAddressFormatException - if MAC address sting is invalid
    • getValue

      public byte[] getValue()
      Returns:
      the value
    • compareTo

      public int compareTo(MacAddress dst)
      Compare this MAC address to another MAC address.
      Parameters:
      dst - another @see MacAddress to be compared with.
      Returns:
      0 if two MAC addresses are equal, negative if this MAC address is "lower", and positive if "higher"