org.littleshoot.util
Class Unsigned

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

public final class Unsigned
extends Object

Utility class to get and put unsigned values to a ByteBuffer object. All methods here are static and take a ByteBuffer argument. Since java does not provide unsigned primitive types, each unsigned value read from the buffer is promoted up to the next bigger primitive data type. getUnsignedByte() returns a short, getUnsignedShort( ) returns an int and getUnsignedInt() returns a long. There is no getUnsignedLong( ) since there is no primitive type to hold the value returned. If needed, methods returning BigInteger could be implemented. Likewise, the put methods take a value larger than the type they will be assigning. putUnsignedByte takes a short argument, etc.

Author:
Ron Hitchens (ron@ronsoft.com)

Constructor Summary
Unsigned()
           
 
Method Summary
static short getUnsignedByte(ByteBuffer bb)
           
static short getUnsignedByte(ByteBuffer bb, int position)
           
static long getUnsignedInt(ByteBuffer bb)
           
static long getUnsignedInt(ByteBuffer bb, int position)
           
static int getUnsignedShort(ByteBuffer bb)
           
static int getUnsignedShort(ByteBuffer bb, int position)
           
static void putUnsignedByte(ByteBuffer bb, int value)
           
static void putUnsignedByte(ByteBuffer bb, int position, int value)
           
static void putUnsignedInt(ByteBuffer bb, int position, long value)
           
static void putUnsignedInt(ByteBuffer bb, long value)
           
static void putUnsignedShort(ByteBuffer bb, int value)
           
static void putUnsignedShort(ByteBuffer bb, int position, int value)
           
 
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(ByteBuffer bb)

putUnsignedByte

public static void putUnsignedByte(ByteBuffer bb,
                                   int value)

getUnsignedByte

public static short getUnsignedByte(ByteBuffer bb,
                                    int position)

putUnsignedByte

public static void putUnsignedByte(ByteBuffer bb,
                                   int position,
                                   int value)

getUnsignedShort

public static int getUnsignedShort(ByteBuffer bb)

putUnsignedShort

public static void putUnsignedShort(ByteBuffer bb,
                                    int value)

getUnsignedShort

public static int getUnsignedShort(ByteBuffer bb,
                                   int position)

putUnsignedShort

public static void putUnsignedShort(ByteBuffer bb,
                                    int position,
                                    int value)

getUnsignedInt

public static long getUnsignedInt(ByteBuffer bb)

putUnsignedInt

public static void putUnsignedInt(ByteBuffer bb,
                                  long value)

getUnsignedInt

public static long getUnsignedInt(ByteBuffer bb,
                                  int position)

putUnsignedInt

public static void putUnsignedInt(ByteBuffer bb,
                                  int position,
                                  long value)


Copyright © 2011-2013 LittleShoot. All Rights Reserved.