Package org.apache.uima.cas.impl
Class Serialization
java.lang.Object
org.apache.uima.cas.impl.Serialization
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 various custom 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.
See also CasIOUtils, which has static methods for serialization and deserialization, including
support for XMI and XCAS.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic CAS
createCAS
(CASMgr casMgr, CASSerializer casSer) Deserialize the data in a CASSerializer into an existing CAS, return the currentview in that Cas.static CASMgr
Deserialize a type system and index repository definition and use to initialize a new instance of a CAS.static SerialFormat
deserializeCAS
(CAS cas, 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 BinaryCasSerDes6
deserializeCAS
(CAS cas, InputStream istream, TypeSystem tgtTypeSystem, 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 BinaryCasSerDes6
deserializeCAS
(CAS cas, InputStream istream, TypeSystem tgtTypeSystem, BinaryCasSerDes6.ReuseInfo reuseInfo, 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
(CASCompleteSerializer casCompSer, CASMgr casMgr) Deserialize the data in a CASCompleteSerializer into an existing CASstatic CASSerializer
serializeCAS
(CAS cas) Convert a CAS to a CASSerializer object.static void
serializeCAS
(CAS cas, OutputStream ostream) Serialize a CAS including what's indexed, to an output stream Uses uncompressed binary serializationstatic void
serializeCAS
(CAS cas, 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 formatstatic CASCompleteSerializer
serializeCASComplete
(CASMgr casMgr) Convert a CAS + the type system and index definitions into a CASCompleteSerializer objectstatic CASMgrSerializer
serializeCASMgr
(CASMgr casMgr) Convert a Type System and Index Repository into a CASMgrSerializer object which can be serializedstatic CASMgrSerializer
serializeCASMgrTypeSystemOnly
(CASMgr casMgr) Convert a Type System into a CASMgrSerializer object which can be serializedstatic CASSerializer
serializeNoMetaData
(CAS cas) Convert a CAS to a CASSerializer object.static void
serializeWithCompression
(CAS cas, Object out) Serialize in compressed binary form 4static BinaryCasSerDes6.ReuseInfo
serializeWithCompression
(CAS cas, Object out, boolean includeTS, boolean includeTSI) 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, Object out, Marker marker) Serialize in compress binary form 4, only the delta part of a CASstatic BinaryCasSerDes6.ReuseInfo
serializeWithCompression
(CAS cas, 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, Object out, TypeSystem tgtTypeSystem, Marker mark, 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.
-
Constructor Details
-
Serialization
public Serialization()
-
-
Method Details
-
serializeCAS
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
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
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
-
serializeCASMgrTypeSystemOnly
Convert a Type System 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
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
Deserialize the data in a CASCompleteSerializer into an existing CAS- Parameters:
casCompSer
- the source for deserializationcasMgr
- the CAS to receive the data
-
createCASMgr
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
Deserialize the data in a CASSerializer into an existing CAS, return the currentview in that Cas.- Parameters:
casMgr
- the CAS ManagercasSer
- the serializer- Returns:
- the initialized CAS loaded with the deserialized data
-
serializeCAS
Serialize a CAS including what's indexed, to an output stream Uses uncompressed binary serialization- Parameters:
cas
- the CAS to serializeostream
- the output stream
-
deserializeCAS
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
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 serializeostream
- the output streammark
- the cas mark (for delta CASes)
-
serializeWithCompression
Serialize in compressed binary form 4- Parameters:
cas
- the CAS to serializeout
- - an OutputStream, a DataOutputStream, or a File- Throws:
IOException
- if IO exception
-
serializeWithCompression
Serialize in compress binary form 4, only the delta part of a CAS- Parameters:
cas
- the CAS to serializeout
- - an OutputStream, a DataOutputStream, or a Filemarker
- identifying where the delta starts- Throws:
IOException
- if IO exception
-
serializeWithCompression
public static BinaryCasSerDes6.ReuseInfo serializeWithCompression(CAS cas, Object out, boolean includeTS, boolean includeTSI) throws 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 serializeout
- an OutputStream, a DataOutputStream, or a FileincludeTS
- true to serialize the type systemincludeTSI
- true to serialize the type system and the indexes definition- Returns:
- information to be used on subsequent serializations (to save time) or deserializations (for receiving delta CASs), or reserializations (if sending delta CASs)
- Throws:
IOException
- if IO exceptionResourceInitializationException
- if target type system is incompatible with this CAS's type system
-
serializeWithCompression
public static BinaryCasSerDes6.ReuseInfo serializeWithCompression(CAS cas, Object out, TypeSystem tgtTypeSystem) throws 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 serializeout
- an OutputStream, a DataOutputStream, or a FiletgtTypeSystem
- 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:
IOException
- if IO exceptionResourceInitializationException
- if target type system is incompatible with this CAS's type system
-
serializeWithCompression
public static void serializeWithCompression(CAS cas, Object out, TypeSystem tgtTypeSystem, Marker mark, BinaryCasSerDes6.ReuseInfo reuseInfo) throws 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 serializeout
- an OutputStream, a DataOutputStream, or a FiletgtTypeSystem
- null or a target TypeSystem, which must be mergable with this CAS's type systemmark
- null or where the mark is in the CAS. If not null, indicates doing a delta CAS serializationreuseInfo
- 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:
IOException
- if IO exceptionResourceInitializationException
- if the target type system and the CAS's type system can't be merged
-
deserializeCAS
public static BinaryCasSerDes6 deserializeCAS(CAS cas, InputStream istream, TypeSystem tgtTypeSystem, BinaryCasSerDes6.ReuseInfo reuseInfo) throws 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 streamtgtTypeSystem
- 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:
IOException
- if IO exceptionResourceInitializationException
- if the target type system and the CAS's type system can't be merged
-
deserializeCAS
public static BinaryCasSerDes6 deserializeCAS(CAS cas, InputStream istream, TypeSystem tgtTypeSystem, BinaryCasSerDes6.ReuseInfo reuseInfo, AllowPreexistingFS allowPreexisting) throws 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 streamtgtTypeSystem
- 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:
IOException
- if IO exceptionResourceInitializationException
- if the target type system and the CAS's type system can't be merged
-