@Test public void testToLong() { assertEquals( 281474976710655L, MACAddress.valueOf(new byte[]{(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}).toLong()); assertEquals( 1103823438081L, MACAddress.valueOf(new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01 }).toLong()); assertEquals( 141289400074368L, MACAddress.valueOf(new byte[] { (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80 }).toLong()); }
public long toLong() { long mac = 0; for (int i = 0; i < 6; i++) { long t = (address[i] & 0xffL) << ((5 - i) * 8); mac |= t; } return mac; }
MACAddress { public long toLong() { long mac = 0; for (int i = 0; i < 6; i++) { long t = (address[i] & 0xffL) << ((5 - i) * 8); mac |= t; } return mac; } }
MACAddress { public long toLong() { long mac = 0; for (int i = 0; i < 6; i++) { long t = (address[i] & 0xffL) << ((5 - i) * 8); mac |= t; } return mac; } MACAddress(byte[] address); }
MACAddress { public long toLong() { long mac = 0; for (int i = 0; i < 6; i++) { long t = (address[i] & 0xffL) << ((5 - i) * 8); mac |= t; } return mac; } MACAddress(byte[] address); static MACAddress valueOf(String address); static MACAddress valueOf(byte[] address); static MACAddress valueOf(long address); int length(); byte[] toBytes(); long toLong(); boolean isBroadcast(); boolean isMulticast(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
MACAddress { public long toLong() { long mac = 0; for (int i = 0; i < 6; i++) { long t = (address[i] & 0xffL) << ((5 - i) * 8); mac |= t; } return mac; } MACAddress(byte[] address); static MACAddress valueOf(String address); static MACAddress valueOf(byte[] address); static MACAddress valueOf(long address); int length(); byte[] toBytes(); long toLong(); boolean isBroadcast(); boolean isMulticast(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final int MAC_ADDRESS_LENGTH; }