edu.rice.cs.cunit.util
Class Types

java.lang.Object
  extended by edu.rice.cs.cunit.util.Types

public class Types
extends java.lang.Object

Type conversions.

Author:
Mathias Ricken

Constructor Summary
Types()
           
 
Method Summary
static byte[] bytesFromInt(int i)
          Construct an array of four individual bytes from an int.
static void bytesFromInt(int i, byte[] b, int start)
          Construct four individual bytes from an int and place them in the byte array starting at offset start.
static byte[] bytesFromShort(short s)
          Construct an array of two individual bytes from a short.
static void bytesFromShort(short s, byte[] b, int start)
          Construct two individual bytes from a short and place them in the byte array at offset start.
static int intFromBytes(byte[] b, int start)
          Construct an int from four bytes in a byte array.
static short shortFromBytes(byte[] b, int start)
          Construct a short from two bytes in a byte array.
static int uintFromBytes(byte[] b, int start)
          Construct an int from four bytes in a byte array.
static int unsigned(byte b)
          Convert a signed byte into an unsigned byte.
static long unsigned(int i)
          Convert a signed int into an unsigned integer.
static int unsigned(short s)
          Convert a signed short into an unsigned short.
static int ushortFromBytes(byte[] b, int start)
          Construct a short from two bytes in a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Types

public Types()
Method Detail

unsigned

public static final long unsigned(int i)
Convert a signed int into an unsigned integer.

Parameters:
i - signed int
Returns:
unsigned integer

unsigned

public static final int unsigned(short s)
Convert a signed short into an unsigned short.

Parameters:
s - signed short
Returns:
unsigned short

unsigned

public static final int unsigned(byte b)
Convert a signed byte into an unsigned byte.

Parameters:
b - signed byte
Returns:
unsigned byte

ushortFromBytes

public static final int ushortFromBytes(byte[] b,
                                        int start)
Construct a short from two bytes in a byte array.

Parameters:
b - byte array
start - index in byte array
Returns:
unsigned short

shortFromBytes

public static final short shortFromBytes(byte[] b,
                                         int start)
Construct a short from two bytes in a byte array.

Parameters:
b - byte array
start - index in byte array
Returns:
short

bytesFromShort

public static final byte[] bytesFromShort(short s)
Construct an array of two individual bytes from a short.

Parameters:
s - short
Returns:
array of two bytes

bytesFromShort

public static final void bytesFromShort(short s,
                                        byte[] b,
                                        int start)
Construct two individual bytes from a short and place them in the byte array at offset start.

Parameters:
s - short
b - byte array
start - offset

uintFromBytes

public static final int uintFromBytes(byte[] b,
                                      int start)
Construct an int from four bytes in a byte array.

Parameters:
b - byte array
start - index in byte array
Returns:
unsigned int

intFromBytes

public static final int intFromBytes(byte[] b,
                                     int start)
Construct an int from four bytes in a byte array.

Parameters:
b - byte array
start - index in byte array
Returns:
signed int

bytesFromInt

public static final byte[] bytesFromInt(int i)
Construct an array of four individual bytes from an int.

Parameters:
i - int
Returns:
array of four bytes

bytesFromInt

public static final void bytesFromInt(int i,
                                      byte[] b,
                                      int start)
Construct four individual bytes from an int and place them in the byte array starting at offset start.

Parameters:
i - int
b - byte array
start - offset