JAPI 0.9.0
Yet another Java API
API Documentation

net.sf.japi.util
Class EndianConverter

java.lang.Object
  extended by net.sf.japi.util.EndianConverter

public class EndianConverter
extends Object

Class to convert data from little endian to big endian and vice versa. Since the conversion is symmetric, there are no special conversion methods, just generic ones, e.g. the same method is used to convert a little endian integer to a big endian integer and vice versa.

Author:
Christian Hujer

Method Summary
static boolean swapEndianess(boolean b)
          Convert a boolean.
static byte swapEndianess(byte b)
          Convert a byte.
static char swapEndianess(char c)
          Convert a char.
static double swapEndianess(double d)
          Convert a double.
static float swapEndianess(float f)
          Convert a float.
static int swapEndianess(int i)
          Convert an int.
static long swapEndianess(long l)
          Convert a long.
static short swapEndianess(short s)
          Convert a short.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

swapEndianess

public static final double swapEndianess(double d)
Convert a double. This method changes byte order from 1, 2, 3, 4, 5, 6, 7, 8 to 8, 7, 6, 5, 4, 3, 2, 1.

Parameters:
d - double to convert
Returns:
converted double

swapEndianess

public static final float swapEndianess(float f)
Convert a float. This method changes byte order from 1, 2, 3, 4 to 4, 3, 2, 1.

Parameters:
f - float to convert
Returns:
converted float

swapEndianess

public static final long swapEndianess(long l)
Convert a long. This method changes byte order from 1, 2, 3, 4, 5, 6, 7, 8 to 8, 7, 6, 5, 4, 3, 2, 1.

Parameters:
l - long to convert
Returns:
converted long

swapEndianess

public static final int swapEndianess(int i)
Convert an int. This method changes byte order from 1, 2, 3, 4 to 4, 3, 2, 1.

Parameters:
i - int to convert
Returns:
converted int

swapEndianess

public static final char swapEndianess(char c)
Convert a char. This method swaps low and high byte.

Parameters:
c - char to convert
Returns:
converted char

swapEndianess

public static final short swapEndianess(short s)
Convert a short. This method swaps low and high byte.

Parameters:
s - short to convert
Returns:
converted short

swapEndianess

public static final byte swapEndianess(byte b)
Convert a byte. This method does nothing and exists for convenience only.

Parameters:
b - byte to convert
Returns:
converted byte (same as b)

swapEndianess

public static final boolean swapEndianess(boolean b)
Convert a boolean. This method does nothing and exists for convenience only.

Parameters:
b - boolean to convert
Returns:
converted boolean (same as b)

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright