com.limegroup.gnutella.filters
Class IP

java.lang.Object
  extended bycom.limegroup.gnutella.filters.IP

public class IP
extends java.lang.Object

An IP address. More precisely, a set of IP addresses specified by a regular expression (e.g., "18.239.*.*") or a submask (e.g., "18.239.0.0/255.255.0.0". Immutable. Used to implement IPFilter; the generic usefulness of this class is questionable. This class is heavily optimized, as IP objects are constructed for every PingReply, QueryReply, PushRequest, and internally or externally generated connection.


Constructor Summary
IP(byte[] ip_bytes)
          Creates an IP object out of a four byte array of the IP in BIG ENDIAN format (most significant byte first).
IP(java.lang.String ip_str)
          Creates an IP object out of a String in the format "0.0.0.0", "0.0.0.0/0.0.0.0" or "0.0.0.0/0"
 
Method Summary
 boolean contains(IP ip)
          Returns if ip is contained in this.
 boolean equals(java.lang.Object other)
          Returns true if other is an IP with the same address and mask.
 int hashCode()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IP

public IP(byte[] ip_bytes)
   throws java.lang.IllegalArgumentException
Creates an IP object out of a four byte array of the IP in BIG ENDIAN format (most significant byte first).


IP

public IP(java.lang.String ip_str)
   throws java.lang.IllegalArgumentException
Creates an IP object out of a String in the format "0.0.0.0", "0.0.0.0/0.0.0.0" or "0.0.0.0/0"

Parameters:
ip_str - a String of the format "0.0.0.0", "0.0.0.0/0.0.0.0", or "0.0.0.0/0" as an argument.
Method Detail

contains

public boolean contains(IP ip)
Returns if ip is contained in this.

Parameters:
ip - a singleton IP set, e.g., one representing a single address

equals

public boolean equals(java.lang.Object other)
Returns true if other is an IP with the same address and mask. Note that "1.1.1.1/255.255.255.255" does not equal "2.2.2.2/255.255.255.255", even though they denote the same sets of addresses.


hashCode

public int hashCode()