Class IPaddress
java.lang.Object
|
+----IPaddress
- public class IPaddress
- extends Object
This class implements an IP address. An IP address is wrapped around in a
class to allow easy changes to its representation later. The current
representation is a 32-bit int, which is represented internally in
two's-complement.
-
IPaddress()
- Constructs an IP address with a random IP value
-
IPaddress(int)
- Constructs an IP address with the given short array
-
IPaddress(int, byte)
- Constructs an IP address with the given short array and the subnet
mask bits, which can range from 1 to 32
-
IPaddress(int, int)
- Constructs an IP address with the given short array and the subnet
mask bits, which can range from 1 to 32
-
equals(IPaddress)
- returns true if the given ip value is the same, false otherwise
-
get()
- Returns the value of this IP address
-
getIncremented(int)
- Returns a new IP address which value is this address incremented
by a certain value
-
getMask()
- Returns the number of bits in the mask
-
identical(IPaddress)
- compares with another IP to see if they are identical
-
increment(int)
- Increments this IP address by a certain value
-
mask(byte)
- Returns an IP address taking the last b bits of this IP address
-
mask(int)
- Returns an IP address taking the last b bits of this IP address
-
next()
- Increments this IP address
-
printBinary()
- Prints the binary value of this IP address
-
samePrefix(IPaddress)
- Returns true if this IP address and the given IP address has the same
prefix.
-
set(int)
- Sets the value of this IP address
-
set(IPaddress)
- Sets this IP to the same as another IP
-
setMask(byte)
- Sets the number of bits in the mask
-
toString()
- Prints the A.B.C.D representation of this IP address.
-
toStringNoMask()
- Prints the A.B.C.D representation of this IP, without mask.
IPaddress
public IPaddress(int ip)
- Constructs an IP address with the given short array
IPaddress
public IPaddress(int ip,
byte maskBits)
- Constructs an IP address with the given short array and the subnet
mask bits, which can range from 1 to 32
IPaddress
public IPaddress(int ip,
int maskBits)
- Constructs an IP address with the given short array and the subnet
mask bits, which can range from 1 to 32
IPaddress
public IPaddress()
- Constructs an IP address with a random IP value
get
public int get()
- Returns the value of this IP address
set
public void set(int s)
- Sets the value of this IP address
set
public void set(IPaddress ip)
- Sets this IP to the same as another IP
setMask
public void setMask(byte m)
- Sets the number of bits in the mask
getMask
public byte getMask()
- Returns the number of bits in the mask
next
public IPaddress next()
- Increments this IP address
getIncremented
public IPaddress getIncremented(int block)
- Returns a new IP address which value is this address incremented
by a certain value
increment
public void increment(int block)
- Increments this IP address by a certain value
equals
public boolean equals(IPaddress ip)
- returns true if the given ip value is the same, false otherwise
identical
public boolean identical(IPaddress ipaddr)
- compares with another IP to see if they are identical
samePrefix
public boolean samePrefix(IPaddress otherIP)
- Returns true if this IP address and the given IP address has the same
prefix.
mask
public int mask(int bin)
- Returns an IP address taking the last b bits of this IP address
mask
public int mask(byte bin)
- Returns an IP address taking the last b bits of this IP address
printBinary
public void printBinary()
- Prints the binary value of this IP address
toStringNoMask
public String toStringNoMask()
- Prints the A.B.C.D representation of this IP, without mask.
toString
public String toString()
- Prints the A.B.C.D representation of this IP address.
- Overrides:
- toString in class Object