You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/01/19 14:08:20 UTC
svn commit: r497800 [1/10] - in /incubator/uima/uimaj/trunk/uimaj-core/src:
main/java/org/apache/uima/cas/ main/java/org/apache/uima/cas/impl/
main/java/org/apache/uima/jcas/cas/ main/java/org/apache/uima/jcas/impl/
main/resources/org/apache/uima/ main...
Author: twgoetz
Date: Fri Jan 19 05:08:19 2007
New Revision: 497800
URL: http://svn.apache.org/viewvc?view=rev&rev=497800
Log:
Jira UIMA-185: make CASRuntimeException inherit from UIMAException.
https://issues.apache.org/jira/browse/UIMA-185
Removed:
incubator/uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/cas/cas_runtime_exception.properties
Modified:
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationTreeNodeImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSTypeConstraintImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureValuePathImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSList.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FloatList.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/IntegerList.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/Sofa.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/StringList.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/TOP.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/cas/TOP_Type.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java
incubator/uima/uimaj/trunk/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/ArrayFSTest.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/CASTest.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/FeatureStructureTest.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/FloatArrayFSTest.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/IntArrayFSTest.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/StringArrayTest.java
incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/jcas/test/JCasTest.java
Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java?view=diff&rev=497800&r1=497799&r2=497800
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java Fri Jan 19 05:08:19 2007
@@ -19,221 +19,180 @@
package org.apache.uima.cas;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import org.apache.uima.UIMARuntimeException;
/**
- * Exception class for package org.apache.uima.cas. Automatically generated from message catalog.
+ * Runtime exception class for package org.apache.uima.cas.
*/
-public class CASRuntimeException extends RuntimeException {
+public class CASRuntimeException extends UIMARuntimeException {
- private static final long serialVersionUID = 2597111625069248081L;
+ private static final long serialVersionUID = 2597111625069248081L;
- private static final String resource_file = "org.apache.uima.cas.cas_runtime_exception";
+ /** Can''t create FS of type "{0}" with this method. */
+ public static final String NON_CREATABLE_TYPE = "NON_CREATABLE_TYPE";
- private static final String missing_resource_error = "Could not load message catalog: "
- + resource_file;
+ /** Array size must be >= 0. */
+ public static final String ILLEGAL_ARRAY_SIZE = "ILLEGAL_ARRAY_SIZE";
- private static final int MESSAGES_NOT_FOUND = -1;
+ /** Expected value of type "{0}", but found "{1}". */
+ public static final String INAPPROP_TYPE = "INAPPROP_TYPE";
- /** Can''t create FS of type "{0}" with this method. */
- public static final int NON_CREATABLE_TYPE = 0;
+ /** Feature "{0}" is not defined for type "{1}". */
+ public static final String INAPPROP_FEAT = "INAPPROP_FEAT";
- /** Array size must be >= 0. */
- public static final int ILLEGAL_ARRAY_SIZE = 1;
-
- /** Expected value of type "{0}", but found "{1}". */
- public static final int INAPPROP_TYPE = 2;
-
- /** Feature "{0}" is not defined for type "{1}". */
- public static final int INAPPROP_FEAT = 3;
-
- /** Trying to access value of feature "{0}" as "{1}", but range of feature is "{2}". */
- public static final int INAPPROP_RANGE = 4;
+ /**
+ * Trying to access value of feature "{0}" as "{1}", but range of feature is "{2}".
+ */
+ public static final String INAPPROP_RANGE = "INAPPROP_RANGE";
- /** Trying to access value of feature "{0}" as feature structure, but is primitive type. */
- public static final int PRIMITIVE_VAL_FEAT = 5;
+ /**
+ * Trying to access value of feature "{0}" as feature structure, but is primitive type.
+ */
+ public static final String PRIMITIVE_VAL_FEAT = "PRIMITIVE_VAL_FEAT";
- /** Error accessing type system: the type system has not been committed. */
- public static final int TYPESYSTEM_NOT_LOCKED = 6;
+ /** Error accessing type system: the type system has not been committed. */
+ public static final String TYPESYSTEM_NOT_LOCKED = "TYPESYSTEM_NOT_LOCKED";
- /** Error setting string value: string "{0}" is not valid for a value of type "{1}". */
- public static final int ILLEGAL_STRING_VALUE = 7;
+ /**
+ * Error setting string value: string "{0}" is not valid for a value of type "{1}".
+ */
+ public static final String ILLEGAL_STRING_VALUE = "ILLEGAL_STRING_VALUE";
- /** Error applying FS constraint: no type "{0}" in current type system. */
- public static final int UNKNOWN_CONSTRAINT_TYPE = 8;
+ /** Error applying FS constraString: no type "{0}" in current type system. */
+ public static final String UNKNOWN_CONSTRAINT_TYPE = "UNKNOWN_CONSTRAINT_TYPE";
- /** Error applying FS constraint: no feature "{0}" in current type system. */
- public static final int UNKNOWN_CONSTRAINT_FEAT = 9;
+ /**
+ * Error applying FS constraString: no feature "{0}" in current type system.
+ */
+ public static final String UNKNOWN_CONSTRAINT_FEAT = "UNKNOWN_CONSTRAINT_FEAT";
- /** Error accessing child node in tree, index out of range. */
- public static final int CHILD_INDEX_OOB = 10;
+ /** Error accessing child node in tree, index out of range. */
+ public static final String CHILD_INDEX_OOB = "CHILD_INDEX_OOB";
- /** CAS type system doesn''t match JCas Type definition for type "{0}". */
- public static final int JCAS_CAS_MISMATCH = 11;
+ /** CAS type system doesn''t match JCas Type definition for type "{0}". */
+ public static final String JCAS_CAS_MISMATCH = "JCAS_CAS_MISMATCH";
- /** JCas type "{0}" used in Java code, but was not declared in the XML type descriptor. */
- public static final int JCAS_TYPE_NOT_IN_CAS = 12;
+ /**
+ * JCas type "{0}" used in Java code, but was not declared in the XML type descriptor.
+ */
+ public static final String JCAS_TYPE_NOT_IN_CAS = "JCAS_TYPE_NOT_IN_CAS";
- /**
+ /**
* Unknown JCas type used in Java code but was not declared or imported in the XML descriptor for
* this component.
*/
- public static final int JCAS_UNKNOWN_TYPE_NOT_IN_CAS = 13;
+ public static final String JCAS_UNKNOWN_TYPE_NOT_IN_CAS = "JCAS_UNKNOWN_TYPE_NOT_IN_CAS";
- /** JCas getNthElement method called via invalid object - an empty list: {0}. */
- public static final int JCAS_GET_NTH_ON_EMPTY_LIST = 14;
+ /**
+ * JCas getNthElement method called via invalid object - an empty list: {0}.
+ */
+ public static final String JCAS_GET_NTH_ON_EMPTY_LIST = "JCAS_GET_NTH_ON_EMPTY_LIST";
- /** JCas getNthElement method called with index "{0}" which is negative. */
- public static final int JCAS_GET_NTH_NEGATIVE_INDEX = 15;
+ /** JCas getNthElement method called with index "{0}" which is negative. */
+ public static final String JCAS_GET_NTH_NEGATIVE_INDEX = "JCAS_GET_NTH_NEGATIVE_INDEX";
- /** JCas getNthElement method called with index "{0}" larger than the length of the list. */
- public static final int JCAS_GET_NTH_PAST_END = 16;
+ /**
+ * JCas getNthElement method called with index "{0}" larger than the length of the list.
+ */
+ public static final String JCAS_GET_NTH_PAST_END = "JCAS_GET_NTH_PAST_END";
- /**
+ /**
* JCas is referencing via a JFSIterator or get method, a type, "{0}", which has no JCAS class
* model. You must use FSIterator instead of JFSIterator.
*/
- public static final int JCAS_OLDSTYLE_REF_TO_NONJCAS_TYPE = 17;
+ public static final String JCAS_OLDSTYLE_REF_TO_NONJCAS_TYPE = "JCAS_OLDSTYLE_REF_TO_NONJCAS_TYPE";
- /**
+ /**
* A CAS iterator or createFS call is trying to make an instance of type "{0}", but that type has
* been declared "abstract" in JCas, and no instances are allowed to be made.
*/
- public static final int JCAS_MAKING_ABSTRACT_INSTANCE = 18;
+ public static final String JCAS_MAKING_ABSTRACT_INSTANCE = "JCAS_MAKING_ABSTRACT_INSTANCE";
- /**
+ /**
* The method "{0}" is not supported by this JCAS because it is not associated with a CAS view of
* a CAS, but rather just with a base CAS.
*/
- public static final int JCAS_UNSUPPORTED_OP_NOT_CAS = 19;
+ public static final String JCAS_UNSUPPORTED_OP_NOT_CAS = "JCAS_UNSUPPORTED_OP_NOT_CAS";
- /** A sofaFS with name {0} has already been created. */
- public static final int SOFANAME_ALREADY_EXISTS = 20;
+ /** A sofaFS with name {0} has already been created. */
+ public static final String SOFANAME_ALREADY_EXISTS = "SOFANAME_ALREADY_EXISTS";
- /** Data for Sofa feature {0} has already been set. */
- public static final int SOFADATA_ALREADY_SET = 21;
+ /** Data for Sofa feature {0} has already been set. */
+ public static final String SOFADATA_ALREADY_SET = "SOFADATA_ALREADY_SET";
- /** No sofaFS with name {0} found. */
- public static final int SOFANAME_NOT_FOUND = 22;
+ /** No sofaFS with name {0} found. */
+ public static final String SOFANAME_NOT_FOUND = "SOFANAME_NOT_FOUND";
- /** No sofaFS for specified sofaRef found. */
- public static final int SOFAREF_NOT_FOUND = 23;
+ /** No sofaFS for specified sofaRef found. */
+ public static final String SOFAREF_NOT_FOUND = "SOFAREF_NOT_FOUND";
- /** Can''t use standard set methods with SofaFS features. */
- public static final int PROTECTED_SOFA_FEATURE = 24;
+ /** Can''t use standard set methods with SofaFS features. */
+ public static final String PROTECTED_SOFA_FEATURE = "PROTECTED_SOFA_FEATURE";
- /** The JCAS cover class "{0}" could not be loaded. */
- public static final int JCAS_MISSING_COVERCLASS = 25;
+ /** The JCAS cover class "{0}" could not be loaded. */
+ public static final String JCAS_MISSING_COVERCLASS = "JCAS_MISSING_COVERCLASS";
- /** The feature path "{0}" is not valid. */
- public static final int INVALID_FEATURE_PATH = 26;
+ /** The feature path "{0}" is not valid. */
+ public static final String INVALID_FEATURE_PATH = "INVALID_FEATURE_PATH";
- /** The feature path does not end in a primitive valued feature. */
- public static final int NO_PRIMITIVE_TAIL = 27;
+ /** The feature path does not end in a primitive valued feature. */
+ public static final String NO_PRIMITIVE_TAIL = "NO_PRIMITIVE_TAIL";
- /** Error trying to do binary serialization of CAS data and write the BLOB to an output stream. */
- public static final int BLOB_SERIALIZATION = 28;
+ /**
+ * Error trying to do binary serialization of CAS data and write the BLOB to an output stream.
+ */
+ public static final String BLOB_SERIALIZATION = "BLOB_SERIALIZATION";
- /** Error trying to read BLOB data from an input stream and deserialize into a CAS. */
- public static final int BLOB_DESERIALIZATION = 29;
+ /**
+ * Error trying to read BLOB data from an input stream and deserialize Stringo a CAS.
+ */
+ public static final String BLOB_DESERIALIZATION = "BLOB_DESERIALIZATION";
- /** Error trying to open a stream to Sofa data. */
- public static final int SOFADATASTREAM_ERROR = 30;
+ /** Error trying to open a stream to Sofa data. */
+ public static final String SOFADATASTREAM_ERROR = "SOFADATASTREAM_ERROR";
- /** Can''t call method "{0}" on the base CAS. */
- public static final int INVALID_BASE_CAS_METHOD = 31;
+ /** Can''t call method "{0}" on the base CAS. */
+ public static final String INVALID_BASE_CAS_METHOD = "INVALID_BASE_CAS_METHOD";
- /**
+ /**
* Error - the Annotation "{0}" is over view "{1}" and cannot be added to indexes associated with
* the different view "{2}".
*/
- public static final int ANNOTATION_IN_WRONG_INDEX = 32;
+ public static final String ANNOTATION_IN_WRONG_INDEX = "ANNOTATION_IN_WRONG_INDEX";
- /**
- * Error accessing index "{0}" for type "{1}". Index "{0}" is over type "{2}", which is not a supertype of "{1}".
- */
- public static final int TYPE_NOT_IN_INDEX = 33;
-
- private static final String[] identifiers = { "NON_CREATABLE_TYPE", "ILLEGAL_ARRAY_SIZE",
- "INAPPROP_TYPE", "INAPPROP_FEAT", "INAPPROP_RANGE", "PRIMITIVE_VAL_FEAT",
- "TYPESYSTEM_NOT_LOCKED", "ILLEGAL_STRING_VALUE", "UNKNOWN_CONSTRAINT_TYPE",
- "UNKNOWN_CONSTRAINT_FEAT", "CHILD_INDEX_OOB", "JCAS_CAS_MISMATCH", "JCAS_TYPE_NOT_IN_CAS",
- "JCAS_UNKNOWN_TYPE_NOT_IN_CAS", "JCAS_GET_NTH_ON_EMPTY_LIST", "JCAS_GET_NTH_NEGATIVE_INDEX",
- "JCAS_GET_NTH_PAST_END", "JCAS_OLDSTYLE_REF_TO_NONJCAS_TYPE",
- "JCAS_MAKING_ABSTRACT_INSTANCE", "JCAS_UNSUPPORTED_OP_NOT_CAS", "SOFANAME_ALREADY_EXISTS",
- "SOFADATA_ALREADY_SET", "SOFANAME_NOT_FOUND", "SOFAREF_NOT_FOUND", "PROTECTED_SOFA_FEATURE",
- "JCAS_MISSING_COVERCLASS", "INVALID_FEATURE_PATH", "NO_PRIMITIVE_TAIL", "BLOB_SERIALIZATION",
- "BLOB_DESERIALIZATION", "SOFADATASTREAM_ERROR", "INVALID_BASE_CAS_METHOD",
- "ANNOTATION_IN_WRONG_INDEX", "TYPE_NOT_IN_INDEX" };
-
- private int error;
-
- private ResourceBundle resource = null;
-
- private Object[] arguments = new Object[9];
-
- /**
- * Create a new <code>CASRuntimeException</code>
- *
- * @param error
- * The error code.
- */
- public CASRuntimeException(int error) {
- this.error = error;
- }
-
- /**
- * @return The error code for the exception. This may be useful when the error needs to be handed
- * over language boundaries. Instead of handing over the complete exception object, return
- * the error code, and the receiving application can look up the error in the message
- * file. Unfortunately, the error parameters get lost that way.
- */
- public int getError() {
- return error;
- }
-
- /**
- * @return The message of the exception. Useful for including the text in another exception.
- */
- public String getMessage() {
- if (resource == null) {
- try {
- resource = ResourceBundle.getBundle(resource_file);
- } catch (MissingResourceException e) {
- error = MESSAGES_NOT_FOUND;
- return missing_resource_error;
- }
- }
- // Retrieve message from resource bundle, format using arguments,
- // and return resulting string.
- return (new MessageFormat(resource.getString(identifiers[error]))).format(arguments);
- }
-
- /** @return The same as getMessage(), but prefixed with <code>"CASRuntimeException: "</code>. */
- public String toString() {
- return "CASRuntimeException: " + this.getMessage();
- }
-
- /**
- * Add an argument to a <code>CASRuntimeException</code> object. Excess arguments will be
- * ignored, and missing arguments will have the value <code>null</code>. Add arguments in the
- * order in which they are specified in the message catalog (i.e. add %1 first, %2 next, and so
- * on). Adding a <code>null String</code> has no effect! So if you don't know the value of an
- * argument, use something like <code>""</code> or <code>"UNKNOWN"</code>, but not
- * <code>null</code>.
- */
- public boolean addArgument(String s) {
- int i = 0;
- while (i < arguments.length) {
- if (arguments[i] == null) {
- arguments[i] = s;
- return true;
- }
- i++;
- }
- return false;
- }
+ /**
+ * Error accessing index "{0}" for type "{1}". Index "{0}" is over type "{2}", which is not a
+ * supertype of "{1}".
+ */
+ public static final String TYPE_NOT_IN_INDEX = "TYPE_NOT_IN_INDEX";
+
+ public CASRuntimeException() {
+ super();
+ }
+
+ public CASRuntimeException(String messageKey) {
+ super(messageKey, null);
+ }
+
+ public CASRuntimeException(String aMessageKey, Object[] aArguments, Throwable aCause) {
+ super(aMessageKey, aArguments, aCause);
+ }
+
+ public CASRuntimeException(String aMessageKey, Object[] aArguments) {
+ super(aMessageKey, aArguments);
+ }
+
+ public CASRuntimeException(String aResourceBundleName, String aMessageKey, Object[] aArguments,
+ Throwable aCause) {
+ super(aResourceBundleName, aMessageKey, aArguments, aCause);
+ }
+
+ public CASRuntimeException(String aResourceBundleName, String aMessageKey, Object[] aArguments) {
+ super(aResourceBundleName, aMessageKey, aArguments);
+ }
+
+ public CASRuntimeException(Throwable aCause) {
+ super(aCause);
+ }
}
Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationTreeNodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationTreeNodeImpl.java?view=diff&rev=497800&r1=497799&r2=497800
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationTreeNodeImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationTreeNodeImpl.java Fri Jan 19 05:08:19 2007
@@ -76,7 +76,7 @@
try {
return (AnnotationTreeNode) this.dtrs.get(i);
} catch (IndexOutOfBoundsException e) {
- throw new CASRuntimeException(CASRuntimeException.CHILD_INDEX_OOB);
+ throw new CASRuntimeException(CASRuntimeException.CHILD_INDEX_OOB, null);
}
}