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.


Constructor Index

 o IPaddress()
Constructs an IP address with a random IP value
 o IPaddress(int)
Constructs an IP address with the given short array
 o IPaddress(int, byte)
Constructs an IP address with the given short array and the subnet mask bits, which can range from 1 to 32
 o IPaddress(int, int)
Constructs an IP address with the given short array and the subnet mask bits, which can range from 1 to 32

Method Index

 o equals(IPaddress)
returns true if the given ip value is the same, false otherwise
 o get()
Returns the value of this IP address
 o getIncremented(int)
Returns a new IP address which value is this address incremented by a certain value
 o getMask()
Returns the number of bits in the mask
 o identical(IPaddress)
compares with another IP to see if they are identical
 o increment(int)
Increments this IP address by a certain value
 o mask(byte)
Returns an IP address taking the last b bits of this IP address
 o mask(int)
Returns an IP address taking the last b bits of this IP address
 o next()
Increments this IP address
 o printBinary()
Prints the binary value of this IP address
 o samePrefix(IPaddress)
Returns true if this IP address and the given IP address has the same prefix.
 o set(int)
Sets the value of this IP address
 o set(IPaddress)
Sets this IP to the same as another IP
 o setMask(byte)
Sets the number of bits in the mask
 o toString()
Prints the A.B.C.D representation of this IP address.
 o toStringNoMask()
Prints the A.B.C.D representation of this IP, without mask.

Constructors

 o IPaddress
 public IPaddress(int ip)
Constructs an IP address with the given short array

 o 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

 o 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

 o IPaddress
 public IPaddress()
Constructs an IP address with a random IP value

Methods

 o get
 public int get()
Returns the value of this IP address

 o set
 public void set(int s)
Sets the value of this IP address

 o set
 public void set(IPaddress ip)
Sets this IP to the same as another IP

 o setMask
 public void setMask(byte m)
Sets the number of bits in the mask

 o getMask
 public byte getMask()
Returns the number of bits in the mask

 o next
 public IPaddress next()
Increments this IP address

 o getIncremented
 public IPaddress getIncremented(int block)
Returns a new IP address which value is this address incremented by a certain value

 o increment
 public void increment(int block)
Increments this IP address by a certain value

 o equals
 public boolean equals(IPaddress ip)
returns true if the given ip value is the same, false otherwise

 o identical
 public boolean identical(IPaddress ipaddr)
compares with another IP to see if they are identical

 o samePrefix
 public boolean samePrefix(IPaddress otherIP)
Returns true if this IP address and the given IP address has the same prefix.

 o mask
 public int mask(int bin)
Returns an IP address taking the last b bits of this IP address

 o mask
 public int mask(byte bin)
Returns an IP address taking the last b bits of this IP address

 o printBinary
 public void printBinary()
Prints the binary value of this IP address

 o toStringNoMask
 public String toStringNoMask()
Prints the A.B.C.D representation of this IP, without mask.

 o toString
 public String toString()
Prints the A.B.C.D representation of this IP address.

Overrides:
toString in class Object