The Meta-Environment API

toolbus.util
Class NativeTypeConverter

java.lang.Object
  extended by toolbus.util.NativeTypeConverter

public class NativeTypeConverter
extends java.lang.Object

This class handles the conversion of native types from and to their byte representation.

Author:
Arnold Lankamp

Field Summary
private static int BYTEMASK
           
 
Constructor Summary
private NativeTypeConverter()
          Default constructor.
 
Method Summary
static byte[] makeBytesFromInt(int fourByteNumber)
          Splits the given int value into four separate bytes (little endian encoded).
static byte[] makeBytesFromUnsignedShort(int twoByteNumber)
          Splits the given unsigned short value into two separate bytes (little endian encoded).
static int makeInt(byte[] intBytes)
          Merges four (little endian encoded) bytes into a int value.
static int makeUnsignedShort(byte[] shortBytes)
          Merges two (little endian encoded) bytes into a unsigned short value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BYTEMASK

private static final int BYTEMASK
See Also:
Constant Field Values
Constructor Detail

NativeTypeConverter

private NativeTypeConverter()
Default constructor. Made private to prevent instantiation.

Method Detail

makeUnsignedShort

public static int makeUnsignedShort(byte[] shortBytes)
Merges two (little endian encoded) bytes into a unsigned short value.

Parameters:
shortBytes - The two (little endian encoded) bytes.
Returns:
The resulting short value.

makeBytesFromUnsignedShort

public static byte[] makeBytesFromUnsignedShort(int twoByteNumber)
Splits the given unsigned short value into two separate bytes (little endian encoded).

Parameters:
twoByteNumber - The short that needs to be split.
Returns:
Two (little endian encoded) bytes.

makeInt

public static int makeInt(byte[] intBytes)
Merges four (little endian encoded) bytes into a int value.

Parameters:
intBytes - The four (little endian encoded) bytes.
Returns:
The resulting int value.

makeBytesFromInt

public static byte[] makeBytesFromInt(int fourByteNumber)
Splits the given int value into four separate bytes (little endian encoded).

Parameters:
fourByteNumber - The int that needs to be split.
Returns:
Four (little endian encoded) bytes.

The Meta-Environment API