Package org.apache.uima.cas.impl

# Class Serialization

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

public class Serialization extends 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 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

  Constructors
  Constructor
  Description
  `Serialization()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static CAS`
  `createCAS(CASMgr casMgr, CASSerializer casSer)`
  Deserialize the data in a CASSerializer into an existing CAS, return the currentview in that Cas.
  `static CASMgr`
  `createCASMgr(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, 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 CAS
  `static 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 serialization
  `static 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 format
  `static CASCompleteSerializer`
  `serializeCASComplete(CASMgr casMgr)`
  Convert a CAS + the type system and index definitions into a CASCompleteSerializer object
  `static CASMgrSerializer`
  `serializeCASMgr(CASMgr casMgr)`
  Convert a Type System and Index Repository into a CASMgrSerializer object which can be serialized
  `static CASMgrSerializer`
  `serializeCASMgrTypeSystemOnly(CASMgr casMgr)`
  Convert a Type System into a CASMgrSerializer object which can be serialized
  `static CASSerializer`
  `serializeNoMetaData(CAS cas)`
  Convert a CAS to a CASSerializer object.
  `static void`
  `serializeWithCompression(CAS cas, Object out)`
  Serialize in compressed binary form 4
  `static 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 CAS
  `static 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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Serialization

    public Serialization()

- ## Method Details

  - ### serializeCAS

    public static 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 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 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

  - ### serializeCASMgrTypeSystemOnly

    public static CASMgrSerializer serializeCASMgrTypeSystemOnly(CASMgr casMgr)
    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

    public static 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(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(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, 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, 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, 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, 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, Object out) throws IOException
    Serialize in compressed binary form 4
    Parameters:
      `cas` - the CAS to serialize
      `out` - - an OutputStream, a DataOutputStream, or a File
    Throws:
      `IOException` - if IO exception

  - ### serializeWithCompression

    public static void serializeWithCompression(CAS cas, Object out, Marker marker) throws 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:
      `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 serialize
      `out` - an OutputStream, a DataOutputStream, or a File
      `includeTS` - true to serialize the type system
      `includeTSI` - 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 exception
      `ResourceInitializationException` - 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 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:
      `IOException` - if IO exception
      `ResourceInitializationException` - 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 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:
      `IOException` - if IO exception
      `ResourceInitializationException` - 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 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:
      `IOException` - if IO exception
      `ResourceInitializationException` - 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 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:
      `IOException` - if IO exception
      `ResourceInitializationException` - if the target type system and the CAS's type system can't be merged