You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2015/12/24 02:31:24 UTC
svn commit: r1721589 - in
/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit:
factory/CollectionReaderFactory.java factory/JCasFactory.java
pipeline/JCasIterable.java pipeline/SimplePipeline.java
testing/factory/TokenBuilder.java
Author: rec
Date: Thu Dec 24 01:31:24 2015
New Revision: 1721589
URL: http://svn.apache.org/viewvc?rev=1721589&view=rev
Log:
[UIMA-3562] Avoid throwing UIMAException
Modified:
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java
uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java
Modified: uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java?rev=1721589&r1=1721588&r2=1721589&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java (original)
+++ uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java Thu Dec 24 01:31:24 2015
@@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Map.Entry;
import org.apache.uima.Constants;
-import org.apache.uima.UIMAException;
import org.apache.uima.UIMAFramework;
import org.apache.uima.collection.CollectionReader;
import org.apache.uima.collection.CollectionReaderDescription;
@@ -51,6 +50,7 @@ import org.apache.uima.resource.metadata
import org.apache.uima.resource.metadata.ResourceMetaData;
import org.apache.uima.resource.metadata.TypePriorities;
import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.util.InvalidXMLException;
/**
*/
@@ -69,13 +69,16 @@ public final class CollectionReaderFacto
* Any additional configuration parameters to be set. These should be supplied as (name,
* value) pairs, so there should always be an even number of parameters.
* @return The CollectionReader created from the XML descriptor and the configuration parameters.
- * @throws UIMAException
- * if the descriptor could not be created or if the component could not be instantiated
+ * @throws InvalidXMLException
+ * if the descriptor could not be created
+ * @throws ResourceInitializationException
+ * if the component could not be instantiated
* @throws IOException
* if the descriptor could not be read
*/
public static CollectionReader createReaderFromPath(String descriptorPath,
- Object... configurationData) throws UIMAException, IOException {
+ Object... configurationData) throws InvalidXMLException, ResourceInitializationException,
+ IOException {
CollectionReaderDescription desc = createReaderDescriptionFromPath(descriptorPath,
configurationData);
return UIMAFramework.produceCollectionReader(desc, ResourceManagerFactory.newResourceManager(),
@@ -92,14 +95,17 @@ public final class CollectionReaderFacto
* value) pairs, so there should always be an even number of parameters.
* @return The CollectionReader created from the XML descriptor and the configuration parameters.
* @deprecated use {@link #createReaderFromPath(String, Object...)}
- * @throws UIMAException
- * if the descriptor could not be created or if the component could not be instantiated
+ * @throws InvalidXMLException
+ * if the descriptor could not be created
+ * @throws ResourceInitializationException
+ * if the component could not be instantiated
* @throws IOException
* if the descriptor could not be read
*/
@Deprecated
public static CollectionReader createCollectionReaderFromPath(String descriptorPath,
- Object... configurationData) throws UIMAException, IOException {
+ Object... configurationData) throws InvalidXMLException, ResourceInitializationException,
+ IOException {
return createReaderFromPath(descriptorPath, configurationData);
}
@@ -112,13 +118,13 @@ public final class CollectionReaderFacto
* Any additional configuration parameters to be set. These should be supplied as (name,
* value) pairs, so there should always be an even number of parameters.
* @return the description created from the XML descriptor and the configuration parameters.
- * @throws UIMAException
+ * @throws InvalidXMLException
* if the descriptor could not be created or if the component could not be instantiated
* @throws IOException
* if the descriptor could not be read
*/
public static CollectionReaderDescription createReaderDescriptionFromPath(String descriptorPath,
- Object... configurationData) throws UIMAException, IOException {
+ Object... configurationData) throws InvalidXMLException, IOException {
ResourceCreationSpecifier specifier = createResourceCreationSpecifier(descriptorPath,
configurationData);
return (CollectionReaderDescription) specifier;
@@ -134,14 +140,17 @@ public final class CollectionReaderFacto
* value) pairs, so there should always be an even number of parameters.
* @return The CollectionReader created from the XML descriptor and the configuration parameters.
* @deprecated use {@link #createReaderDescriptionFromPath(String, Object...)}
- * @throws UIMAException
- * if the descriptor could not be created or if the component could not be instantiated
+ * @throws InvalidXMLException
+ * if the descriptor could not be created
+ * @throws ResourceInitializationException
+ * if the component could not be instantiated
* @throws IOException
* if the descriptor could not be read
*/
@Deprecated
public static CollectionReaderDescription createCollectionReaderDescriptionFromPath(
- String descriptorPath, Object... configurationData) throws UIMAException, IOException {
+ String descriptorPath, Object... configurationData) throws InvalidXMLException,
+ ResourceInitializationException, IOException {
return createReaderDescriptionFromPath(descriptorPath, configurationData);
}
@@ -155,13 +164,15 @@ public final class CollectionReaderFacto
* Any additional configuration parameters to be set. These should be supplied as (name,
* value) pairs, so there should always be an even number of parameters.
* @return The AnalysisEngine created from the XML descriptor and the configuration parameters.
- * @throws UIMAException
- * if the descriptor could not be created or if the component could not be instantiated
+ * @throws InvalidXMLException
+ * if the descriptor could not be created
+ * @throws ResourceInitializationException
+ * if the component could not be instantiated
* @throws IOException
* if the descriptor could not be read
*/
- public static CollectionReader createReader(String descriptorName,
- Object... configurationData) throws UIMAException, IOException {
+ public static CollectionReader createReader(String descriptorName, Object... configurationData)
+ throws InvalidXMLException, ResourceInitializationException, IOException {
Import imp = UIMAFramework.getResourceSpecifierFactory().createImport();
imp.setName(descriptorName);
URL url = imp.findAbsoluteUrl(ResourceManagerFactory.newResourceManager());
@@ -181,14 +192,17 @@ public final class CollectionReaderFacto
* value) pairs, so there should always be an even number of parameters.
* @return The AnalysisEngine created from the XML descriptor and the configuration parameters.
* @deprecated use {@link #createReader(String, Object...)}
- * @throws UIMAException
- * if the descriptor could not be created or if the component could not be instantiated
+ * @throws InvalidXMLException
+ * if the descriptor could not be created
+ * @throws ResourceInitializationException
+ * if the component could not be instantiated
* @throws IOException
* if the descriptor could not be read
*/
@Deprecated
public static CollectionReader createCollectionReader(String descriptorName,
- Object... configurationData) throws UIMAException, IOException {
+ Object... configurationData) throws ResourceInitializationException, InvalidXMLException,
+ IOException {
return createReader(descriptorName, configurationData);
}
Modified: uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java?rev=1721589&r1=1721588&r2=1721589&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java (original)
+++ uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/factory/JCasFactory.java Thu Dec 24 01:31:24 2015
@@ -26,10 +26,11 @@ import static org.apache.uima.fit.factor
import java.io.File;
import java.io.IOException;
-import org.apache.uima.UIMAException;
+import org.apache.uima.cas.CASException;
import org.apache.uima.fit.internal.ResourceManagerFactory;
import org.apache.uima.fit.util.CasIOUtil;
import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceManager;
import org.apache.uima.resource.metadata.FsIndexCollection;
import org.apache.uima.resource.metadata.TypePriorities;
@@ -51,10 +52,12 @@ public final class JCasFactory {
* detected automatically using {@link FsIndexFactory#createFsIndexCollection()}.
*
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
*/
- public static JCas createText(String aText) throws UIMAException {
+ public static JCas createText(String aText) throws ResourceInitializationException, CASException {
return createText(aText, null);
}
@@ -65,10 +68,13 @@ public final class JCasFactory {
* detected automatically using {@link FsIndexFactory#createFsIndexCollection()}.
*
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
*/
- public static JCas createText(String aText, String aLanguage) throws UIMAException {
+ public static JCas createText(String aText, String aLanguage)
+ throws ResourceInitializationException, CASException {
JCas jcas = createJCas();
if (aText != null) {
jcas.setDocumentText(aText);
@@ -86,10 +92,12 @@ public final class JCasFactory {
* detected automatically using {@link FsIndexFactory#createFsIndexCollection()}.
*
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
*/
- public static JCas createJCas() throws UIMAException {
+ public static JCas createJCas() throws ResourceInitializationException, CASException {
TypeSystemDescription tsd = createTypeSystemDescription();
TypePriorities tp = createTypePriorities();
FsIndexCollection indexes = createFsIndexCollection();
@@ -105,10 +113,13 @@ public final class JCasFactory {
* names of the type system descriptors on the classpath used to initialize the JCas (in
* Java notation, e.g. "my.package.TypeSystem" without the ".xml" extension)
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
*/
- public static JCas createJCas(String... typeSystemDescriptorNames) throws UIMAException {
+ public static JCas createJCas(String... typeSystemDescriptorNames) throws CASException,
+ ResourceInitializationException {
return CasCreationUtils.createCas(createTypeSystemDescription(typeSystemDescriptorNames), null,
null).getJCas();
}
@@ -120,10 +131,13 @@ public final class JCasFactory {
* @param typeSystemDescriptorPaths
* paths to type system descriptor files
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
*/
- public static JCas createJCasFromPath(String... typeSystemDescriptorPaths) throws UIMAException {
+ public static JCas createJCasFromPath(String... typeSystemDescriptorPaths) throws CASException,
+ ResourceInitializationException {
return createJCas(createTypeSystemDescriptionFromPath(typeSystemDescriptorPaths));
}
@@ -134,10 +148,13 @@ public final class JCasFactory {
* @param typeSystemDescription
* a type system description to initialize the JCas
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
*/
- public static JCas createJCas(TypeSystemDescription typeSystemDescription) throws UIMAException {
+ public static JCas createJCas(TypeSystemDescription typeSystemDescription) throws CASException,
+ ResourceInitializationException {
return CasCreationUtils.createCas(typeSystemDescription, null, null).getJCas();
}
@@ -149,13 +166,15 @@ public final class JCasFactory {
* @param typeSystemDescription
* a type system description to initialize the JCas
* @return a new JCas
- * @throws UIMAException
+ * @throws ResourceInitializationException
+ * if the CAS configuration could not be assembled
+ * @throws CASException
* if the JCas could not be initialized
* @throws IOException
* if there is a problem reading the file
*/
public static JCas createJCas(String fileName, TypeSystemDescription typeSystemDescription)
- throws UIMAException, IOException {
+ throws IOException, CASException, ResourceInitializationException {
JCas jCas = createJCas(typeSystemDescription);
CasIOUtil.readJCas(jCas, new File(fileName));
return jCas;
Modified: uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java?rev=1721589&r1=1721588&r2=1721589&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java (original)
+++ uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/JCasIterable.java Thu Dec 24 01:31:24 2015
@@ -20,14 +20,15 @@ package org.apache.uima.fit.pipeline;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
-import org.apache.uima.UIMAException;
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.cas.CASException;
import org.apache.uima.collection.CollectionReader;
import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.fit.internal.ResourceManagerFactory;
import org.apache.uima.jcas.JCas;
+import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.ResourceManager;
/**
@@ -80,7 +81,7 @@ public class JCasIterable implements Ite
i.setSelfComplete(true);
i.setSelfDestroy(true);
return i;
- } catch (UIMAException e) {
+ } catch (CASException | ResourceInitializationException e) {
throw new IllegalStateException(e);
}
}
Modified: uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java?rev=1721589&r1=1721588&r2=1721589&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java (original)
+++ uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/pipeline/SimplePipeline.java Thu Dec 24 01:31:24 2015
@@ -22,16 +22,18 @@ import static java.util.Arrays.asList;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
import static org.apache.uima.fit.util.LifeCycleUtil.collectionProcessComplete;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.uima.UIMAException;
import org.apache.uima.UIMAFramework;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.admin.CASAdminException;
+import org.apache.uima.collection.CollectionException;
import org.apache.uima.collection.CollectionReader;
import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.fit.internal.ResourceManagerFactory;
@@ -68,13 +70,21 @@ public final class SimplePipeline {
* Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a mix
* of primitive and aggregate engines, then please create the AnalysisEngines yourself
* and call the other runPipeline method.
- * @throws UIMAException
- * if there is a problem initializing or running the CPE.
+ * @throws ResourceInitializationException
+ * if there is a problem initializing the pipeline.
* @throws IOException
- * if there is an I/O problem in the reader
+ * if there is an I/O problem in the reader.
+ * @throws CASAdminException
+ * if there is a problem resetting the CAS.
+ * @throws CollectionException
+ * if there is a problem running the pipeline.
+ * @throws AnalysisEngineProcessException
+ * if there is a problem running the pipeline.
*/
public static void runPipeline(final CollectionReader reader,
- final AnalysisEngineDescription... descs) throws UIMAException, IOException {
+ final AnalysisEngineDescription... descs) throws IOException,
+ ResourceInitializationException, AnalysisEngineProcessException, CollectionException,
+ CASAdminException {
// Create AAE
final AnalysisEngineDescription aaeDesc = createEngineDescription(descs);
@@ -120,13 +130,19 @@ public final class SimplePipeline {
* Primitive AnalysisEngineDescriptions that process the CAS, in order. If you have a mix
* of primitive and aggregate engines, then please create the AnalysisEngines yourself
* and call the other runPipeline method.
- * @throws UIMAException
- * if there is a problem initializing or running the CPE.
+ * @throws ResourceInitializationException
+ * if there is a problem initializing the pipeline.
* @throws IOException
- * if there is an I/O problem in the reader
+ * if there is an I/O problem in the reader.
+ * @throws CASAdminException
+ * if there is a problem resetting the CAS.
+ * @throws CollectionException
+ * if there is a problem running the pipeline.
+ * @throws AnalysisEngineProcessException
+ * if there is a problem running the pipeline.
*/
public static void runPipeline(final CollectionReaderDescription readerDesc,
- final AnalysisEngineDescription... descs) throws UIMAException, IOException {
+ final AnalysisEngineDescription... descs) throws IOException, ResourceInitializationException, AnalysisEngineProcessException, CollectionException, CASAdminException {
ResourceManager resMgr = ResourceManagerFactory.newResourceManager();
// Create the components
@@ -174,13 +190,20 @@ public final class SimplePipeline {
* a collection reader
* @param engines
* a sequence of analysis engines
- * @throws UIMAException
- * if there is a problem initializing or running the CPE.
+ * @throws ResourceInitializationException
+ * if there is a problem initializing the pipeline.
* @throws IOException
- * if there is an I/O problem in the reader
+ * if there is an I/O problem in the reader.
+ * @throws CASAdminException
+ * if there is a problem resetting the CAS.
+ * @throws CollectionException
+ * if there is a problem running the pipeline.
+ * @throws AnalysisEngineProcessException
+ * if there is a problem running the pipeline.
*/
public static void runPipeline(final CollectionReader reader, final AnalysisEngine... engines)
- throws UIMAException, IOException {
+ throws IOException, ResourceInitializationException, AnalysisEngineProcessException,
+ CollectionException, CASAdminException {
final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
metaData.add(reader.getMetaData());
for (AnalysisEngine engine : engines) {
Modified: uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java
URL: http://svn.apache.org/viewvc/uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java?rev=1721589&r1=1721588&r2=1721589&view=diff
==============================================================================
--- uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java (original)
+++ uima/uimafit/trunk/uimafit-core/src/main/java/org/apache/uima/fit/testing/factory/TokenBuilder.java Thu Dec 24 01:31:24 2015
@@ -21,7 +21,6 @@ package org.apache.uima.fit.testing.fact
import java.util.ArrayList;
import java.util.List;
-import org.apache.uima.UIMAException;
import org.apache.uima.cas.Feature;
import org.apache.uima.fit.factory.AnnotationFactory;
import org.apache.uima.jcas.JCas;