jremote jbase5.2.1

com.jbase.jremote.io
Class AbstractJBaseObjectReader

java.lang.Object
  extended by com.jbase.jremote.io.AbstractJBaseObjectReader
All Implemented Interfaces:
JBaseObjectReader
Direct Known Subclasses:
IOJBaseObjectReader, NIOJBaseObjectReader

public abstract class AbstractJBaseObjectReader
extends java.lang.Object
implements JBaseObjectReader

Deserializes JBaseSerializable objects sent from the jbase_agent server, or any other source of serialized JCF objects. The clients of the class use readRootObject method to read deserialized JBaseSerializable objects, @see JBaseSerializable. Application classes implementing JBaseSerializable use JBaseObjectReader's methods readObject, readInt, readString, readBytes, etc., in their readFrom method. Application classes must not use readRootObject in readFrom method. Interface of this class is simillar to the one of java.io.ObjectInputStream. It does not extend java.io.ObjectInputStream because that would require handling of the original Java'a serialization protocol on the jsqld server. Concrete classes extending AbstractJBaseObjectReader should implement method createObject,

Author:
Peter Kuchta, pkuchta@temenos.com
See Also:
and JRemoteObjectReader.

Field Summary
protected static java.util.logging.Logger log
           
 
Constructor Summary
AbstractJBaseObjectReader()
           
 
Method Summary
protected  int bufferedRead()
           
protected  java.nio.ByteBuffer checkBuffer(java.nio.ByteBuffer bBuf, int newDataLength)
           
abstract  void close()
           
protected abstract  byte getByte()
           
protected abstract  int getBytes(byte[] buf)
           
protected abstract  int getBytes(java.nio.ByteBuffer bBuf)
           
protected abstract  int getInt()
           
protected abstract  ObjectFactory getObjectFactory()
          This method must be implemented by concrete ObjectReaders.
protected abstract  int inBytes(int numberOfBytesToRead)
           
protected  IByteObject readByteObject(char code, IByteObject o)
           
 byte[] readBytes()
           
 int readInt()
          Reads a 32 bits integer from the underlying InputStream.
protected  JBaseSerializable readJBaseSerializableObject(char code, JBaseSerializable o)
           
 java.lang.Object readObject()
          Deserializes next object from the underlying InputStream.
 IByteObject readObject(IByteObject o)
          Reads/deserializes next byte object, a new ByteObject will be created and returned if a null argument is passed in.
 JBaseSerializable readObject(JBaseSerializable o)
          Reads/deserializes next object, the ObjectFactory will be used to create a JBaseSerializable object if a null argument is passed in.
 JBaseSerializable readRootObject()
          Deserializes a root object.
 java.lang.String readString()
          Reads a java.lang.String.
protected abstract  java.lang.String readUTF()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log
Constructor Detail

AbstractJBaseObjectReader

public AbstractJBaseObjectReader()
Method Detail

inBytes

protected abstract int inBytes(int numberOfBytesToRead)
                        throws java.io.IOException
Throws:
java.io.IOException

getByte

protected abstract byte getByte()
                         throws java.io.IOException
Throws:
java.io.IOException

getInt

protected abstract int getInt()
                       throws java.io.IOException
Throws:
java.io.IOException

getBytes

protected abstract int getBytes(byte[] buf)
                         throws java.io.IOException
Throws:
java.io.IOException

getBytes

protected abstract int getBytes(java.nio.ByteBuffer bBuf)
                         throws java.io.IOException
Throws:
java.io.IOException

readUTF

protected abstract java.lang.String readUTF()
                                     throws java.io.IOException
Throws:
java.io.IOException

close

public abstract void close()
                    throws java.io.IOException
Specified by:
close in interface JBaseObjectReader
Throws:
java.io.IOException

readObject

public java.lang.Object readObject()
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Deserializes next object from the underlying InputStream. Client should use Java safe cast to cast the object to an expected type.

Specified by:
readObject in interface JBaseObjectReader
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObject

public JBaseSerializable readObject(JBaseSerializable o)
                             throws java.io.IOException,
                                    java.lang.ClassNotFoundException
Reads/deserializes next object, the ObjectFactory will be used to create a JBaseSerializable object if a null argument is passed in.

Specified by:
readObject in interface JBaseObjectReader
Throws:
java.io.IOException
java.lang.ClassNotFoundException

readObject

public IByteObject readObject(IByteObject o)
                       throws java.io.IOException
Reads/deserializes next byte object, a new ByteObject will be created and returned if a null argument is passed in.

Specified by:
readObject in interface JBaseObjectReader
Throws:
java.io.IOException

readByteObject

protected IByteObject readByteObject(char code,
                                     IByteObject o)
                              throws java.io.IOException
Throws:
java.io.IOException

checkBuffer

protected java.nio.ByteBuffer checkBuffer(java.nio.ByteBuffer bBuf,
                                          int newDataLength)

readJBaseSerializableObject

protected JBaseSerializable readJBaseSerializableObject(char code,
                                                        JBaseSerializable o)
                                                 throws java.io.IOException,
                                                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

getObjectFactory

protected abstract ObjectFactory getObjectFactory()
                                           throws UnknownTypeException
This method must be implemented by concrete ObjectReaders.

Parameters:
objectType - type identifier, @see JBaseSerializable.TYPE
Returns:
an instance of a class implementing JBaseSerializable
Throws:
UnknownTypeException

readInt

public int readInt()
            throws java.io.IOException
Reads a 32 bits integer from the underlying InputStream.

Specified by:
readInt in interface JBaseObjectReader
Throws:
java.io.IOException

readBytes

public byte[] readBytes()
                 throws java.io.IOException
Specified by:
readBytes in interface JBaseObjectReader
Throws:
java.io.IOException

readString

public java.lang.String readString()
                            throws java.io.IOException
Reads a java.lang.String. This method will deserialize and convert to String a JDynArray (a variable of type CVar serialized on the server). It will throw an exception if the object coming from the server is of any other type.

Specified by:
readString in interface JBaseObjectReader
Throws:
java.io.IOException

readRootObject

public JBaseSerializable readRootObject()
                                 throws java.io.IOException,
                                        java.lang.ClassNotFoundException
Description copied from interface: JBaseObjectReader
Deserializes a root object. This method must not be used by implementors of JBaseSerializable (in readObject).

Specified by:
readRootObject in interface JBaseObjectReader
Returns:
an instance of JBaseSerializable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

bufferedRead

protected int bufferedRead()
                    throws java.io.IOException
Throws:
java.io.IOException

jremote jbase5.2.1

Copyright © 2010 TEMENOS. All Rights Reserved.