org.apache.uima.cas.impl
Class Serialization

java.lang.Object
  extended by org.apache.uima.cas.impl.Serialization

public class Serialization
extends java.lang.Object

This class has no fields or instance methods, but instead has only static methods. In spite of its name, it has static methods for both serializing and deserializing CASes. It has 2 styles of Serialization / Deserialization - one which makes use of variouscustom binary serialization methods, and - one which just converts CAS and related objects into other objects which in turn are serializable by normal Java Object serialization.


Constructor Summary
Serialization()
           
 
Method Summary
static CAS createCAS(CASMgr casMgr, org.apache.uima.cas.impl.CASSerializer casSer)
          Deserialize the data in a CASSerializer into an existing CAS, return the currentview in that Cas.
static CASMgr createCASMgr(org.apache.uima.cas.impl.CASMgrSerializer ser)
          Deserialize a type system and index repository definition and use to initialize a new instance of a CAS.
static SerialFormat deserializeCAS(CAS cas, java.io.InputStream istream)
          Deserialize a CAS, in various binary formats, into an existing CAS Note: this form supports deserializing the following binary representations: - plain (uncompressed) - compressed, no type filtering (form 4), Delta and not-delta - compressed, no type filtering (form 6), not-delta only.
static org.apache.uima.cas.impl.BinaryCasSerDes6 deserializeCAS(CAS cas, java.io.InputStream istream, TypeSystem tgtTypeSystem, org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo reuseInfo)
          Deserialize a CAS, in various binary formats, into an existing CAS Note: this form supports deserializing the following binary representations: - compressed, type filtering (form 6), delta and not-delta.
static org.apache.uima.cas.impl.BinaryCasSerDes6 deserializeCAS(CAS cas, java.io.InputStream istream, TypeSystem tgtTypeSystem, org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo reuseInfo, org.apache.uima.cas.impl.AllowPreexistingFS allowPreexisting)
          Deserialize a CAS, in various binary formats, into an existing CAS Note: this form supports deserializing the following binary representations: - compressed, type filtering (form 6), delta and not-delta.
static void deserializeCASComplete(org.apache.uima.cas.impl.CASCompleteSerializer casCompSer, CASMgr casMgr)
          Deserialize the data in a CASCompleteSerializer into an existing CAS
static org.apache.uima.cas.impl.CASSerializer serializeCAS(CAS cas)
          Convert a CAS to a CASSerializer object.
static void serializeCAS(CAS cas, java.io.OutputStream ostream)
          Serialize a CAS including what's indexed, to an output stream Uses uncompressed binary serialization
static void serializeCAS(CAS cas, java.io.OutputStream ostream, Marker mark)
          Serializes CAS data added or modified after the tracking Marker was created and writes it to the output stream in Delta CAS format using uncompressed binary format
static org.apache.uima.cas.impl.CASCompleteSerializer serializeCASComplete(CASMgr casMgr)
          Convert a CAS + the type system and index definitions into a CASCompleteSerializer object
static org.apache.uima.cas.impl.CASMgrSerializer serializeCASMgr(CASMgr casMgr)
          Convert a Type System and Index Repository into a CASMgrSerializer object which can be serialized
static org.apache.uima.cas.impl.CASSerializer serializeNoMetaData(CAS cas)
          Convert a CAS to a CASSerializer object.
static void serializeWithCompression(CAS cas, java.lang.Object out)
          Serialize in compressed binary form 4
static void serializeWithCompression(CAS cas, java.lang.Object out, Marker marker)
          Serialize in compress binary form 4, only the delta part of a CAS
static org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo serializeWithCompression(CAS cas, java.lang.Object out, TypeSystem tgtTypeSystem)
          Serialize in compressed binary with type filtering This method can use type filtering to omit sending those types and/or features not present in the target type system.
static void serializeWithCompression(CAS cas, java.lang.Object out, TypeSystem tgtTypeSystem, Marker mark, org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo reuseInfo)
          Delta Serialize in compressed form, with type filtering This method can use type filtering to omit sending those types and/or features not present in the target type system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serialization

public Serialization()
Method Detail

serializeCAS

public static org.apache.uima.cas.impl.CASSerializer serializeCAS(CAS cas)
Convert a CAS to a CASSerializer object. This object used in testing , and also to pass things via the CPP JNI interface, and the Vinci protocol

