Class EthernetAddress

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public class EthernetAddress
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Cloneable
    This class represents a ethernet address.

    An Ethernet Address ia a six octets (48 bits) number that uniquelly identifies every network interface card (NIC). The first three octects (24 bits) are known as the Organizationally Unique Identifier (OUI) and identifies its manufacturer.
    Author:
    Steffen Moldaner
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      EthernetAddress​(byte[] ethernetAddress)
      Create a EthernetAddress based on the provided bytes.
      EthernetAddress​(java.lang.String ethernetAddress)
      Create a EthernetAddress based on the provided address.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String byteToHexString​(byte b)  
      java.lang.Object clone()  
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      protected byte[] parseEthernetAddress​(java.lang.String ethernetAddress)
      Parses a String representing an ethernet address into an byte array.
      byte[] toBytes()
      Returns the byte representation of this ethernet address.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • EthernetAddress

        public EthernetAddress​(java.lang.String ethernetAddress)
                        throws IllegalEthernetAddressException
        Create a EthernetAddress based on the provided address. The address must be 6 hexadecimal values seperated by a colon.

        E.g.: 00:50:95:10:95:F5
        Parameters:
        ethernetAddress - the ethernet address
        Throws:
        java.lang.IllegalArgumentException - if the ethernet address could not be parsed
        java.lang.NullPointerException - if the ethernet address is null
        IllegalEthernetAddressException
      • EthernetAddress

        public EthernetAddress​(byte[] ethernetAddress)
                        throws IllegalEthernetAddressException
        Create a EthernetAddress based on the provided bytes. The byte array must have a length of 6 representing the 48 bit ethernet address.
        Parameters:
        ethernetAddress - the bytes. Must have length of 6!
        Throws:
        IllegalEthernetAddressException - if ethernet address is of illegal length or null
        java.lang.NullPointerException - if the ethernet address is null
    • Method Detail

      • parseEthernetAddress

        protected byte[] parseEthernetAddress​(java.lang.String ethernetAddress)
                                       throws IllegalEthernetAddressException
        Parses a String representing an ethernet address into an byte array. The String must be a list of 6 hexadecimal bytes, sepeartet by a colon.

        Example: 00:50:95:10:95:F5
        Parameters:
        ethernetAddress - a String representation of the ethernet address.
        Returns:
        a byte array containing the byte representation of the ethernet address
        Throws:
        IllegalEthernetAddressException
      • toBytes

        public byte[] toBytes()
        Returns the byte representation of this ethernet address.
        Returns:
        the bytes
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

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

        protected java.lang.String byteToHexString​(byte b)
      • hashCode

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

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object