org.eclipse.birt.core.util
Class IOUtil

java.lang.Object
  extended by org.eclipse.birt.core.util.IOUtil

public class IOUtil
extends java.lang.Object

A util class to read or write primitive Java data type. Please notice, every method has a stream which might be input stream or output stream as parameters. This stream should be already added a buffered layer underlying it.


Field Summary
static int INT_LENGTH
           
static int MAX_NUMBER_OF_STREAM_BUFFER
           
static int RA_STREAM_BUFFER_LENGTH
           
 
Constructor Summary
IOUtil()
           
 
Method Summary
static int bytesToInteger(byte[] b)
          Assemble four bytes to an int value, make sure that the passed bytes length is larger than 4.
static long bytesToLong(byte[] b)
          Assemble eight bytes to an long value, make sure that the passed bytes length larger than 8.
static int getInt(byte[] bytes)
          Assemble four bytes to an int value, make sure that the passed bytes length is 4.
static void integerToBytes(int v, byte[] b)
           
static void longToBytes(long v, byte[] b)
           
static boolean readBool(java.io.InputStream inputStream)
          Read a bool value from an input stream
static byte[] readBytes(java.io.DataInputStream dis)
          Read a list from an input stream
static double readDouble(java.io.DataInputStream inputStream)
          Read a double value from an input stream
static float readFloat(java.io.DataInputStream inputStream)
          Read a float value from an input stream
static int readInt(java.io.InputStream inputStream)
          Read an int value from an input stream
static java.util.List readList(java.io.DataInputStream dis)
          Read a list from an input stream
static java.util.List readList(java.io.DataInputStream dis, java.lang.ClassLoader classLoader)
          Read a list from an input stream
static long readLong(java.io.DataInputStream inputStream)
          Read a long value from an input stream
static java.util.Map readMap(java.io.DataInputStream dis)
          Read a Map from an input stream
static java.util.Map readMap(java.io.DataInputStream dis, java.lang.ClassLoader loader)
          Read a Map from an input stream
static java.lang.Object readObject(java.io.DataInputStream dis)
          Currently these data types are supported.
static java.lang.Object readObject(java.io.DataInputStream dis, java.lang.ClassLoader classLoader)
          Currently these data types are supported.
static short readShort(java.io.InputStream inputStream)
          Read an int value from an input stream
static java.lang.String readString(java.io.DataInputStream dis)
          Read a String from an input stream
static void writeBool(java.io.OutputStream outputStream, boolean bool)
          Write a boolean value to an output stream
static void writeBytes(java.io.DataOutputStream dos, byte[] bytes)
          Write a bytes to an output stream
static void writeDouble(java.io.DataOutputStream outputStream, double value)
          Write a double value to an output stream
static void writeFloat(java.io.DataOutputStream outputStream, float value)
          Write a float value to an output stream
static void writeInt(java.io.OutputStream outputStream, int value)
          Write an int value to an output stream
static void writeList(java.io.DataOutputStream dos, java.util.List list)
          Write a list to an output stream
static void writeLong(java.io.DataOutputStream outputStream, long value)
          Write a long value to an output stream
static void writeMap(java.io.DataOutputStream dos, java.util.Map map)
          Write a Map to an output stream
static void writeObject(java.io.DataOutputStream dos, java.lang.Object obValue)
          When obValue is not supported te be serialized, an IOException will be thrown.
static void writeRawBytes(java.io.DataOutputStream dos, byte[] bytes)
          Write a byte array to an output stream only with its raw content.
static void writeShort(java.io.OutputStream outputStream, short value)
          Write an int value to an output stream
static void writeString(java.io.DataOutputStream dos, java.lang.String str)
          Write a String value to an output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INT_LENGTH

public static final int INT_LENGTH
See Also:
Constant Field Values

RA_STREAM_BUFFER_LENGTH

public static final int RA_STREAM_BUFFER_LENGTH
See Also:
Constant Field Values

MAX_NUMBER_OF_STREAM_BUFFER

public static final int MAX_NUMBER_OF_STREAM_BUFFER
See Also:
Constant Field Values
Constructor Detail

IOUtil

public IOUtil()
Method Detail

readShort

public static final short readShort(java.io.InputStream inputStream)
                             throws java.io.IOException
Read an int value from an input stream

Parameters:
inputStream -
Returns:
int value
Throws:
java.io.IOException

writeShort

public static final void writeShort(java.io.OutputStream outputStream,
                                    short value)
                             throws java.io.IOException
Write an int value to an output stream

Parameters:
outputStream -
value -
Throws:
java.io.IOException

readInt

public static final int readInt(java.io.InputStream inputStream)
                         throws java.io.IOException
Read an int value from an input stream

Parameters:
inputStream -
Returns:
int value
Throws:
java.io.IOException

writeInt

public static final void writeInt(java.io.OutputStream outputStream,
                                  int value)
                           throws java.io.IOException
Write an int value to an output stream

Parameters:
outputStream -
value -
Throws:
java.io.IOException

getInt

public static final int getInt(byte[] bytes)
Assemble four bytes to an int value, make sure that the passed bytes length is 4.

Parameters:
bytes -
Returns:
int value of bytes

bytesToInteger

public static final int bytesToInteger(byte[] b)
Assemble four bytes to an int value, make sure that the passed bytes length is larger than 4.

Parameters:
bytes -
Returns:
int value of bytes

bytesToLong

public static final long bytesToLong(byte[] b)
Assemble eight bytes to an long value, make sure that the passed bytes length larger than 8.

Parameters:
bytes -
Returns:
int value of bytes

integerToBytes

public static final void integerToBytes(int v,
                                        byte[] b)

longToBytes

public static final void longToBytes(long v,
                                     byte[] b)

readBool

public static final boolean readBool(java.io.InputStream inputStream)
                              throws java.io.IOException
Read a bool value from an input stream

Parameters:
inputStream -
Returns:
boolean value
Throws:
java.io.IOException

writeBool

public static final void writeBool(java.io.OutputStream outputStream,
                                   boolean bool)
                            throws java.io.IOException
Write a boolean value to an output stream

Parameters:
outputStream -
bool -
Throws:
java.io.IOException

readFloat

public static final float readFloat(java.io.DataInputStream inputStream)
                             throws java.io.IOException
Read a float value from an input stream

Parameters:
inputStream -
Returns:
int value
Throws:
java.io.IOException

writeFloat

public static final void writeFloat(java.io.DataOutputStream outputStream,
                                    float value)
                             throws java.io.IOException
Write a float value to an output stream

Parameters:
outputStream -
value -
Throws:
java.io.IOException

readDouble

public static final double readDouble(java.io.DataInputStream inputStream)
                               throws java.io.IOException
Read a double value from an input stream

Parameters:
inputStream -
Returns:
int value
Throws:
java.io.IOException

writeDouble

public static final void writeDouble(java.io.DataOutputStream outputStream,
                                     double value)
                              throws java.io.IOException
Write a double value to an output stream

Parameters:
outputStream -
value -
Throws:
java.io.IOException

readLong

public static final long readLong(java.io.DataInputStream inputStream)
                           throws java.io.IOException
Read a long value from an input stream

Parameters:
inputStream -
Returns:
int value
Throws:
java.io.IOException

writeLong

public static final void writeLong(java.io.DataOutputStream outputStream,
                                   long value)
                            throws java.io.IOException
Write a long value to an output stream

Parameters:
outputStream -
value -
Throws:
java.io.IOException

writeRawBytes

public static final void writeRawBytes(java.io.DataOutputStream dos,
                                       byte[] bytes)
                                throws java.io.IOException
Write a byte array to an output stream only with its raw content.

Parameters:
dos -
bytes, - it can not be null
Throws:
java.io.IOException

readObject

public static final java.lang.Object readObject(java.io.DataInputStream dis)
                                         throws java.io.IOException
Currently these data types are supported. Integer Float Double BigDecimal Date Time Timestamp Boolean String byte[] List Map

Returns:
Throws:
java.io.IOException

readObject

public static final java.lang.Object readObject(java.io.DataInputStream dis,
                                                java.lang.ClassLoader classLoader)
                                         throws java.io.IOException
Currently these data types are supported. Integer Float Double BigDecimal Date Time Timestamp Boolean String byte[] List Map

Returns:
Throws:
java.io.IOException

writeObject

public static final void writeObject(java.io.DataOutputStream dos,
                                     java.lang.Object obValue)
                              throws java.io.IOException
When obValue is not supported te be serialized, an IOException will be thrown.

Parameters:
dos -
obValue -
Throws:
java.io.IOException

readString

public static final java.lang.String readString(java.io.DataInputStream dis)
                                         throws java.io.IOException
Read a String from an input stream

Parameters:
inputStream -
Returns:
an String
Throws:
java.io.IOException

writeString

public static final void writeString(java.io.DataOutputStream dos,
                                     java.lang.String str)
                              throws java.io.IOException
Write a String value to an output stream

Parameters:
outputStream -
str -
Throws:
java.io.IOException

readBytes

public static final byte[] readBytes(java.io.DataInputStream dis)
                              throws java.io.IOException
Read a list from an input stream

Parameters:
dos -
Returns:
Throws:
java.io.IOException
BirtException

writeBytes

public static final void writeBytes(java.io.DataOutputStream dos,
                                    byte[] bytes)
                             throws java.io.IOException
Write a bytes to an output stream

Parameters:
dos -
dataMap -
Throws:
java.io.IOException
BirtException

readList

public static final java.util.List readList(java.io.DataInputStream dis)
                                     throws java.io.IOException
Read a list from an input stream

Parameters:
dos -
Returns:
Throws:
java.io.IOException
BirtException

readList

public static final java.util.List readList(java.io.DataInputStream dis,
                                            java.lang.ClassLoader classLoader)
                                     throws java.io.IOException
Read a list from an input stream

Parameters:
dos -
Returns:
Throws:
java.io.IOException
BirtException

writeList

public static final void writeList(java.io.DataOutputStream dos,
                                   java.util.List list)
                            throws java.io.IOException
Write a list to an output stream

Parameters:
dos -
dataMap -
Throws:
java.io.IOException
BirtException

readMap

public static final java.util.Map readMap(java.io.DataInputStream dis)
                                   throws java.io.IOException
Read a Map from an input stream

Parameters:
dos -
Returns:
Throws:
java.io.IOException
BirtException

readMap

public static final java.util.Map readMap(java.io.DataInputStream dis,
                                          java.lang.ClassLoader loader)
                                   throws java.io.IOException
Read a Map from an input stream

Parameters:
dos -
Returns:
Throws:
java.io.IOException
BirtException

writeMap

public static final void writeMap(java.io.DataOutputStream dos,
                                  java.util.Map map)
                           throws java.io.IOException
Write a Map to an output stream

Parameters:
dos -
map -
Throws:
java.io.IOException
BirtException


Copyright © 2008 Actuate Corp. All rights reserved.