Parameters:
cas - the CAS which serves as the source for a new CASSerializer object
Returns:
a corresponding CASSerializer object

serializeNoMetaData

public static org.apache.uima.cas.impl.CASSerializer serializeNoMetaData(CAS cas)
Convert a CAS to a CASSerializer object. This object used in testing Excludes metadata about the CAS

Parameters:
cas - the source for a new CASSerializer object
Returns:
a corresponding CASSerializer object

serializeCASMgr

public static org.apache.uima.cas.impl.CASMgrSerializer serializeCASMgr(CASMgr casMgr)
Convert a Type System and Index Repository into a CASMgrSerializer object which can be serialized

Parameters:
casMgr - the type system and index repo definitions
Returns:
a serializable object version of these

serializeCASComplete

public static org.apache.uima.cas.impl.CASCompleteSerializer serializeCASComplete(CASMgr casMgr)
Convert a CAS + the type system and index definitions into a CASCompleteSerializer object

Parameters:
casMgr - the source for a new CASCompleteSerializer object
Returns:
a Java Object which is serializable and has both the type system, index definitions, and the CAS contents

deserializeCASComplete

public static void deserializeCASComplete(org.apache.uima.cas.impl.CASCompleteSerializer casCompSer,
                                          CASMgr casMgr)
Deserialize the data in a CASCompleteSerializer into an existing CAS

Parameters:
casCompSer - the source for deserialization
casMgr - the CAS to receive the data

createCASMgr

public static CASMgr createCASMgr(org.apache.uima.cas.impl.CASMgrSerializer ser)
Deserialize a type system and index repository definition and use to initialize a new instance of a CAS.

Parameters:
ser - the CAS to receive the type system
Returns:
the initialized CAS loaded with the deserialized info about the CAS Type systen and Index repositories

createCAS

public static CAS createCAS(CASMgr casMgr,
                            org.apache.uima.cas.impl.CASSerializer casSer)
Deserialize the data in a CASSerializer into an existing CAS, return the currentview in that Cas.

Parameters:
casMgr - the CAS Manager
casSer - the serializer
Returns:
the initialized CAS loaded with the deserialized data

serializeCAS

public static void serializeCAS(CAS cas,
                                java.io.OutputStream ostream)
Serialize a CAS including what's indexed, to an output stream Uses uncompressed binary serialization

Parameters:
cas - the CAS to serialize
ostream - the output stream

deserializeCAS

public static SerialFormat deserializeCAS(CAS cas,
                                          java.io.InputStream istream)
Deserialize a CAS, in various binary formats, into an existing CAS Note: this form supports deserializing the following binary representations: - plain (uncompressed) - compressed, no type filtering (form 4), Delta and not-delta - compressed, no type filtering (form 6), not-delta only. If this form encounters a non-conforming kind of input, it will throw a runtime exception.

Parameters:
cas - the CAS to deserialize into. If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to.
istream - the input stream
Returns:
The form of the serialized CAS (from its header)

serializeCAS

public static void serializeCAS(CAS cas,
                                java.io.OutputStream ostream,
                                Marker mark)
Serializes CAS data added or modified after the tracking Marker was created and writes it to the output stream in Delta CAS format using uncompressed binary format

Parameters:
cas - the Cas to serialize
ostream - the output stream
mark - the cas mark (for delta CASes)

serializeWithCompression

public static void serializeWithCompression(CAS cas,
                                            java.lang.Object out)
                                     throws java.io.IOException
Serialize in compressed binary form 4

Parameters:
cas - the CAS to serialize
out - - an OutputStream, a DataOutputStream, or a File
Throws:
java.io.IOException - if IO exception

serializeWithCompression

public static void serializeWithCompression(CAS cas,
                                            java.lang.Object out,
                                            Marker marker)
                                     throws java.io.IOException
Serialize in compress binary form 4, only the delta part of a CAS

Parameters:
cas - the CAS to serialize
out - - an OutputStream, a DataOutputStream, or a File
marker - identifying where the delta starts
Throws:
java.io.IOException - if IO exception

serializeWithCompression

public static org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo serializeWithCompression(CAS cas,
                                                                                           java.lang.Object out,
                                                                                           TypeSystem tgtTypeSystem)
                                                                                    throws java.io.IOException,
                                                                                           ResourceInitializationException
