Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.common.stream.CJDBCStream Class Reference

List of all members.

Static Public Member Functions

final Object decompressObject (byte[] array) throws IOException, ClassNotFoundException
final byte[] compressObject (Object obj) throws IOException
final int countBytes (Object obj) throws IOException

Static Public Attributes

final int CLEAN_INTERVAL = 10
final int OBJECT = 0
final int NULL = 1
final int STRING_OBJECT = 2
final int INTEGER_OBJECT = 3
final int LONG_OBJECT = 4
final int BOOLEAN_OBJECT = 5

Detailed Description

This is a useful stream class to compress and decompress object to a stream.

Author:
Nicolas Modrzyk

Emmanuel Cecchet

Definition at line 42 of file CJDBCStream.java.


Member Function Documentation

final byte [] org.objectweb.cjdbc.common.stream.CJDBCStream.compressObject Object  obj  )  throws IOException [static]
 

Compress an object from its java form to byte array

Parameters:
obj to compress
Returns:
byte array
Exceptions:
IOException if fails to read

Definition at line 87 of file CJDBCStream.java.

00088   {
00089     ByteArrayOutputStream bos = new ByteArrayOutputStream();
00090     DeflaterOutputStream zip = new DeflaterOutputStream(bos, new Deflater(
00091         Deflater.BEST_COMPRESSION));
00092     ObjectOutputStream oos = new ObjectOutputStream(zip);
00093     oos.writeObject(obj);
00094     oos.flush();
00095     oos.close();
00096     bos.close();
00097     byte[] data = bos.toByteArray();
00098     return data;
00099   }

final int org.objectweb.cjdbc.common.stream.CJDBCStream.countBytes Object  obj  )  throws IOException [static]
 

Statistic method to count the number of bytes of a class.

Parameters:
obj to count bytes
Returns:
the number of bytes
Exceptions:
IOException if fails to read

Definition at line 108 of file CJDBCStream.java.

00109   {
00110     ByteArrayOutputStream bos = new ByteArrayOutputStream();
00111     ObjectOutputStream oos = new ObjectOutputStream(bos);
00112     oos.writeObject(obj);
00113     oos.flush();
00114     oos.close();
00115     bos.close();
00116     return bos.size();
00117   }

final Object org.objectweb.cjdbc.common.stream.CJDBCStream.decompressObject byte[]  array  )  throws IOException, ClassNotFoundException [static]
 

Decompress an object from its byte-compressed form to java object

Parameters:
array of bytes
Returns:
the object if it can be retrieved
Exceptions:
IOException if fails to read
ClassNotFoundException if class of object does not exist

Definition at line 68 of file CJDBCStream.java.

00070   {
00071     ByteArrayInputStream bos = new ByteArrayInputStream(array);
00072     InflaterInputStream zip = new InflaterInputStream(bos);
00073     ObjectInputStream oos = new ObjectInputStream(zip);
00074     Object obj = oos.readObject();
00075     oos.close();
00076     bos.close();
00077     return obj;
00078   }


Member Data Documentation

final int org.objectweb.cjdbc.common.stream.CJDBCStream.BOOLEAN_OBJECT = 5 [static]
 

Identifier of a Boolean object on the stream

Definition at line 58 of file CJDBCStream.java.

final int org.objectweb.cjdbc.common.stream.CJDBCStream.CLEAN_INTERVAL = 10 [static]
 

Clean the stream after CLEAN_INTERVAL call to writeUnshared

Definition at line 45 of file CJDBCStream.java.

final int org.objectweb.cjdbc.common.stream.CJDBCStream.INTEGER_OBJECT = 3 [static]
 

Identifier of an Integer object on the stream

Definition at line 54 of file CJDBCStream.java.

final int org.objectweb.cjdbc.common.stream.CJDBCStream.LONG_OBJECT = 4 [static]
 

Identifier of a Long object on the stream

Definition at line 56 of file CJDBCStream.java.

final int org.objectweb.cjdbc.common.stream.CJDBCStream.NULL = 1 [static]
 

Identifier of null on the stream

Definition at line 50 of file CJDBCStream.java.

final int org.objectweb.cjdbc.common.stream.CJDBCStream.OBJECT = 0 [static]
 

Identifier of an object on the stream

Definition at line 48 of file CJDBCStream.java.

final int org.objectweb.cjdbc.common.stream.CJDBCStream.STRING_OBJECT = 2 [static]
 

Identifier of a String object on the stream

Definition at line 52 of file CJDBCStream.java.


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:02:13 2005 for C-JDBC by  doxygen 1.3.9.1