JNative project : see http://jnative.sf.net


org.xvolks.jnative.util
Class StructConverter

java.lang.Object
  extended by org.xvolks.jnative.util.StructConverter

public class StructConverter
extends java.lang.Object


Method Summary
static int byteArrayIntoBytes(byte[] src, byte[] dest, int start)
           
static boolean bytesIntoBoolean(byte[] bytes, int offset)
           
static double bytesIntoDouble(byte[] bytes, int offset)
           
static float bytesIntoFloat(byte[] bytes, int offset)
           
static int bytesIntoInt(byte[] bytes, int offset)
           
static long bytesIntoLong(byte[] bytes, int offset)
           
static short bytesIntoShort(byte[] bytes, int offset)
           
static int intIntoBytes(int data, byte[] bytes, int start)
           
static int longIntoBytes(long data, byte[] bytes, int start)
           
static int parseInt(java.lang.String val)
          parse a hex string into an int.
static long parseLong(java.lang.String val)
           
static short parseShort(java.lang.String val)
           
static int shortIntoBytes(short data, byte[] bytes, int start)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseLong

public static long parseLong(java.lang.String val)
Parameters:
val - max 16 characters long. Should not contain any '0x'-prefix. the empty string will return 0.
Throws:
java.lang.NumberFormatException - if val is longer than 16 characters or if val contains non parseable characters ([0-9, a-f, A-F] is legal).
java.lang.NullPointerException - if val is null.
See Also:
parseInt(String)

parseInt

public static int parseInt(java.lang.String val)
parse a hex string into an int. This method differs from Integer.parseInt(val, 16) in that it does not allow '-' and allows the full range of eight hex characters (eg. 'FFFFFFFF' is allowed). Since int is signed the string is parsed in the standard signed 2-complement representaion, eg:

Parameters:
val - max 8 characters long. Should not contain any '0x'-prefix. the empty string will return 0.
Throws:
java.lang.NumberFormatException - if val is longer than 8 characters or if val contains non parseable characters ([0-9, a-f, A-F] is legal).
java.lang.NullPointerException - if val is null.

parseShort

public static short parseShort(java.lang.String val)
Parameters:
val - max 4 characters long. Should not contain any '0x'-prefix. the empty string will return 0.
Throws:
java.lang.NumberFormatException - if val is longer than 4 characters or if val contains non parseable characters ([0-9, a-f, A-F] is legal).
java.lang.NullPointerException - if val is null.
See Also:
parseInt(String)

bytesIntoLong

public static long bytesIntoLong(byte[] bytes,
                                 int offset)

bytesIntoDouble

public static double bytesIntoDouble(byte[] bytes,
                                     int offset)

bytesIntoFloat

public static float bytesIntoFloat(byte[] bytes,
                                   int offset)

bytesIntoBoolean

public static boolean bytesIntoBoolean(byte[] bytes,
                                       int offset)

bytesIntoInt

public static int bytesIntoInt(byte[] bytes,
                               int offset)

bytesIntoShort

public static short bytesIntoShort(byte[] bytes,
                                   int offset)

longIntoBytes

public static int longIntoBytes(long data,
                                byte[] bytes,
                                int start)

intIntoBytes

public static int intIntoBytes(int data,
                               byte[] bytes,
                               int start)

shortIntoBytes

public static int shortIntoBytes(short data,
                                 byte[] bytes,
                                 int start)

byteArrayIntoBytes

public static int byteArrayIntoBytes(byte[] src,
                                     byte[] dest,
                                     int start)

JNative project : see http://jnative.sf.net