OpenOffice.org
XMerge API

org.openoffice.xmerge.util
Class EndianConverter

java.lang.Object
  |
  +--org.openoffice.xmerge.util.EndianConverter

public class EndianConverter
extends java.lang.Object

Helper class providing static methods to convert data to/from Network Byte Order (Big Endian).

With the introduction of java.nio.ByteOrder and java.nio.ByteBuffer in Java 1.4, it may no longer be necessary to use this class in the future.

Version:
1.1

Constructor Summary
EndianConverter()
           
 
Method Summary
static int readInt(byte[] value)
          Convert a Little Endian representation of an integer to a Java int (Network Byte Order).
static short readShort(byte[] value)
          Convert a Little Endian representation of a short to a Java short (Network Byte Order).
static byte[] writeInt(int value)
          Convert an integer to a Little Endian representation.
static byte[] writeShort(short value)
          Convert a short to a Little Endian representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EndianConverter

public EndianConverter()
Method Detail

readInt

public static int readInt(byte[] value)

Convert a Little Endian representation of an integer to a Java int (Network Byte Order).

An array with more than four elements can be used, but only the first four elements will be read.

Parameters:
value - byte array containing the LE representation of the value.
Returns:
int containing the converted value.

readShort

public static short readShort(byte[] value)

Convert a Little Endian representation of a short to a Java short (Network Byte Order).

An array with more than two elements can be used, but only the first two elements will be read.

Parameters:
value - byte array containing the LE representation of the value.
Returns:
short containing the converted value.

writeInt

public static byte[] writeInt(int value)

Convert an integer to a Little Endian representation.

Parameters:
value - The int to be converted.
Returns:
Four element byte array containing the converted value.

writeShort

public static byte[] writeShort(short value)

Convert a short to a Little Endian representation.

Parameters:
value - The short to be converted.
Returns:
Two element byte array containing the converted value.

OpenOffice.org
XMerge API

Copyright © 2002 OpenOffice.org