hotline.iconlib
Class HLUtils

java.lang.Object
  |
  +--hotline.iconlib.HLUtils

public abstract class HLUtils
extends java.lang.Object

an abstract class with various useful operations, such as conversions etc.

See Also:
developer site

Constructor Summary
HLUtils()
           
 
Method Summary
static boolean compareBeginStr(byte[] field, java.lang.String c)
          compare the beginning of a (Text-) bytefield with a string
static void copyBytes(byte[] dest, byte[] src, int destOff, int srcOff, int len)
          copies bytes from one data field into another
static byte[] extractBytes(byte[] data, int pos, int length)
          extracts a given number of bytes at a given index from a byte field
static hotline.iconlib.HLData extractDataFieldHLData(byte[] data)
          extracts the identity, size and offset of an icon/gif/... from the given bytefield which should be a LVT entry from a hotline.dat file
static hotline.iconlib.HLDataHdr extractDataFieldHLDataHdr(byte[] data)
          extracts the block name and row count from the bytefield which should have the form of a HLDataHdr table, i. e. the first 8 bytes of a LVT entry
static int extractInt(byte[] data, int pos)
          extracts an integer in big endian format from a byte field at a given position
static byte[] intToBytes(int val)
          converts an integer to a byte field, bytes are in big endian order
static void printField(byte[] field)
          prints the unsigned byte values of a byte field
static void printFieldInt(int[] field)
          prints the int field
static int signedToUnsigned(byte b)
          converts a signed byte to an unsigned int
static int signedToUnsigned(short s)
          converts a signed short to an unsigned int
static void storeReversed(byte[] dest, byte[] src, int destOff, int srcOff, int len)
          copies bytes reversed from one data field into another
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HLUtils

public HLUtils()
Method Detail

signedToUnsigned

public static int signedToUnsigned(byte b)
converts a signed byte to an unsigned int

Parameters:
b - the byte to be converted
Returns:
unsigned byte value

signedToUnsigned

public static int signedToUnsigned(short s)
converts a signed short to an unsigned int

Parameters:
s - the byte to be converted
Returns:
unsigned byte value

extractInt

public static int extractInt(byte[] data,
                             int pos)
extracts an integer in big endian format from a byte field at a given position

Parameters:
data - byte field where the integer is stored in big endian format
pos - index of the byte field where the integer starts
Returns:
extracted int

extractBytes

public static byte[] extractBytes(byte[] data,
                                  int pos,
                                  int length)
extracts a given number of bytes at a given index from a byte field

Parameters:
data - source byte field
pos - index in data
length - number of bytes
Returns:
extracted bytes

extractDataFieldHLData

public static hotline.iconlib.HLData extractDataFieldHLData(byte[] data)
extracts the identity, size and offset of an icon/gif/... from the given bytefield which should be a LVT entry from a hotline.dat file

Parameters:
data - byte field containing a LVT row
Returns:
extracted bytes

extractDataFieldHLDataHdr

public static hotline.iconlib.HLDataHdr extractDataFieldHLDataHdr(byte[] data)
extracts the block name and row count from the bytefield which should have the form of a HLDataHdr table, i. e. the first 8 bytes of a LVT entry

Parameters:
data - byte field containing a LVT entry
Returns:
object with extracted data

intToBytes

public static byte[] intToBytes(int val)
converts an integer to a byte field, bytes are in big endian order

Parameters:
val - integer value
Returns:
byte field in big endian order

copyBytes

public static void copyBytes(byte[] dest,
                             byte[] src,
                             int destOff,
                             int srcOff,
                             int len)
copies bytes from one data field into another

Parameters:
dest - destination byte field
src - source byte field
destOff - offset in the destination byte field
srcOff - offset in the source byte field
len - number of bytes to be copied
See Also:
storeReversed(byte[], byte[], int, int, int)

storeReversed

public static void storeReversed(byte[] dest,
                                 byte[] src,
                                 int destOff,
                                 int srcOff,
                                 int len)
copies bytes reversed from one data field into another

Parameters:
dest - destination byte field
src - source byte field
destOff - offset in the destination byte field
srcOff - offset in the source byte field
len - number of bytes to be copied
See Also:
copyBytes(byte[], byte[], int, int, int)

printField

public static void printField(byte[] field)
prints the unsigned byte values of a byte field

Parameters:
field - byte field to be printed

printFieldInt

public static void printFieldInt(int[] field)
prints the int field

Parameters:
field - int field to be printed

compareBeginStr

public static boolean compareBeginStr(byte[] field,
                                      java.lang.String c)
compare the beginning of a (Text-) bytefield with a string

Parameters:
field - byte field
c - String
Returns:
true if the first c.length bytes of c and field are equal - when field is considered as a String - false otherwise