/** * Default cloning behaviour (bitwise copy) is just fine... */ public Object clone() { return new EthernetAddress(_address); }
/** * Constructs a new EthernetAddress given the long int value (64-bit) * representation of the ethernet address (of which 48 LSB contain * the definition) * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addr Long int representation of the ethernet address */ public static EthernetAddress valueOf(long addr) { return new EthernetAddress(addr); }
/** * Constructs a new EthernetAddress given a string representation of * the ethernet address. * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addrStr String representation of the ethernet address * * @throws NumberFormatException if addr representation is invalid */ public static EthernetAddress valueOf(String addrStr) throws NumberFormatException { return new EthernetAddress(addrStr); }
/** * Constructs a new EthernetAddress given the byte array that contains * binary representation of the address. * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addr Binary representation of the ethernet address * * @throws NumberFormatException if addr is invalid (less or more than * 6 bytes in array) */ public static EthernetAddress valueOf(byte[] addr) throws NumberFormatException { return new EthernetAddress(addr); }
/** * Constructs a new EthernetAddress given the byte array that contains * binary representation of the address. * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addr Binary representation of the ethernet address * * @throws NumberFormatException if addr is invalid (less or more than * 6 ints in array) */ public static EthernetAddress valueOf(int[] addr) throws NumberFormatException { byte[] bAddr = new byte[addr.length]; for (int i = 0; i < addr.length; ++i) { bAddr[i] = (byte) addr[i]; } return new EthernetAddress(bAddr); }
/** * Factory method that can be used to construct a random multicast * address; to be used in cases where there is no "real" ethernet * address to use. Address to generate should be a multicase address * to avoid accidental collision with real manufacturer-assigned * MAC addresses. *<p> * Address is created using specified random number generator. */ public static EthernetAddress constructMulticastAddress(Random rnd) { byte[] dummy = new byte[6]; synchronized (rnd) { rnd.nextBytes(dummy); } /* Need to set the broadcast bit to indicate it's not a real * address. */ /* 20-May-2010, tatu: Actually, we could use both second least-sig-bit * ("locally administered") or the LSB (multicast), as neither is * ever set for 'real' addresses. * Since UUID specs recommends latter, use that. */ dummy[0] |= (byte) 0x01; return new EthernetAddress(dummy); }
byte[] data = nint.getHardwareAddress(); if (data != null && data.length == 6) { return new EthernetAddress(data);
/** * Default cloning behaviour (bitwise copy) is just fine... */ public Object clone() { return new EthernetAddress(_address); }
/** * Constructs a new EthernetAddress given the long int value (64-bit) * representation of the ethernet address (of which 48 LSB contain * the definition) * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addr Long int representation of the ethernet address */ public static EthernetAddress valueOf(long addr) { return new EthernetAddress(addr); }
/** * Constructs a new EthernetAddress given a string representation of * the ethernet address. * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addrStr String representation of the ethernet address * * @throws NumberFormatException if addr representation is invalid */ public static EthernetAddress valueOf(String addrStr) throws NumberFormatException { return new EthernetAddress(addrStr); }
/** * Constructs a new EthernetAddress given the byte array that contains * binary representation of the address. * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addr Binary representation of the ethernet address * * @throws NumberFormatException if addr is invalid (less or more than * 6 bytes in array) */ public static EthernetAddress valueOf(byte[] addr) throws NumberFormatException { return new EthernetAddress(addr); }
/** * Constructs a new EthernetAddress given the byte array that contains * binary representation of the address. * * Note that calling this method returns the same result as would * using the matching constructor. * * @param addr Binary representation of the ethernet address * * @throws NumberFormatException if addr is invalid (less or more than * 6 ints in array) */ public static EthernetAddress valueOf(int[] addr) throws NumberFormatException { byte[] bAddr = new byte[addr.length]; for (int i = 0; i < addr.length; ++i) { bAddr[i] = (byte) addr[i]; } return new EthernetAddress(bAddr); }
/** * Factory method that can be used to construct a random multicast * address; to be used in cases where there is no "real" ethernet * address to use. Address to generate should be a multicase address * to avoid accidental collision with real manufacturer-assigned * MAC addresses. *<p> * Address is created using specified random number generator. */ public static EthernetAddress constructMulticastAddress(Random rnd) { byte[] dummy = new byte[6]; synchronized (rnd) { rnd.nextBytes(dummy); } /* Need to set the broadcast bit to indicate it's not a real * address. */ /* 20-May-2010, tatu: Actually, we could use both second least-sig-bit * ("locally administered") or the LSB (multicast), as neither is * ever set for 'real' addresses. * Since UUID specs recommends latter, use that. */ dummy[0] |= (byte) 0x01; return new EthernetAddress(dummy); }
byte[] data = nint.getHardwareAddress(); if (data != null && data.length == 6) { return new EthernetAddress(data);