SSF.OS.OSPF
Class BinInt

java.lang.Object
  |
  +--SSF.OS.OSPF.BinInt

public class BinInt
extends java.lang.Object


Constructor Summary
BinInt()
           
 
Method Summary
static int binToInt(boolean[] bin)
          returns the int value of a binary (boolean) array, which has the least significant bit on the left ( boolean [0] )
static java.lang.String binToStr(boolean[] bin)
          Converts the given boolean array into a String of 0's and 1's.
static java.lang.String binToStr(boolean[] bin, int length)
          Converts a given boolean array into a String of 0's and 1's, but only up to a certain length.
static boolean[] intToBin(int v)
          Returns the binary value of this int in a boolean [32], with the least significant bit on the left ( boolean [0] ), e.g.
static boolean[] intToBin(int v, int len)
          returns the binary value of this int in a boolean [] of the specified length, with the least significant bit on the left ( boolean [0] ) e.g.
static boolean[] intToBinPrefix(int v, int prefixLen)
          returns the binary "prefix value" of this int in a boolean [] of length prefixLen, with the least significant bit on the left ( boolean [0] ); what this means is that it's as if v were put into a boolean array of size 32, and then it was chopped down to the appropriate size (prefixLen) by removing 32-prefixLen elements from the beginning of the array (remember that the least significant bits are at the beginning); intToBin(int,int) behaves the same way, except that it removes elements from the end of the array An example: intToBinPrefix(256,28) first, we get this boolean[32]: 00000000 10000000 00000000 00000000 then, chop it to a boolean[28]: 0000 10000000 00000000 00000000 whereas intToBin(256,28) would result in this boolean[28]: 00000000 10000000 00000000 0000 if we reverse the order of the array elements, the results of a call to intToBinPrefix(int,int) looks like an IP prefix for example, 00000000 00000000 00000001 0000 = 0.0.1.0/28 (note that intToBin(int,int) should *not* be used to get IP prefixes, since it "chops off" the most significant bits, not the least significant)
static boolean[] invertBin(boolean[] bin)
           
static int rightBinLength(int blockSize)
          Returns, in the power of 2, the appropriate IP address block size for the specified block size, eg, 7 and 8 returns 3
static int rightBlock(int blockSize)
          returns the next largest integer which is a power of 2, e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinInt

public BinInt()
Method Detail

invertBin

public static boolean[] invertBin(boolean[] bin)

intToBin

public static boolean[] intToBin(int v)
Returns the binary value of this int in a boolean [32], with the least significant bit on the left ( boolean [0] ), e.g. intToBin(10) gives 01010000000000000000000000000000


intToBin

public static boolean[] intToBin(int v,
                                 int len)
returns the binary value of this int in a boolean [] of the specified length, with the least significant bit on the left ( boolean [0] ) e.g. intToBin (64) returns 00000010 00000000 00000000 00000000 e.g. intToBin (64, 26) returns 00000010 00000000 00000000 00


intToBinPrefix

public static boolean[] intToBinPrefix(int v,
                                       int prefixLen)
returns the binary "prefix value" of this int in a boolean [] of length prefixLen, with the least significant bit on the left ( boolean [0] ); what this means is that it's as if v were put into a boolean array of size 32, and then it was chopped down to the appropriate size (prefixLen) by removing 32-prefixLen elements from the beginning of the array (remember that the least significant bits are at the beginning); intToBin(int,int) behaves the same way, except that it removes elements from the end of the array An example: intToBinPrefix(256,28) first, we get this boolean[32]: 00000000 10000000 00000000 00000000 then, chop it to a boolean[28]: 0000 10000000 00000000 00000000 whereas intToBin(256,28) would result in this boolean[28]: 00000000 10000000 00000000 0000 if we reverse the order of the array elements, the results of a call to intToBinPrefix(int,int) looks like an IP prefix for example, 00000000 00000000 00000001 0000 = 0.0.1.0/28 (note that intToBin(int,int) should *not* be used to get IP prefixes, since it "chops off" the most significant bits, not the least significant)


binToInt

public static int binToInt(boolean[] bin)
returns the int value of a binary (boolean) array, which has the least significant bit on the left ( boolean [0] )


binToStr

public static java.lang.String binToStr(boolean[] bin)
Converts the given boolean array into a String of 0's and 1's.


binToStr

public static java.lang.String binToStr(boolean[] bin,
                                        int length)
Converts a given boolean array into a String of 0's and 1's, but only up to a certain length.


rightBlock

public static int rightBlock(int blockSize)
returns the next largest integer which is a power of 2, e.g. if blockSize = 384 will return 512


rightBinLength

public static int rightBinLength(int blockSize)
Returns, in the power of 2, the appropriate IP address block size for the specified block size, eg, 7 and 8 returns 3