org.apache.uima.util
Class CasCopier

java.lang.Object
  extended by org.apache.uima.util.CasCopier

public class CasCopier
extends Object

Utility class for doing deep copies of FeatureStructures from one CAS to another. To handle cases where the source CAS has multiple references to the same FS, you can create one instance of CasCopier and use it to copy multiple FeatureStructures. The CasCopier will remember previously copied FeatureStructures, so if you later copy another FS that has a reference to a previously copied FS, it will not duplicate the multiply-referenced FS.


Constructor Summary
CasCopier(CAS aSrcCas, CAS aDestCas)
          Creates a new CasCopier that can be used to copy FeatureStructures from one CAS to another.
 
Method Summary
 boolean alreadyCopied(FeatureStructure aFS)
          Returns whether the given FS has already been copied using this CasCopier.
static void copyCas(CAS aSrcCas, CAS aDestCas, boolean aCopySofa)
          Does a complete deep copy of one CAS into another CAS.
 void copyCasView(CAS aSrcCasView, boolean aCopySofa)
          Does a deep copy of the contents of one CAS View into another CAS.
 FeatureStructure copyFs(FeatureStructure aFS)
          Copies an FS from the source CAS to the destination CAS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CasCopier

public CasCopier(CAS aSrcCas,
                 CAS aDestCas)
Creates a new CasCopier that can be used to copy FeatureStructures from one CAS to another. Note that if you are merging data from multiple CASes, you must create a new CasCopier for each source CAS.

Parameters:
aSrcCas - the CAS to copy from.
aDestCas - the CAS to copy into.
Method Detail

copyCas

public static void copyCas(CAS aSrcCas,
                           CAS aDestCas,
                           boolean aCopySofa)
Does a complete deep copy of one CAS into another CAS. The contents of each view in the source CAS will be copied to the same-named view in the destination CAS. If the view does not already exist it will be created. All FeatureStructures that are indexed in a view in the source CAS will become indexed in the same-named view in the destination CAS.

Parameters:
aSrcCas - the CAS to copy from
aDestCas - the CAS to copy to
aCopySofa - if true, the sofa data and mimeType of each view will be copied. If false they will not.

copyCasView

public void copyCasView(CAS aSrcCasView,
                        boolean aCopySofa)
Does a deep copy of the contents of one CAS View into another CAS. If a view with the same name as aSrcCasView exists in the destination CAS, then it will be the target of the copy. Otherwise, a new view will be created with that name and will become the target of the copy. All FeatureStructures that are indexed in the source CAS view will become indexed in the target view.

Parameters:
aSrcCasView - the CAS to copy from
aCopySofa - if true, the sofa data and mimeType will be copied. If false they will not.

copyFs

public FeatureStructure copyFs(FeatureStructure aFS)
Copies an FS from the source CAS to the destination CAS. Also copies any referenced FS, except that previously copied FS will not be copied again.

Parameters:
aFS - the FS to copy. Must be contained within the source CAS.
Returns:
the copy of aFS in the target CAS.

alreadyCopied

public boolean alreadyCopied(FeatureStructure aFS)
Returns whether the given FS has already been copied using this CasCopier.

Parameters:
aFS -
Returns:


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.