@Test public final void testSet() throws InvalidAddressException { IPv4 ip = null; ip = new IPv4("255.255.255.255"); byte[] b = new byte[4]; for (int i = 0; i < 4; i++) { b[i] = (byte)0xFF; } IPv4 ip2 = new IPv4(b); assertEquals(ip, ip2); }
public void set(String ipAddress) throws InvalidAddressException { StringTokenizer tokenizer = new StringTokenizer(ipAddress); String token; for (int i = 0; i < 4; i++) { token = tokenizer.nextToken("."); if (token == null) { throw new InvalidAddressException(); } else if (Integer.valueOf(token) < 0 || Integer.valueOf(token) > 255) { throw new InvalidAddressException(); } this.ipBytes[i] = (byte)(((Integer.valueOf(token) << 24) >> 24) & 0xFF); } }
IPv4 implements Writable, Comparable<IPv4> { public void set(String ipAddress) throws InvalidAddressException { StringTokenizer tokenizer = new StringTokenizer(ipAddress); String token; for (int i = 0; i < 4; i++) { token = tokenizer.nextToken("."); if (token == null) { throw new InvalidAddressException(); } else if (Integer.valueOf(token) < 0 || Integer.valueOf(token) > 255) { throw new InvalidAddressException(); } this.ipBytes[i] = (byte)(((Integer.valueOf(token) << 24) >> 24) & 0xFF); } } }
IPv4 implements Writable, Comparable<IPv4> { public void set(String ipAddress) throws InvalidAddressException { StringTokenizer tokenizer = new StringTokenizer(ipAddress); String token; for (int i = 0; i < 4; i++) { token = tokenizer.nextToken("."); if (token == null) { throw new InvalidAddressException(); } else if (Integer.valueOf(token) < 0 || Integer.valueOf(token) > 255) { throw new InvalidAddressException(); } this.ipBytes[i] = (byte)(((Integer.valueOf(token) << 24) >> 24) & 0xFF); } } IPv4();  IPv4(byte[] bytes);  IPv4(String ipAddress); }
IPv4 implements Writable, Comparable<IPv4> { public void set(String ipAddress) throws InvalidAddressException { StringTokenizer tokenizer = new StringTokenizer(ipAddress); String token; for (int i = 0; i < 4; i++) { token = tokenizer.nextToken("."); if (token == null) { throw new InvalidAddressException(); } else if (Integer.valueOf(token) < 0 || Integer.valueOf(token) > 255) { throw new InvalidAddressException(); } this.ipBytes[i] = (byte)(((Integer.valueOf(token) << 24) >> 24) & 0xFF); } } IPv4();  IPv4(byte[] bytes);  IPv4(String ipAddress); static IPv4 getSubnetMask(int len); void set(String ipAddress); void set(byte[] bytes); byte[] getBytes(); boolean matchSubnet(String addr); boolean matchGeoIP(/* country code */); IPv4 and(IPv4 other); @Override boolean equals(Object o); @Override int compareTo(IPv4 o); @Override String toString(); @Override int hashCode(); @Override void readFields(DataInput in); @Override void write(DataOutput out); }
IPv4 implements Writable, Comparable<IPv4> { public void set(String ipAddress) throws InvalidAddressException { StringTokenizer tokenizer = new StringTokenizer(ipAddress); String token; for (int i = 0; i < 4; i++) { token = tokenizer.nextToken("."); if (token == null) { throw new InvalidAddressException(); } else if (Integer.valueOf(token) < 0 || Integer.valueOf(token) > 255) { throw new InvalidAddressException(); } this.ipBytes[i] = (byte)(((Integer.valueOf(token) << 24) >> 24) & 0xFF); } } IPv4();  IPv4(byte[] bytes);  IPv4(String ipAddress); static IPv4 getSubnetMask(int len); void set(String ipAddress); void set(byte[] bytes); byte[] getBytes(); boolean matchSubnet(String addr); boolean matchGeoIP(/* country code */); IPv4 and(IPv4 other); @Override boolean equals(Object o); @Override int compareTo(IPv4 o); @Override String toString(); @Override int hashCode(); @Override void readFields(DataInput in); @Override void write(DataOutput out);  }