Package org.apache.uima.fit.factory
Class CasFactory
java.lang.Object
org.apache.uima.fit.factory.CasFactory
Convenience methods to create
CAS objects.-
Method Summary
Modifier and TypeMethodDescriptionstatic CASCreates a newCAS.static CASCreates a newCASfrom type system descriptor files found by name.static CAScreateCas(String fileName, TypeSystemDescription typeSystemDescription) This method creates a new CAS and loads the contents of an XMI or XCAS file into it.static CAScreateCas(TypeSystemDescription typeSystemDescription) Create a new CAS for the given type system description.static CAScreateCasFromPath(String... typeSystemDescriptorPaths) Creates a new CAS from type system descriptor files.static CAScreateText(String aText) Creates a new CAS with the given text.static CAScreateText(String aText, String aLanguage) Creates a new CAS with the given text and language.
-
Method Details
-
createText
Creates a new CAS with the given text. The type system is detected automatically usingTypeSystemDescriptionFactory.createTypeSystemDescription(). Type priorities are detected automatically usingTypePrioritiesFactory.createTypePriorities(). Indexes are detected automatically usingFsIndexFactory.createFsIndexCollection().- Parameters:
aText- the document text to be set in the new CAS.- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initialized
-
createText
Creates a new CAS with the given text and language. The type system is detected automatically usingTypeSystemDescriptionFactory.createTypeSystemDescription(). Type priorities are detected automatically usingTypePrioritiesFactory.createTypePriorities(). Indexes are detected automatically usingFsIndexFactory.createFsIndexCollection().- Parameters:
aText- the document text to be set in the new CAS.aLanguage- the document language to be set in the new CAS.- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initialized
-
createCas
Creates a newCAS. The type system is detected automatically usingTypeSystemDescriptionFactory.createTypeSystemDescription(). Type priorities are detected automatically usingTypePrioritiesFactory.createTypePriorities(). Indexes are detected automatically usingFsIndexFactory.createFsIndexCollection().- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initialized
-
createCas
public static CAS createCas(String... typeSystemDescriptorNames) throws ResourceInitializationException Creates a newCASfrom type system descriptor files found by name. No auto-detection for type priorities, or indexes is performed.- Parameters:
typeSystemDescriptorNames- names of the type system descriptors on the classpath used to initialize the CAS (in Java notation, e.g. "my.package.TypeSystem" without the ".xml" extension)- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initialized
-
createCasFromPath
public static CAS createCasFromPath(String... typeSystemDescriptorPaths) throws ResourceInitializationException Creates a new CAS from type system descriptor files. No auto-detection for type priorities, or indexes is performed.- Parameters:
typeSystemDescriptorPaths- paths to type system descriptor files- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initialized
-
createCas
public static CAS createCas(TypeSystemDescription typeSystemDescription) throws ResourceInitializationException Create a new CAS for the given type system description. No auto-detection type priorities, or indexes is performed.- Parameters:
typeSystemDescription- a type system description to initialize the CAS- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initialized
-
createCas
public static CAS createCas(String fileName, TypeSystemDescription typeSystemDescription) throws ResourceInitializationException, IOException This method creates a new CAS and loads the contents of an XMI or XCAS file into it.- Parameters:
fileName- a file name for the serialized CAS datatypeSystemDescription- a type system description to initialize the CAS- Returns:
- a new CAS
- Throws:
ResourceInitializationException- if the CAS could not be initializedIOException- if there is a problem reading the file
-