picturedream.utils
Class BinaryUtils

java.lang.Object
  |
  +--picturedream.utils.BinaryUtils

public class BinaryUtils
extends java.lang.Object

Title: PictureDream

Description:

Copyright: Copyright (c) 2003 MRoc

Organisation: MRoc Audiosolutions

Version:
1.0
Author:
MRoc

Field Summary
static int[] BITS8
          some static fields to mask bits
static boolean DEBUG
          set this value to false to prevent console output
private static java.lang.String[] HEX
           
 
Constructor Summary
BinaryUtils()
           
 
Method Summary
static int makeIntFrom2BytesBigEndian(byte[] bytes, int offset)
          makes an int from two bytes from an bytearray from the given offset
static int makeIntFrom2BytesLittleEndian(byte[] bytes, int offset)
          makes an int from two bytes from an bytearray from the given offset
static int makeIntFrom4BytesLittleEndian(byte[] bytes, int offset)
          returns an int made out of four bytes (32bit) from an bytearray from the given offset
static void put2BytesToBufferLittleEndian(int value, ByteBuffer buffer)
          puts the given int as 2 bytes to the buffer, in little endian align, means lowest byte first (reverse representation from memory)
static void put2BytesToBufferLittleEndian(short value, byte[] buffer, int offset)
          puts the given int as 2 bytes to the buffer, in little endian align, means lowest byte first (reverse representation from memory)
static void put4BytesToBufferBigEndian(int value, byte[] buffer, int offset)
          puts the given int as 4 bytes to the buffer, in big endian align, means highest byte first (normal representation like in memory)
static void put4BytesToBufferBigEndian(int value, ByteBuffer buffer)
          puts the given int as 4 bytes to the buffer, in big endian align, means highest byte first (normal representation like in memory)
static void put4BytesToBufferLittleEndian(int value, byte[] buffer, int offset)
          puts the given int as 4 bytes to the given buffer at the given offset
static void put4BytesToBufferLittleEndian(int value, ByteBuffer buffer)
          puts the given int as 4 bytes to the buffer, in little endian align, means lowest byte first (reverse representation from memory)
static java.lang.String toHexString(byte b)
          returns the unsigned byte as hex string left filled with zeros, (means allways two characters)
static java.lang.String toHexString4(int i)
          returns the unsigned int as hex string left filled with zeros, (means allways four characters)
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

BITS8

public static final int[] BITS8
some static fields to mask bits

HEX

private static final java.lang.String[] HEX

DEBUG

public static boolean DEBUG
set this value to false to prevent console output
Constructor Detail

BinaryUtils

public BinaryUtils()
Method Detail

put4BytesToBufferLittleEndian

public static void put4BytesToBufferLittleEndian(int value,
                                                 ByteBuffer buffer)
puts the given int as 4 bytes to the buffer, in little endian align, means lowest byte first (reverse representation from memory)

put4BytesToBufferLittleEndian

public static void put4BytesToBufferLittleEndian(int value,
                                                 byte[] buffer,
                                                 int offset)
puts the given int as 4 bytes to the given buffer at the given offset

put4BytesToBufferBigEndian

public static void put4BytesToBufferBigEndian(int value,
                                              ByteBuffer buffer)
puts the given int as 4 bytes to the buffer, in big endian align, means highest byte first (normal representation like in memory)

put4BytesToBufferBigEndian

public static void put4BytesToBufferBigEndian(int value,
                                              byte[] buffer,
                                              int offset)
puts the given int as 4 bytes to the buffer, in big endian align, means highest byte first (normal representation like in memory)

put2BytesToBufferLittleEndian

public static void put2BytesToBufferLittleEndian(int value,
                                                 ByteBuffer buffer)
puts the given int as 2 bytes to the buffer, in little endian align, means lowest byte first (reverse representation from memory)

put2BytesToBufferLittleEndian

public static void put2BytesToBufferLittleEndian(short value,
                                                 byte[] buffer,
                                                 int offset)
puts the given int as 2 bytes to the buffer, in little endian align, means lowest byte first (reverse representation from memory)

toHexString

public static java.lang.String toHexString(byte b)
returns the unsigned byte as hex string left filled with zeros, (means allways two characters)

toHexString4

public static java.lang.String toHexString4(int i)
returns the unsigned int as hex string left filled with zeros, (means allways four characters)

makeIntFrom4BytesLittleEndian

public static int makeIntFrom4BytesLittleEndian(byte[] bytes,
                                                int offset)
returns an int made out of four bytes (32bit) from an bytearray from the given offset

makeIntFrom2BytesLittleEndian

public static int makeIntFrom2BytesLittleEndian(byte[] bytes,
                                                int offset)
makes an int from two bytes from an bytearray from the given offset

makeIntFrom2BytesBigEndian

public static int makeIntFrom2BytesBigEndian(byte[] bytes,
                                             int offset)
makes an int from two bytes from an bytearray from the given offset