org.openflow.util
Class Unsigned

java.lang.Object
  extended by org.openflow.util.Unsigned

public class Unsigned
extends java.lang.Object

A util library class for dealing with the lack of unsigned datatypes in Java

Author:
Rob Sherwood (rob.sherwood@stanford.edu), David Erickson (daviderickson@cs.stanford.edu)

Constructor Summary
Unsigned()
           
 
Method Summary
static short getUnsignedByte(java.nio.ByteBuffer bb)
          Get an unsigned byte from the current position of the ByteBuffer
static short getUnsignedByte(java.nio.ByteBuffer bb, int offset)
          Get an unsigned byte from the specified offset in the ByteBuffer
static long getUnsignedInt(java.nio.ByteBuffer bb)
          Get an unsigned int from the current position of the ByteBuffer
static long getUnsignedInt(java.nio.ByteBuffer bb, int offset)
          Get an unsigned int from the specified offset in the ByteBuffer
static java.math.BigInteger getUnsignedLong(java.nio.ByteBuffer bb)
          Get an unsigned long from the current position of the ByteBuffer
static java.math.BigInteger getUnsignedLong(java.nio.ByteBuffer bb, int offset)
          Get an unsigned long from the specified offset in the ByteBuffer
static int getUnsignedShort(java.nio.ByteBuffer bb)
          Get an unsigned short from the current position of the ByteBuffer
static int getUnsignedShort(java.nio.ByteBuffer bb, int offset)
          Get an unsigned short from the specified offset in the ByteBuffer
static void putUnsignedByte(java.nio.ByteBuffer bb, short v)
          Put an unsigned byte into the specified ByteBuffer at the current position
static void putUnsignedByte(java.nio.ByteBuffer bb, short v, int offset)
          Put an unsigned byte into the specified ByteBuffer at the specified offset
static void putUnsignedInt(java.nio.ByteBuffer bb, long v)
          Put an unsigned int into the specified ByteBuffer at the current position
static void putUnsignedInt(java.nio.ByteBuffer bb, long v, int offset)
          Put an unsigned int into the specified ByteBuffer at the specified offset
static void putUnsignedLong(java.nio.ByteBuffer bb, java.math.BigInteger v)
          Put an unsigned long into the specified ByteBuffer at the current position
static void putUnsignedLong(java.nio.ByteBuffer bb, java.math.BigInteger v, int offset)
          Put an unsigned long into the specified ByteBuffer at the specified offset
static void putUnsignedShort(java.nio.ByteBuffer bb, int v)
          Put an unsigned short into the specified ByteBuffer at the current position
static void putUnsignedShort(java.nio.ByteBuffer bb, int v, int offset)
          Put an unsigned short into the specified ByteBuffer at the specified offset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Unsigned

public Unsigned()
Method Detail

getUnsignedByte

public static short getUnsignedByte(java.nio.ByteBuffer bb)
Get an unsigned byte from the current position of the ByteBuffer

Parameters:
bb - ByteBuffer to get the byte from
Returns:
an unsigned byte contained in a short

getUnsignedByte

public static short getUnsignedByte(java.nio.ByteBuffer bb,
                                    int offset)
Get an unsigned byte from the specified offset in the ByteBuffer

Parameters:
bb - ByteBuffer to get the byte from
offset - the offset to get the byte from
Returns:
an unsigned byte contained in a short

putUnsignedByte

public static void putUnsignedByte(java.nio.ByteBuffer bb,
                                   short v)
Put an unsigned byte into the specified ByteBuffer at the current position

Parameters:
bb - ByteBuffer to put the byte into
v - the short containing the unsigned byte

putUnsignedByte

public static void putUnsignedByte(java.nio.ByteBuffer bb,
                                   short v,
                                   int offset)
Put an unsigned byte into the specified ByteBuffer at the specified offset

Parameters:
bb - ByteBuffer to put the byte into
v - the short containing the unsigned byte
offset - the offset to insert the unsigned byte at

getUnsignedShort

public static int getUnsignedShort(java.nio.ByteBuffer bb)
Get an unsigned short from the current position of the ByteBuffer

Parameters:
bb - ByteBuffer to get the byte from
Returns:
an unsigned short contained in a int

getUnsignedShort

public static int getUnsignedShort(java.nio.ByteBuffer bb,
                                   int offset)
Get an unsigned short from the specified offset in the ByteBuffer

Parameters:
bb - ByteBuffer to get the short from
offset - the offset to get the short from
Returns:
an unsigned short contained in a int

putUnsignedShort

public static void putUnsignedShort(java.nio.ByteBuffer bb,
                                    int v)
Put an unsigned short into the specified ByteBuffer at the current position

Parameters:
bb - ByteBuffer to put the short into
v - the int containing the unsigned short

putUnsignedShort

public static void putUnsignedShort(java.nio.ByteBuffer bb,
                                    int v,
                                    int offset)
Put an unsigned short into the specified ByteBuffer at the specified offset

Parameters:
bb - ByteBuffer to put the short into
v - the int containing the unsigned short
offset - the offset to insert the unsigned short at

getUnsignedInt

public static long getUnsignedInt(java.nio.ByteBuffer bb)
Get an unsigned int from the current position of the ByteBuffer

Parameters:
bb - ByteBuffer to get the int from
Returns:
an unsigned int contained in a long

getUnsignedInt

public static long getUnsignedInt(java.nio.ByteBuffer bb,
                                  int offset)
Get an unsigned int from the specified offset in the ByteBuffer

Parameters:
bb - ByteBuffer to get the int from
offset - the offset to get the int from
Returns:
an unsigned int contained in a long

putUnsignedInt

public static void putUnsignedInt(java.nio.ByteBuffer bb,
                                  long v)
Put an unsigned int into the specified ByteBuffer at the current position

Parameters:
bb - ByteBuffer to put the int into
v - the long containing the unsigned int

putUnsignedInt

public static void putUnsignedInt(java.nio.ByteBuffer bb,
                                  long v,
                                  int offset)
Put an unsigned int into the specified ByteBuffer at the specified offset

Parameters:
bb - ByteBuffer to put the int into
v - the long containing the unsigned int
offset - the offset to insert the unsigned int at

getUnsignedLong

public static java.math.BigInteger getUnsignedLong(java.nio.ByteBuffer bb)
Get an unsigned long from the current position of the ByteBuffer

Parameters:
bb - ByteBuffer to get the long from
Returns:
an unsigned long contained in a BigInteger

getUnsignedLong

public static java.math.BigInteger getUnsignedLong(java.nio.ByteBuffer bb,
                                                   int offset)
Get an unsigned long from the specified offset in the ByteBuffer

Parameters:
bb - ByteBuffer to get the long from
offset - the offset to get the long from
Returns:
an unsigned long contained in a BigInteger

putUnsignedLong

public static void putUnsignedLong(java.nio.ByteBuffer bb,
                                   java.math.BigInteger v)
Put an unsigned long into the specified ByteBuffer at the current position

Parameters:
bb - ByteBuffer to put the long into
v - the BigInteger containing the unsigned long

putUnsignedLong

public static void putUnsignedLong(java.nio.ByteBuffer bb,
                                   java.math.BigInteger v,
                                   int offset)
Put an unsigned long into the specified ByteBuffer at the specified offset

Parameters:
bb - ByteBuffer to put the long into
v - the BigInteger containing the unsigned long
offset - the offset to insert the unsigned long at