@Test(expected=IllegalArgumentException.class) public void testLongStringFields() { MACAddress.valueOf("00:01:02:03:04:05:06"); }
public static MACAddress valueOf(String address) { String[] elements = address.split(":"); if (elements.length != MAC_ADDRESS_LENGTH) { throw new IllegalArgumentException( "Specified MAC Address must contain 12 hex digits" + " separated pairwise by :'s."); } byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH]; for (int i = 0; i < MAC_ADDRESS_LENGTH; i++) { String element = elements[i]; addressInBytes[i] = (byte)Integer.parseInt(element, 16); } return new MACAddress(addressInBytes); }
MACAddress { public static MACAddress valueOf(String address) { String[] elements = address.split(":"); if (elements.length != MAC_ADDRESS_LENGTH) { throw new IllegalArgumentException( "Specified MAC Address must contain 12 hex digits" + " separated pairwise by :'s."); } byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH]; for (int i = 0; i < MAC_ADDRESS_LENGTH; i++) { String element = elements[i]; addressInBytes[i] = (byte)Integer.parseInt(element, 16); } return new MACAddress(addressInBytes); } }
MACAddress { public static MACAddress valueOf(String address) { String[] elements = address.split(":"); if (elements.length != MAC_ADDRESS_LENGTH) { throw new IllegalArgumentException( "Specified MAC Address must contain 12 hex digits" + " separated pairwise by :'s."); } byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH]; for (int i = 0; i < MAC_ADDRESS_LENGTH; i++) { String element = elements[i]; addressInBytes[i] = (byte)Integer.parseInt(element, 16); } return new MACAddress(addressInBytes); } MACAddress(byte[] address); }
MACAddress { public static MACAddress valueOf(String address) { String[] elements = address.split(":"); if (elements.length != MAC_ADDRESS_LENGTH) { throw new IllegalArgumentException( "Specified MAC Address must contain 12 hex digits" + " separated pairwise by :'s."); } byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH]; for (int i = 0; i < MAC_ADDRESS_LENGTH; i++) { String element = elements[i]; addressInBytes[i] = (byte)Integer.parseInt(element, 16); } return new MACAddress(addressInBytes); } 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 static MACAddress valueOf(String address) { String[] elements = address.split(":"); if (elements.length != MAC_ADDRESS_LENGTH) { throw new IllegalArgumentException( "Specified MAC Address must contain 12 hex digits" + " separated pairwise by :'s."); } byte[] addressInBytes = new byte[MAC_ADDRESS_LENGTH]; for (int i = 0; i < MAC_ADDRESS_LENGTH; i++) { String element = elements[i]; addressInBytes[i] = (byte)Integer.parseInt(element, 16); } return new MACAddress(addressInBytes); } 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; }