Serialize in compressed binary with type filtering This method can use type filtering to omit sending those types and/or features not present in the target type system. - To omit type filtering, use null for the target type system It also only sends those feature structures which are reachable either from an index or references from other reachable feature structures.

Parameters:
cas - the CAS to serialize
out - an OutputStream, a DataOutputStream, or a File
tgtTypeSystem - null or a target TypeSystem, which must be mergable with this CAS's type system
Returns:
information to be used on subsequent serializations (to save time) or deserializations (for receiving delta CASs), or reserializations (if sending delta CASs)
Throws:
java.io.IOException - if IO exception
ResourceInitializationException - if target type system is incompatible with this CAS's type system

serializeWithCompression

public static void serializeWithCompression(CAS cas,
                                            java.lang.Object out,
                                            TypeSystem tgtTypeSystem,
                                            Marker mark,
                                            org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo reuseInfo)
                                     throws java.io.IOException,
                                            ResourceInitializationException
Delta Serialize in compressed form, with type filtering This method can use type filtering to omit sending those types and/or features not present in the target type system. - To omit type filtering, use null for the target type system It also only sends those feature structures which are reachable either from an index or references from other reachable feature structures.

Parameters:
cas - the CAS to serialize
out - an OutputStream, a DataOutputStream, or a File
tgtTypeSystem - null or a target TypeSystem, which must be mergable with this CAS's type system
mark - null or where the mark is in the CAS. If not null, indicates doing a delta CAS serialization
reuseInfo - if mark is not null, this parameter is required and must have been computed when the original deserialization (of the CAS now being serialized as a delta CAS) was done
Throws:
java.io.IOException - if IO exception
ResourceInitializationException - if the target type system and the CAS's type system can't be merged

deserializeCAS

public static org.apache.uima.cas.impl.BinaryCasSerDes6 deserializeCAS(CAS cas,
                                                                       java.io.InputStream istream,
                                                                       TypeSystem tgtTypeSystem,
                                                                       org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo reuseInfo)
                                                                throws java.io.IOException,
                                                                       ResourceInitializationException
Deserialize a CAS, in various binary formats, into an existing CAS Note: this form supports deserializing the following binary representations: - compressed, type filtering (form 6), delta and not-delta.

Parameters:
cas - the CAS to deserialize into. If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to.
istream - the input stream
tgtTypeSystem - The typeSystem of the serialized form of the CAS; must be compatible with the type system of the receiving cas.
reuseInfo - If delta CAS is being received and form 6 compression is being used, then this must be the reuseInfo captured when the original CAS (being updated by the delta coming in) was sent out.
Returns:
The instance of BinaryCasSerDes6 used for deserialization
Throws:
java.io.IOException - if IO exception
ResourceInitializationException - if the target type system and the CAS's type system can't be merged

deserializeCAS

public static org.apache.uima.cas.impl.BinaryCasSerDes6 deserializeCAS(CAS cas,
                                                                       java.io.InputStream istream,
                                                                       TypeSystem tgtTypeSystem,
                                                                       org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo reuseInfo,
                                                                       org.apache.uima.cas.impl.AllowPreexistingFS allowPreexisting)
                                                                throws java.io.IOException,
                                                                       ResourceInitializationException
Deserialize a CAS, in various binary formats, into an existing CAS Note: this form supports deserializing the following binary representations: - compressed, type filtering (form 6), delta and not-delta.

Parameters:
cas - the CAS to deserialize into. If the incoming representation is a Delta Cas, then the receiving CAS is not reset, but is added to.
istream - the input stream
tgtTypeSystem - The typeSystem of the serialized form of the CAS; must be compatible with the type system of the receiving cas.
reuseInfo - If delta CAS is being received and form 6 compression is being used, then this must be the reuseInfo captured when the original CAS (being updated by the delta coming in) was sent out.
allowPreexisting - used to control what happens when a delta cas is modifying Feature Structures below the line
Returns:
The instance of BinaryCasSerDes6 used for deserialization
Throws:
java.io.IOException - if IO exception
ResourceInitializationException - if the target type system and the CAS's type system can't be merged


Copyright © 2006–2014 The Apache Software Foundation. All rights reserved.