com.jguild.jrpm.io.datatype
Class TypeFactory

java.lang.Object
  extended by com.jguild.jrpm.io.datatype.TypeFactory

public final class TypeFactory
extends java.lang.Object

Factory to create rpm data types.

Version:
$Id: TypeFactory.java,v 1.4 2005/11/11 08:27:40 mkuss Exp $
Author:
kuss

Method Summary
static BIN createBIN(byte[] data)
          Create a data object of type BIN
static CHAR createCHAR(char[] data)
          Create a data object of type CHAR
static DataTypeIf createFromStream(java.io.DataInputStream inputStream, IndexEntry indexEntry, long length)
          This method creates a rpm data type out of a input stream and an IndexEntry.
static I18NSTRING createI18NSTRING(java.lang.String[] str)
          Create a data object of type I18NSTRING
static INT16 createINT16(short[] data)
          Create a data object of type INT16
static INT32 createINT32(int[] data)
          Create a data object of type INT32
static INT64 createINT64(long[] data)
          Create a data object of type INT64
static INT8 createINT8(byte[] data)
          Create a data object of type INT8
static NULL createNULL(int size)
          Create a data object of type NULL
static STRING_ARRAY createSTRING_ARRAY(java.lang.String[] str)
          Create a data object of type STRING_ARRAY
static STRING createSTRING(java.lang.String str)
          Create a data object of type STRING
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createBIN

public static BIN createBIN(byte[] data)
Create a data object of type BIN

Parameters:
data - The raw data
Returns:
The BIN object

createCHAR

public static CHAR createCHAR(char[] data)
Create a data object of type CHAR

Parameters:
data - The raw data
Returns:
The CHAR object

createI18NSTRING

public static I18NSTRING createI18NSTRING(java.lang.String[] str)
Create a data object of type I18NSTRING

Parameters:
str - An array of language strings
Returns:
The I18NSTRING object

createINT8

public static INT8 createINT8(byte[] data)
Create a data object of type INT8

Parameters:
data - The raw data
Returns:
The INT8 object

createINT16

public static INT16 createINT16(short[] data)
Create a data object of type INT16

Parameters:
data - The raw data
Returns:
The INT16 object

createINT32

public static INT32 createINT32(int[] data)
Create a data object of type INT32

Parameters:
data - The raw data
Returns:
The INT32 object

createINT64

public static INT64 createINT64(long[] data)
Create a data object of type INT64

Parameters:
data - The raw data
Returns:
The INT64 object

createNULL

public static NULL createNULL(int size)
Create a data object of type NULL

Parameters:
size - The length of the entry
Returns:
The NULL object

createSTRING

public static STRING createSTRING(java.lang.String str)
Create a data object of type STRING

Parameters:
str - A raw string
Returns:
The STRING object

createSTRING_ARRAY

public static STRING_ARRAY createSTRING_ARRAY(java.lang.String[] str)
Create a data object of type STRING_ARRAY

Parameters:
str - Raw strings
Returns:
The STRING_ARRAY object

createFromStream

public static DataTypeIf createFromStream(java.io.DataInputStream inputStream,
                                          IndexEntry indexEntry,
                                          long length)
                                   throws java.io.IOException
This method creates a rpm data type out of a input stream and an IndexEntry. The object must at the current position of the input stream. The length is only needed for string objects; the string objects will read length bytes of the input stream and will try to convert the data into a rpm data type.

Parameters:
inputStream - The input stream
indexEntry - The IndexEntry that should be read
length - The number of bytes to read for string objects
Returns:
One of the rpm data types coresponding with the type contained in the IndexEntry.
Throws:
java.io.IOException - if something was wrong during reading of the input stream