com.lukasfeiler.util
Class Int

java.lang.Object
  extended bycom.lukasfeiler.util.Int
Direct Known Subclasses:
IPAddress, Netmask

public class Int
extends java.lang.Object

A 32 Bit Integer. This class allows a bitwise handling of an integer. The integer can be as well separated into 4 octets. This class is also capable of handling the dotted-quad notation (as used for IPv4 addresses).


Constructor Summary
Int(int i)
          Constructor that takes an int value as an argument.
Int(java.lang.String s)
          Constructor that takes the integer in dottet-quad notation as an argument.
 
Method Summary
 boolean allBitsSet()
          Returns whether all bits are set.
 boolean getBit(int bitNumber)
          Returns one of the 32 bits as a boolean value.
 short getOctet(int octetNumber)
          Returns one of the 4 octets as a short value.
 short[] getOctets()
          Returns the 4 octets of the 32 bit integer as a short array.
 int intValue()
          Returns the int value of this instance.
 java.lang.String toBitString()
          Returns all the bits of this integer as a string (e.g. 11000000101010000000000100001010 for -1062731510).
 java.lang.String toString()
          Returns the integer in the dottet-quad notation (e.g. 192.168.1.10).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Int

public Int(java.lang.String s)
    throws InvalidIntOctetException
Constructor that takes the integer in dottet-quad notation as an argument.

Parameters:
s - A string in the dottet-quad notation (e.g. 192.168.1.10).

Int

public Int(int i)
Constructor that takes an int value as an argument.

Method Detail

getOctets

public short[] getOctets()
Returns the 4 octets of the 32 bit integer as a short array.


intValue

public int intValue()
Returns the int value of this instance.


toBitString

public java.lang.String toBitString()
Returns all the bits of this integer as a string (e.g. 11000000101010000000000100001010 for -1062731510).


toString

public java.lang.String toString()
Returns the integer in the dottet-quad notation (e.g. 192.168.1.10).


getOctet

public short getOctet(int octetNumber)
Returns one of the 4 octets as a short value.


getBit

public boolean getBit(int bitNumber)
Returns one of the 32 bits as a boolean value.


allBitsSet

public boolean allBitsSet()
Returns whether all bits are set.