You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2016/03/07 22:50:09 UTC
svn commit: r1733992 [2/2] - in
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima:
cas/impl/ jcas/cas/ jcas/tcas/ util/
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl.java Mon Mar 7 21:50:08 2016
@@ -35,22 +35,6 @@ import org.apache.uima.cas.Feature;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.admin.CASAdminException;
-import org.apache.uima.cas.function.JCas_getter_boolean;
-import org.apache.uima.cas.function.JCas_getter_byte;
-import org.apache.uima.cas.function.JCas_getter_double;
-import org.apache.uima.cas.function.JCas_getter_float;
-import org.apache.uima.cas.function.JCas_getter_generic;
-import org.apache.uima.cas.function.JCas_getter_int;
-import org.apache.uima.cas.function.JCas_getter_long;
-import org.apache.uima.cas.function.JCas_getter_short;
-import org.apache.uima.cas.function.JCas_setter_boolean;
-import org.apache.uima.cas.function.JCas_setter_byte;
-import org.apache.uima.cas.function.JCas_setter_double;
-import org.apache.uima.cas.function.JCas_setter_float;
-import org.apache.uima.cas.function.JCas_setter_generic;
-import org.apache.uima.cas.function.JCas_setter_int;
-import org.apache.uima.cas.function.JCas_setter_long;
-import org.apache.uima.cas.function.JCas_setter_short;
import org.apache.uima.cas.impl.SlotKinds.SlotKind;
import org.apache.uima.util.Misc;
@@ -84,8 +68,8 @@ public class TypeImpl implements Type, C
* set when type is committed and JCas cover classes are loaded
*/
protected Class<?> javaClass;
- final protected Class<?> getter_funct_intfc_class;
- final protected Class<?> setter_funct_intfc_class;
+// final protected Class<?> getter_funct_intfc_class;
+// final protected Class<?> setter_funct_intfc_class;
/* ***************** boolean flags *****************/
protected boolean isFeatureFinal;
@@ -113,6 +97,9 @@ public class TypeImpl implements Type, C
/* ***************** type hierarchy *****************/
private final TypeImpl superType;
+ /**
+ * All supertypes, in order, starting with immediate (nearest) supertype
+ */
private final List<TypeImpl> allSuperTypes = new ArrayList<>();
private final List<TypeImpl> directSubtypes = new ArrayList<>();
@@ -123,11 +110,20 @@ public class TypeImpl implements Type, C
private final List<FeatureImpl> staticMergedFeaturesIntroducedByThisType = new ArrayList<>(0);
/**
+ * Map from adjusted offset in int features to feature
+ */
+ private final List<FeatureImpl> staticMergedIntFeaturesList = new ArrayList<>(0);
+ /**
+ * Map from adjusted offset in ref features to feature
+ */
+ private final List<FeatureImpl> staticMergedRefFeaturesList = new ArrayList<>(0);
+
+ /**
* The number of used slots needed = total number of features minus those represented by fields in JCas cover classes
*/
int nbrOfUsedIntDataSlots = -1;
int nbrOfUsedRefDataSlots = -1;
-
+
// for journalling allocation: This is a 0-based offset for all features in feature order
int highestOffset = -1;
@@ -145,8 +141,8 @@ public class TypeImpl implements Type, C
this.isRefType = false;
this.javaClass = null;
- getter_funct_intfc_class = null;
- setter_funct_intfc_class = null;
+// getter_funct_intfc_class = null;
+// setter_funct_intfc_class = null;
slotKind = TypeSystemImpl.getSlotKindFromType(this);
}
@@ -155,7 +151,7 @@ public class TypeImpl implements Type, C
* Create a new type. This should only be done by a <code>TypeSystemImpl</code>.
*/
TypeImpl(String name, TypeSystemImpl tsi, final TypeImpl supertype) {
- this(name, tsi,supertype, FeatureStructureImplC.class);
+ this(name, tsi, supertype, supertype.javaClass);
}
TypeImpl(String name, TypeSystemImpl tsi, final TypeImpl supertype, Class<?> javaClass) {
@@ -201,31 +197,31 @@ public class TypeImpl implements Type, C
this.javaClass = javaClass;
tsi.typeName2TypeImpl.put(name, this);
- if (javaClass == boolean.class) {
- getter_funct_intfc_class = JCas_getter_boolean.class;
- setter_funct_intfc_class = JCas_setter_boolean.class;
- } else if (javaClass == byte.class) {
- getter_funct_intfc_class = JCas_getter_byte.class;
- setter_funct_intfc_class = JCas_setter_byte.class;
- } else if (javaClass == short.class) {
- getter_funct_intfc_class = JCas_getter_short.class;
- setter_funct_intfc_class = JCas_setter_short.class;
- } else if (javaClass == int.class) {
- getter_funct_intfc_class = JCas_getter_int.class;
- setter_funct_intfc_class = JCas_setter_int.class;
- } else if (javaClass == long.class) {
- getter_funct_intfc_class = JCas_getter_long.class;
- setter_funct_intfc_class = JCas_setter_long.class;
- } else if (javaClass == float.class) {
- getter_funct_intfc_class = JCas_getter_float.class;
- setter_funct_intfc_class = JCas_setter_float.class;
- } else if (javaClass == double.class) {
- getter_funct_intfc_class = JCas_getter_double.class;
- setter_funct_intfc_class = JCas_setter_double.class;
- } else {
- getter_funct_intfc_class = JCas_getter_generic.class;
- setter_funct_intfc_class = JCas_setter_generic.class;
- }
+// if (javaClass == boolean.class) {
+// getter_funct_intfc_class = JCas_getter_boolean.class;
+// setter_funct_intfc_class = JCas_setter_boolean.class;
+// } else if (javaClass == byte.class) {
+// getter_funct_intfc_class = JCas_getter_byte.class;
+// setter_funct_intfc_class = JCas_setter_byte.class;
+// } else if (javaClass == short.class) {
+// getter_funct_intfc_class = JCas_getter_short.class;
+// setter_funct_intfc_class = JCas_setter_short.class;
+// } else if (javaClass == int.class) {
+// getter_funct_intfc_class = JCas_getter_int.class;
+// setter_funct_intfc_class = JCas_setter_int.class;
+// } else if (javaClass == long.class) {
+// getter_funct_intfc_class = JCas_getter_long.class;
+// setter_funct_intfc_class = JCas_setter_long.class;
+// } else if (javaClass == float.class) {
+// getter_funct_intfc_class = JCas_getter_float.class;
+// setter_funct_intfc_class = JCas_setter_float.class;
+// } else if (javaClass == double.class) {
+// getter_funct_intfc_class = JCas_getter_double.class;
+// setter_funct_intfc_class = JCas_setter_double.class;
+// } else {
+// getter_funct_intfc_class = JCas_getter_generic.class;
+// setter_funct_intfc_class = JCas_setter_generic.class;
+// }
slotKind = TypeSystemImpl.getSlotKindFromType(this);
@@ -651,7 +647,7 @@ public class TypeImpl implements Type, C
}
@Override
- public Type getComponentType() {
+ public TypeImpl getComponentType() {
return null; // not an array, array subtype overrides
}
@@ -673,6 +669,10 @@ public class TypeImpl implements Type, C
boolean hasSupertype(TypeImpl supertype) {
return allSuperTypes.contains(supertype);
}
+
+ List<TypeImpl> getAllSuperTypes() {
+ return allSuperTypes;
+ }
// public <T extends FeatureStructure> T createFS(CAS cas) {
// if (null == creator) {
@@ -747,10 +747,11 @@ public class TypeImpl implements Type, C
}
public boolean subsumesValue(Object v) {
- return (v == null) ||
+ return (isRefType && v == null) ||
(v instanceof String && typeCode == TypeSystemImpl.stringTypeCode) ||
((v instanceof FeatureStructureImplC) &&
- subsumes( ((FeatureStructureImplC)v)._typeImpl));
+ subsumes( ((FeatureStructureImplC)v)._typeImpl)) ||
+ this.getCode() == TypeSystemImpl.javaObjectTypeCode;
}
int computeDepthFirstCode(int level) {
@@ -764,7 +765,7 @@ public class TypeImpl implements Type, C
**************************************************************************************/
if (level != 1) {
// skip for top level; no features there, but no super type either
- computeStaticMergedFeaturesList();
+ getFeatureImpls(); // also done for side effect of computingcomputeStaticMergedFeaturesList();
computeHasRef();
}
@@ -815,6 +816,32 @@ public class TypeImpl implements Type, C
return isHeapStoredArray() ? (2 + length) : isArray() ? 3 : getFsSpaceReq();
}
+ void setOffset2Feat(FeatureImpl fi, int next) {
+ if (fi.isInInt) {
+ assert staticMergedIntFeaturesList.size() == next;
+ staticMergedIntFeaturesList.add(fi);
+ if (fi.getRangeImpl().isLongOrDouble) {
+ staticMergedIntFeaturesList.add(null);
+ }
+ } else {
+ assert staticMergedRefFeaturesList.size() == next;
+ staticMergedRefFeaturesList.add(fi);
+ }
+ }
+
+ void initAdjOffset2FeatureMaps() {
+ staticMergedIntFeaturesList.addAll(superType.staticMergedIntFeaturesList);
+ staticMergedRefFeaturesList.addAll(superType.staticMergedRefFeaturesList);
+ }
+
+ FeatureImpl getFeatureByAdjOffset(int adjOffset, boolean isInInt) {
+ if (isInInt) {
+ return staticMergedIntFeaturesList.get(adjOffset);
+ } else {
+ return staticMergedRefFeaturesList.get(adjOffset);
+ }
+ }
+
/**
* A special instance used in CasCopier to identify a missing type
*/
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java Mon Mar 7 21:50:08 2016
@@ -42,7 +42,7 @@ public class TypeImpl_array extends Type
}
@Override
- public Type getComponentType() {
+ public TypeImpl getComponentType() {
return componentType;
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java Mon Mar 7 21:50:08 2016
@@ -63,7 +63,7 @@ import org.apache.uima.cas.TypeNameSpace
import org.apache.uima.cas.TypeSystem;
import org.apache.uima.cas.admin.CASAdminException;
import org.apache.uima.cas.admin.TypeSystemMgr;
-import org.apache.uima.cas.impl.FSClassRegistry.GetterSetter;
+import org.apache.uima.cas.impl.FSClassRegistry.JCasClassInfo;
import org.apache.uima.cas.impl.SlotKinds.SlotKind;
import org.apache.uima.jcas.JCasRegistry;
import org.apache.uima.jcas.cas.AnnotationBase;
@@ -285,7 +285,14 @@ public class TypeSystemImpl implements T
CAS.TYPE_NAME_JAVA_OBJECT_ARRAY);
}
- final private static Map<TypeSystemImpl, WeakReference<TypeSystemImpl>> committedTypeSystems = Collections.synchronizedMap(new WeakHashMap<>());
+ final private static Map<TypeSystemImpl, WeakReference<TypeSystemImpl>> committedTypeSystems = Collections.synchronizedMap(new WeakHashMap<>());
+
+ /**
+ * used to pass the type being loaded reference to the JCas static initializer code,
+ * referenced from the TypeSystemImpl.getAdjustedFeatureOffset([featurename]) method.
+ */
+ public final static ThreadLocal<TypeImpl> typeBeingLoadedThreadLocal = new ThreadLocal<TypeImpl>();
+
/******************************************
* I N S T A N C E V A R I A B L E S *
******************************************/
@@ -295,6 +302,11 @@ public class TypeSystemImpl implements T
private FSClassRegistry fsClassRegistry; // a new instance is created at commit time.
+ // the loaded JCas cover classes, generators. index is typecode; value is JCas cover class which may belong to a supertype.
+ // OK because the instance of this class FSClassRegistry is one per Type System
+ // not final because set after all types are defined and committed
+ JCasClassInfo[] jcasClassesInfo;
+
/**
* Map from built-in array name to component Type
*/
@@ -460,36 +472,39 @@ public class TypeSystemImpl implements T
intArrayType = addArrayType(intType, Slot_Int, HEAP_STORED_ARRAY, IntegerArray.class);
stringArrayType = addArrayType(stringType, Slot_StrRef, HEAP_STORED_ARRAY, StringArray.class);
- // Add lists
+ /**********************************************************************************************
+ * Add Lists *
+ * The Tail feature is not factored out into listBaseType because it returns a typed value. *
+ **********************************************************************************************/
listBaseType = new TypeImpl(CAS.TYPE_NAME_LIST_BASE, this, topType);
// FS list
fsListType = new TypeImpl_list(CAS.TYPE_NAME_FS_LIST, topType, this, listBaseType, FSList.class);
fsEListType = new TypeImpl_list(CAS.TYPE_NAME_EMPTY_FS_LIST, topType, this, fsListType, EmptyFSList.class);
fsNeListType = new TypeImpl_list(CAS.TYPE_NAME_NON_EMPTY_FS_LIST, topType, this, fsListType, NonEmptyFSList.class);
- addFeature(CAS.FEATURE_BASE_NAME_HEAD, fsNeListType, topType, true);
addFeature(CAS.FEATURE_BASE_NAME_TAIL, fsNeListType, fsListType, true);
+ addFeature(CAS.FEATURE_BASE_NAME_HEAD, fsNeListType, topType, true);
// Float list
floatListType = new TypeImpl_list(CAS.TYPE_NAME_FLOAT_LIST, floatType, this, listBaseType, FloatList.class);
floatEListType = new TypeImpl_list(CAS.TYPE_NAME_EMPTY_FLOAT_LIST, floatType, this, floatListType, EmptyFloatList.class);
floatNeListType = new TypeImpl_list(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST, floatType, this, floatListType, NonEmptyFloatList.class);
- addFeature(CAS.FEATURE_BASE_NAME_HEAD, floatNeListType, floatType, false);
addFeature(CAS.FEATURE_BASE_NAME_TAIL, floatNeListType, floatListType, true);
+ addFeature(CAS.FEATURE_BASE_NAME_HEAD, floatNeListType, floatType, false);
// Integer list
intListType = new TypeImpl_list(CAS.TYPE_NAME_INTEGER_LIST, intType, this, listBaseType, IntegerList.class);
intEListType = new TypeImpl_list(CAS.TYPE_NAME_EMPTY_INTEGER_LIST, intType, this, intListType, EmptyIntegerList.class);
intNeListType = new TypeImpl_list(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST, intType, this, intListType, NonEmptyIntegerList.class);
- addFeature(CAS.FEATURE_BASE_NAME_HEAD, intNeListType, intType, false);
addFeature(CAS.FEATURE_BASE_NAME_TAIL, intNeListType, intListType, true);
+ addFeature(CAS.FEATURE_BASE_NAME_HEAD, intNeListType, intType, false);
// String list
stringListType = new TypeImpl_list(CAS.TYPE_NAME_STRING_LIST, stringType, this, listBaseType, StringList.class);
stringEListType = new TypeImpl_list(CAS.TYPE_NAME_EMPTY_STRING_LIST, stringType, this, stringListType, EmptyStringList.class);
stringNeListType = new TypeImpl_list(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST, stringType, this, stringListType, NonEmptyStringList.class);
- addFeature(CAS.FEATURE_BASE_NAME_HEAD, stringNeListType, stringType, false);
addFeature(CAS.FEATURE_BASE_NAME_TAIL, stringNeListType, stringListType, true);
+ addFeature(CAS.FEATURE_BASE_NAME_HEAD, stringNeListType, stringType, false);
booleanType = new TypeImpl_primitive(CAS.TYPE_NAME_BOOLEAN, this, topType, boolean.class);
byteType = new TypeImpl_primitive(CAS.TYPE_NAME_BYTE, this, topType, byte.class);
@@ -1328,7 +1343,7 @@ public class TypeSystemImpl implements T
prevWr = new WeakReference<>(this);
committedTypeSystems.put(this, prevWr);
- topType.computeDepthFirstCode(1);
+ topType.computeDepthFirstCode(1); // fixes up ordering, supers before subs. also sets hasRef.
computeFeatureOffsets(topType, 0);
@@ -1340,38 +1355,35 @@ public class TypeSystemImpl implements T
}
}
- // true = do user jcas class loading
+ computeAdjustedFeatureOffsets(topType, 0, 0); // must preceed the FSClassRegistry JCas stuff below
+
+ // Load all the available JCas classes (if not already loaded).
+
fsClassRegistry = new FSClassRegistry(this, true);
- computeAdjustedFeatureOffsets(topType, 0, 0);
this.locked = true;
return this;
} // of sync block
}
/**
- * This is the actual offset for the feature, only if it is not in the JCas class as a field
- * Also sets the getter and setter items from the FSClassRegistry.
+ * This is the actual offset for the feature, in either the int or ref array
+ *
* @param ti - the type
* @param nextI - the next available slot to use - for int style items
* @param nextR - the next available slot to use - for ref style items
*/
private void computeAdjustedFeatureOffsets(TypeImpl ti, int nextI, int nextR) {
-
- Class<?>clazz = getFSClassRegistry().getJCasClass(ti.getCode());
+ if (ti != topType) {
+ ti.initAdjOffset2FeatureMaps();
+ }
for (final FeatureImpl fi : ti.getMergedStaticFeaturesIntroducedByThisType()) {
- if ( ! FSClassRegistry.isFieldInClass(fi, clazz)) {
-
- fi.setAdjustedOffset(fi.isInInt ? (nextI ++) : (nextR ++));
- if (((TypeImpl)fi.getRange()).isLongOrDouble) {
- nextI ++;
- }
- } else { // field is in the JCas cover object
- GetterSetter gs = fsClassRegistry.getGetterSetter(ti.getCode(), fi.getShortName());
- fi.jcasGetter = gs.getter;
- fi.jcasSetter = gs.setter;
- }
+ fi.setAdjustedOffset(fi.isInInt ? nextI : nextR);
+ ti.setOffset2Feat(fi, fi.isInInt ? (nextI++) : (nextR++));
+ if (((TypeImpl)fi.getRange()).isLongOrDouble) {
+ nextI ++;
+ }
}
ti.nbrOfUsedIntDataSlots = nextI;
@@ -1381,7 +1393,7 @@ public class TypeSystemImpl implements T
computeAdjustedFeatureOffsets(sub, nextI, nextR);
}
}
-
+
/**
* Feature "ids" - offsets without adjusting for whether or not they're in the class itself
* @param ti a type to compute these for
@@ -2294,25 +2306,26 @@ public class TypeSystemImpl implements T
* @return - the type impl associated with that JCas cover class
*/
public TypeImpl getJCasRegisteredType(int i) {
- if (i >= jcasRegisteredTypes.size()) {
- Class<? extends TOP> cls = JCasRegistry.getClassForIndex(i);
- if (cls != null) {
- String typeName = cls.getName();
- // is type in type system
- if (getType(typeName) == null) {
- // no - report error that JCAS type was not defined in XML
- // descriptor
- throw new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS, typeName);
- } else {
- // yes - there was some problem loading the _Type object
- throw new CASRuntimeException(CASRuntimeException.JCAS_MISSING_COVERCLASS, typeName);
- }
-
- } else {
- throw new CASRuntimeException(CASRuntimeException.JCAS_UNKNOWN_TYPE_NOT_IN_CAS);
- }
- }
- return jcasRegisteredTypes.get(i);
+ TypeImpl ti = (i >= jcasRegisteredTypes.size()) ? null : jcasRegisteredTypes.get(i);
+ if (null == ti) {
+ throwMissingUIMAtype(i);
+ }
+ return ti;
+ }
+
+ /**
+ * For a given JCasRegistry index, that doesn't have a corresponding UIMA type,
+ * throw an appropriate exception
+ * @param i - the index in the JCasRegistry
+ */
+ private void throwMissingUIMAtype(int i) {
+ Class<? extends TOP> cls = JCasRegistry.getClassForIndex(i);
+ if (cls != null) {
+ String className = cls.getName();
+ throw new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS, className);
+ } else {
+ throw new CASRuntimeException(CASRuntimeException.JCAS_UNKNOWN_TYPE_NOT_IN_CAS);
+ }
}
public FSClassRegistry getFSClassRegistry() {
@@ -2359,6 +2372,7 @@ public class TypeSystemImpl implements T
}
public static final TypeSystemImpl staticTsi = new TypeSystemImpl();
+ static { staticTsi.commit(); } // needed to assign adjusted offsets to the builtins
/**
@@ -2433,4 +2447,35 @@ public class TypeSystemImpl implements T
return getFeatureByFullName(f.getName());
}
+ /**
+ * @param typecode the type code
+ * @return the generator for the type
+ */
+ Object getGenerator(int typecode) {
+ return jcasClassesInfo[typecode].generator;
+ }
+
+ /**
+ * @param typecode
+ * @return the associated JCas class (may be for a UIMA supertype, is never null)
+ */
+ Class<?> getJCasClass(int typecode) {
+ return jcasClassesInfo[typecode].jcasClass;
+ }
+
+ /**
+ * This code is run when a JCas class is loaded and resolved, for the first time, as part of type system commit, or
+ * as part of statically loading the FSClassRegister class (where this is done for all the built-ins, once).
+ * It looks up the offset value in the type system (via a thread-local)
+ *
+ * hidden parameter: threadLocal value: referencing this type
+ * @return the next available offset
+ */
+ public static synchronized int getAdjustedFeatureOffset(String featName) {
+ TypeImpl type = typeBeingLoadedThreadLocal.get();
+ FeatureImpl fi = type.getFeatureByBaseName(featName);
+ return (fi == null) ? -1 : type.getFeatureByBaseName(featName).getAdjustedOffset();
+ }
+
+
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/AnnotationBase.java Mon Mar 7 21:50:08 2016
@@ -24,6 +24,7 @@ import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASRuntimeException;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
@@ -51,6 +52,7 @@ public class AnnotationBase extends TOP
public final static int type = typeIndexID;
+ @Override
public int getTypeIndexID() {
return typeIndexID;
}
@@ -58,13 +60,12 @@ public class AnnotationBase extends TOP
// private final static int _FI_sofa = JCasRegistry.registerFeature(); // only for journal-able or corruptable feature slots
/* local data */
- public final static int _FI_sofa = JCasRegistry.registerFeature(typeIndexID);
+ public final static int _FI_sofa = TypeSystemImpl.getAdjustedFeatureOffset("sofa");
- private final Sofa _F_sofa;
+// private final Sofa _F_sofa;
// Never called. Disable default constructor
protected AnnotationBase() {
- _F_sofa = null;
}
// /* Internal - Constructor used by generator */
@@ -77,7 +78,8 @@ public class AnnotationBase extends TOP
if (_casView.isBaseCas()) {
throw new CASRuntimeException(CASRuntimeException.DISALLOW_CREATE_ANNOTATION_IN_BASE_CAS, this.getClass().getName());
}
- _F_sofa = _casView.getSofa();
+ // no journaling, no index corruption checking
+ _refData[_FI_sofa] = _casView.getSofa();
}
/**
@@ -92,7 +94,8 @@ public class AnnotationBase extends TOP
if (_casView.isBaseCas()) {
throw new CASRuntimeException(CASRuntimeException.DISALLOW_CREATE_ANNOTATION_IN_BASE_CAS, this.getClass().getName());
}
- _F_sofa = _casView.getSofa();
+ // no journaling, no index corruption checking
+ _refData[_FI_sofa] = _casView.getSofa();
}
// *------------------*
@@ -101,11 +104,12 @@ public class AnnotationBase extends TOP
/*
* getter for sofa - gets Sofaref for annotation
*/
- public Sofa getSofa() { return _F_sofa; }
+ public Sofa getSofa() { return (Sofa) _getFeatureValueNc(_FI_sofa); }
// There is no setter for this
// The value is set and is fixed when this is created
+ @Override
public CAS getView() {
return _casView;
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonList.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/CommonList.java Mon Mar 7 21:50:08 2016
@@ -145,10 +145,18 @@ public interface CommonList extends Feat
return newNode;
}
+ /**
+ * default impl for empty lists
+ * @return -
+ */
default CommonList getTail() {
throw new UnsupportedOperationException();
- }
+ };
+ /**
+ * default impl for empty lists
+ * @return -
+ */
default void setTail(CommonList v) {
throw new UnsupportedOperationException();
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFSList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFSList.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFSList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFSList.java Mon Mar 7 21:50:08 2016
@@ -20,7 +20,9 @@
package org.apache.uima.jcas.cas;
import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.FeatureImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
@@ -34,12 +36,12 @@ public class NonEmptyFSList extends FSLi
return typeIndexID;
}
- public static final int _FI_head = JCasRegistry.registerFeature(typeIndexID);
- public static final int _FI_tail = JCasRegistry.registerFeature(typeIndexID);
+ public static final int _FI_head = TypeSystemImpl.getAdjustedFeatureOffset("head");
+ public static final int _FI_tail = TypeSystemImpl.getAdjustedFeatureOffset("tail");
- /* local data */
- private TOP _F_head;
- private FSList _F_tail;
+// /* local data */
+// private TOP _F_head;
+// private FSList _F_tail;
// Never called. Disable default constructor
protected NonEmptyFSList() {
@@ -63,27 +65,21 @@ public class NonEmptyFSList extends FSLi
// *------------------*
// * Feature: head
/* getter for head * */
- public TOP getHead() { return _F_head; }
+ public TOP getHead() { return _getFeatureValueNc(_FI_head); }
/* setter for head * */
- public void setHead(TOP v) {
- _F_head = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_head);
- }
+ public void setHead(TOP v) { _setFeatureValueNcWj(_getFeatFromAdjOffset(_FI_head, false), v); }
+// public void _setHeadNcNj(TOP v) { _F_head = v; }
+
// *------------------*
// * Feature: tail
/* getter for tail * */
- public FSList getTail() { return _F_tail; }
+ public FSList getTail() { return (FSList) _getFeatureValueNc(_FI_tail); }
/* setter for tail * */
- public void setTail(FSList v) {
- _F_tail = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_tail);
- }
-
+ public void setTail(FSList v) { _setFeatureValueNcWj(_getFeatFromAdjOffset(_FI_tail, false), v); }
+
public void setTail(CommonList v) {
setTail((FSList) v);
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFloatList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFloatList.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFloatList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyFloatList.java Mon Mar 7 21:50:08 2016
@@ -21,6 +21,7 @@ package org.apache.uima.jcas.cas;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
@@ -34,12 +35,12 @@ public class NonEmptyFloatList extends F
return typeIndexID;
}
- public static final int _FI_head = JCasRegistry.registerFeature(typeIndexID);
- public static final int _FI_tail = JCasRegistry.registerFeature(typeIndexID);
+ public static final int _FI_head = TypeSystemImpl.getAdjustedFeatureOffset("head");
+ public static final int _FI_tail = TypeSystemImpl.getAdjustedFeatureOffset("tail");
/* local data */
- private float _F_head;
- private FloatList _F_tail;
+// private float _F_head;
+// private FloatList _F_tail;
// Never called. Disable default constructor
protected NonEmptyFloatList() {
@@ -63,30 +64,24 @@ public class NonEmptyFloatList extends F
// *------------------*
// * Feature: head
/* getter for head * */
- public float getHead() { return _F_head; }
+ public float getHead() { return _getFloatValueNc(_FI_head); }
/* setter for head * */
public void setHead(float v) {
- _F_head = v;
- // no corruption check - a list element can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_head);
+ this._setFloatValueNfc(_getFeatFromAdjOffset(_FI_head, true), v);
}
+// public void _setHeadNcNj(float v) { setFloatValueNcNj(_getFeat(_FI_head), v); }
+
// *------------------*
// * Feature: tail
/* getter for tail * */
- public FloatList getTail() { return _F_tail; }
+ public FloatList getTail() { return (FloatList) _getFeatureValueNc(_FI_tail); }
/* setter for tail * */
- public void setTail(FloatList v) {
- _F_tail = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_tail);
- }
+ public void setTail(FloatList v) { _setFeatureValueNcWj(_getFeatFromAdjOffset(_FI_tail, false), v); }
- public void setTail(CommonList v) {
- setTail((FloatList) v);
- }
+ public void setTail(CommonList v) { setTail((FloatList) v); }
/* (non-Javadoc)
* @see org.apache.uima.jcas.cas.CommonList#get_headAsString()
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyIntegerList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyIntegerList.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyIntegerList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyIntegerList.java Mon Mar 7 21:50:08 2016
@@ -23,6 +23,7 @@ import java.util.List;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
@@ -36,12 +37,12 @@ public class NonEmptyIntegerList extends
return typeIndexID;
}
- public final static int _FI_head = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_tail = JCasRegistry.registerFeature(typeIndexID);
+ public final static int _FI_head = TypeSystemImpl.getAdjustedFeatureOffset("head");
+ public final static int _FI_tail = TypeSystemImpl.getAdjustedFeatureOffset("tail");
- /* local data */
- private int _F_head;
- private IntegerList _F_tail;
+// /* local data */
+// private int _F_head;
+// private IntegerList _F_tail;
// Never called. Disable default constructor
protected NonEmptyIntegerList() {
@@ -66,31 +67,25 @@ public class NonEmptyIntegerList extends
// *------------------*
// * Feature: head
/* getter for head * */
- public int getHead() { return _F_head; }
+ public int getHead() { return _getIntValueNc(_FI_head); }
/* setter for head * */
public void setHead(int v) {
- _F_head = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_head);
+ _setIntValueNfc(_getFeatFromAdjOffset(_FI_head, true), v);
}
+
+// public void _setHeadNcNj(int v) { _FI_head = v;}
// *------------------*
// * Feature: tail
/* getter for tail * */
- public IntegerList getTail() { return _F_tail; }
+ public IntegerList getTail() { return (IntegerList) _getFeatureValueNc(_FI_tail); }
/* setter for tail * */
- public void setTail(IntegerList v) {
- _F_tail = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_tail);
- }
-
- public void setTail(CommonList v) {
- setTail((IntegerList)v);
- }
+ public void setTail(IntegerList v) { _setFeatureValueNcWj(_getFeatFromAdjOffset(_FI_tail, false), v); }
+ public void setTail(CommonList v) { setTail((IntegerList)v); }
+
public void setHead(List<String> stringValues, int i) {
setHead(Integer.parseInt(stringValues.get(i)));
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyList.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyList.java Mon Mar 7 21:50:08 2016
@@ -22,6 +22,4 @@ package org.apache.uima.jcas.cas;
/**
* a marker interface for nonempty lists
*/
-public interface NonEmptyList extends CommonList {
- CommonList getTail();
-}
+public interface NonEmptyList extends CommonList {}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyStringList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyStringList.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyStringList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/NonEmptyStringList.java Mon Mar 7 21:50:08 2016
@@ -21,6 +21,7 @@ package org.apache.uima.jcas.cas;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
@@ -34,12 +35,12 @@ public class NonEmptyStringList extends
return typeIndexID;
}
- public static final int _FI_head = JCasRegistry.registerFeature(typeIndexID);
- public static final int _FI_tail = JCasRegistry.registerFeature(typeIndexID);
+ public static final int _FI_head = TypeSystemImpl.getAdjustedFeatureOffset("head");
+ public static final int _FI_tail = TypeSystemImpl.getAdjustedFeatureOffset("tail");
- /* local data */
- private String _F_head;
- private StringList _F_tail;
+// /* local data */
+// private String _F_head;
+// private StringList _F_tail;
// Never called. Disable default constructor
protected NonEmptyStringList() {
@@ -63,31 +64,29 @@ public class NonEmptyStringList extends
// *------------------*
// * Feature: head
/* getter for head * */
- public String getHead() { return _F_head; }
+ public String getHead() { return _getStringValueNc(_FI_head); }
/* setter for head * */
public void setHead(String v) {
- _F_head = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_head);
+ _setStringValueNfc(_getFeatFromAdjOffset(_FI_head, false), v);
}
+
+// public void _setHeadNcNj(String v) {_FI_head = v;};
// *------------------*
// * Feature: tail
/* getter for tail * */
- public StringList getTail() { return _F_tail; }
+ public StringList getTail() { return (StringList) _getFeatureValueNc(_FI_tail); }
/* setter for tail * */
- public void setTail(StringList v) {
- _F_tail = v;
- // no corruption check - can't be a key
- _casView.maybeLogUpdateJFRI(this, _FI_tail);
- }
+ public void setTail(StringList v) { _setFeatureValueNcWj(_getFeatFromAdjOffset(_FI_tail, false), v); }
public void setTail(CommonList v) {
setTail((StringList)v);
}
+// public void _setTailNcNj(StringList v) { _FI_tail = v; }
+
/* (non-Javadoc)
* @see org.apache.uima.jcas.cas.CommonList#get_headAsString()
*/
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/Sofa.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/Sofa.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/Sofa.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/Sofa.java Mon Mar 7 21:50:08 2016
@@ -27,6 +27,7 @@ import org.apache.uima.cas.FeatureStruct
import org.apache.uima.cas.SofaFS;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.jcas.JCasRegistry;
public class Sofa extends TOP implements SofaFS {
@@ -41,24 +42,24 @@ public class Sofa extends TOP implements
/* local data */
// these static ints are for fast index corruption checking
- public final static int _FI_sofaNum = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_sofaID = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_mimeType = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_sofaArray = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_sofaString = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_sofaURI = JCasRegistry.registerFeature(typeIndexID);
-
- private final int _F_sofaNum;
- private final String _F_sofaID; // view name or _InitialView
- private String _F_mimeType; // may be changed
- private TOP _F_sofaArray;
- private String _F_sofaString;
- private String _F_sofaURI;
+ public final static int _FI_sofaNum = TypeSystemImpl.getAdjustedFeatureOffset("sofaNum");
+ public final static int _FI_sofaID = TypeSystemImpl.getAdjustedFeatureOffset("sofaID");
+ public final static int _FI_mimeType = TypeSystemImpl.getAdjustedFeatureOffset("mimeType");
+ public final static int _FI_sofaArray = TypeSystemImpl.getAdjustedFeatureOffset("sofaArray");
+ public final static int _FI_sofaString = TypeSystemImpl.getAdjustedFeatureOffset("sofaString");
+ public final static int _FI_sofaURI = TypeSystemImpl.getAdjustedFeatureOffset("sofaURI");
+
+// private final int _F_sofaNum;
+// private final String _F_sofaID; // view name or _InitialView
+// private String _F_mimeType; // may be changed
+// private TOP _F_sofaArray;
+// private String _F_sofaString;
+// private String _F_sofaURI;
protected Sofa() {
- _F_sofaNum = 0;
- _F_sofaID = null;
- _F_mimeType = null;
+// _F_sofaNum = 0;
+// _F_sofaID = null;
+// _F_mimeType = null;
}
/**
@@ -69,15 +70,18 @@ public class Sofa extends TOP implements
*/
public Sofa(TypeImpl t, CASImpl c) {
super(t, c);
- _F_sofaNum = 0;
- _F_sofaID = null;
+// _F_sofaNum = 0;
+// _F_sofaID = null;
}
public Sofa(TypeImpl t, CASImpl c, int sofaNum, String viewName, String mimeType) {
super(t, c);
- _F_sofaNum = sofaNum;
- _F_sofaID = viewName;
- _F_mimeType = mimeType;
+ _intData[_FI_sofaNum ] = sofaNum;
+ _refData[_FI_sofaID ] = viewName;
+ _refData[_FI_mimeType] = mimeType;
+// _F_sofaNum = sofaNum;
+// _F_sofaID = viewName;
+// _F_mimeType = mimeType;
}
// no constructor for Sofa for users
@@ -109,7 +113,7 @@ public class Sofa extends TOP implements
* getter for sofaNum
* @return the sofa number
*/
- public int getSofaNum() { return _F_sofaNum; }
+ public int getSofaNum() { return _getIntValueNc(_FI_sofaNum); }
// *--------------*
// * Feature: sofaID
@@ -119,7 +123,7 @@ public class Sofa extends TOP implements
* @return the sofaID, which is the same as the view name
*/
@Override
- public String getSofaID() { return _F_sofaID; }
+ public String getSofaID() { return _getStringValueNc(_FI_sofaID); }
// *--------------*
// * Feature: mimeType
@@ -128,7 +132,7 @@ public class Sofa extends TOP implements
* getter for mimeType - gets
* @return the mime type
*/
- public String getMimeType() { return _F_mimeType; }
+ public String getMimeType() { return _getStringValueNc(_FI_mimeType); }
/**
* @see org.apache.uima.cas.SofaFS#setLocalSofaData(FeatureStructure) This method is duplicated in
@@ -138,12 +142,12 @@ public class Sofa extends TOP implements
@Override
public void setLocalSofaData(FeatureStructure aFS) {
if (isSofaDataSet()) { throwAlreadySet("setLocalSofaData()"); }
- _F_sofaArray = (TOP) aFS;
+ _setFeatureValueNcWj(_getFeatFromAdjOffset(_FI_sofaArray, false), aFS);
}
public void setLocalSofaData(FeatureStructure aFS, String mimeType) {
setLocalSofaData(aFS);
- _F_mimeType = mimeType;
+ setMimeType(mimeType);
}
/**
@@ -153,7 +157,7 @@ public class Sofa extends TOP implements
@Override
public void setLocalSofaData(String aString) {
if (isSofaDataSet()) { throwAlreadySet("setLocalSofaData()"); }
- _F_sofaString = aString;
+ _setStringValueNcWj(_FI_sofaString, aString);
// create or update the document annotation for this Sofa's view
((CASImpl)(_casView.getView(this))).updateDocumentAnnotation();
@@ -161,7 +165,7 @@ public class Sofa extends TOP implements
public void setLocalSofaData(String aString, String mimeType) {
setLocalSofaData(aString);
- _F_mimeType = mimeType;
+ setMimeType(mimeType);
}
/**
@@ -169,14 +173,13 @@ public class Sofa extends TOP implements
* returns an UIMA Array whose data represents the sofa
*/
@Override
- public FeatureStructure getLocalFSData() { return _F_sofaArray; }
+ public FeatureStructure getLocalFSData() { return _getFeatureValueNc(_FI_sofaArray); }
/**
- * @see org.apache.uima.cas.SofaFS#getLocalStringData() This method is duplicated in SofaFSImpl.
- * Any changes should be made in both places.
+ * @see org.apache.uima.cas.SofaFS#getLocalStringData()
*/
@Override
- public String getLocalStringData() { return _F_sofaString; }
+ public String getLocalStringData() { return _getStringValueNc(_FI_sofaString); }
/**
* @see org.apache.uima.cas.SofaFS#setRemoteSofaURI(String) This method is duplicated in
@@ -185,12 +188,12 @@ public class Sofa extends TOP implements
@Override
public void setRemoteSofaURI(String aURI) {
if (isSofaDataSet()) { throwAlreadySet("setRemoteSofaURI()"); }
- _F_sofaURI = aURI;
+ _setStringValueNcWj(_FI_sofaURI, aURI);
}
public void setRemoteSofaURI(String aURI, String mimeType) {
setRemoteSofaURI(aURI);
- _F_mimeType = mimeType;
+ setMimeType(mimeType);
}
public boolean isSofaDataSet() {
@@ -200,14 +203,14 @@ public class Sofa extends TOP implements
}
@Override
- public String getSofaMime() { return _F_mimeType; }
+ public String getSofaMime() { return _getStringValueNc(_FI_mimeType); }
@Override
- public String getSofaURI() { return _F_sofaURI; }
+ public String getSofaURI() { return _getStringValueNc(_FI_sofaURI); }
// ** Note: this gets the feature named "sofaNum"
@Override
- public int getSofaRef() { return _F_sofaNum; }
+ public int getSofaRef() { return _getIntValueNc(_FI_sofaNum); }
@Override
public InputStream getSofaDataStream() {
@@ -220,9 +223,9 @@ public class Sofa extends TOP implements
* - used in generic pretty printing routines
*/
- public TOP getSofaArray() { return _F_sofaArray; }
+ public TOP getSofaArray() { return _getFeatureValueNc(_FI_sofaArray); }
- public String getSofaString() { return _F_sofaString; }
+ public String getSofaString() { return _getStringValueNc(_FI_sofaString); }
// override setStringValue for SofaFS to prohibit setting in this manner!
@@ -247,9 +250,5 @@ public class Sofa extends TOP implements
throw new CASRuntimeException(CASRuntimeException.SOFADATA_ALREADY_SET, msg);
}
- public void setMimeType(String v) {
- _F_mimeType = v;
- // no corruption check - sofa's aren't in any index except base view bag
- _casView.maybeLogUpdateJFRI(this, _FI_mimeType);
- }
+ public void setMimeType(String v) { _setStringValueNcWj(_FI_mimeType, v); }
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/TOP.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/TOP.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/TOP.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/TOP.java Mon Mar 7 21:50:08 2016
@@ -56,6 +56,14 @@ public class TOP extends FeatureStructur
// maybe called to create unique removed marker, but not otherwise used
public TOP() {
}
+
+ /**
+ * For use when creating a search key
+ * @param id -
+ */
+ private TOP(int id) {
+ super(id);
+ }
/**
* used by generator
@@ -76,6 +84,9 @@ public class TOP extends FeatureStructur
super((JCasImpl) jcas);
}
+ public static TOP createSearchKey(int id) {
+ return new TOP(id);
+ }
final public static TOP singleton = new TOP();
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/tcas/Annotation.java Mon Mar 7 21:50:08 2016
@@ -19,8 +19,10 @@
package org.apache.uima.jcas.tcas;
+import org.apache.uima.cas.admin.LinearTypeOrder;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.JCasRegistry;
@@ -41,12 +43,12 @@ public class Annotation extends Annotati
return typeIndexID;
}
- public final static int _FI_begin = JCasRegistry.registerFeature(typeIndexID);
- public final static int _FI_end = JCasRegistry.registerFeature(typeIndexID);
+ public final static int _FI_begin = TypeSystemImpl.getAdjustedFeatureOffset("begin");
+ public final static int _FI_end = TypeSystemImpl.getAdjustedFeatureOffset("end");
- /* local data */
- private int _F_begin;
- private int _F_end;
+// /* local data */
+// private int _F_begin;
+// private int _F_end;
// Never called. Disable default constructor
protected Annotation() {
@@ -74,15 +76,15 @@ public class Annotation extends Annotati
/*
* getter for begin - gets beginning of span of annotation
*/
- public int getBegin() { return _F_begin; }
+// public int getBegin() { return _F_begin; }
+ public int getBegin() { return _getIntValueNc(_FI_begin);
+ }
/*
* setter for begin - sets beginning of span of annotation
*/
- public void setBegin(int v) {
- _casView.setWithCheckAndJournalJFRI(this, _FI_begin , () -> _F_begin = v);
- }
-
+ public void setBegin(int v) { _setIntValueNfcCJ(_getFeatFromAdjOffset(_FI_begin, true), v); }
+
// *------------------*
// * Feature: end
// * ending of span of annotation
@@ -90,15 +92,17 @@ public class Annotation extends Annotati
/*
* getter for end - gets ending of span of annotation
*/
- public int getEnd() { return _F_end; }
+ public int getEnd() {
+ return this._getIntValueNc(_FI_end);
+ }
/*
* setter for end - sets ending of span of annotation
*/
public void setEnd(int v) {
- _casView.setWithCheckAndJournalJFRI(this, _FI_end, () -> _F_end = v);
+ this._setIntValueNfc(_getFeatFromAdjOffset(_FI_end, true), v);
}
-
+
/**
* Constructor with begin and end passed as arguments
* @param jcas JCas
@@ -106,9 +110,9 @@ public class Annotation extends Annotati
* @param end end offset
*/
public Annotation(JCas jcas, int begin, int end) {
- this(jcas); // forward to constructor
- this.setBegin(begin);
- this.setEnd(end);
+ super(jcas); // forward to constructor
+ this._setIntValueNcNj(_FI_begin, begin);
+ this._setIntValueNcNj(_FI_end, end);
}
/**
@@ -133,4 +137,57 @@ public class Annotation extends Annotati
return getBegin();
}
+ /**
+ * Compare two annotations, no type order
+ * @param other
+ * @return
+ */
+ public int compareAnnotation(Annotation other) {
+ int[] o = other._intData;
+ int result = Integer.compare(_intData[_FI_begin], o[_FI_begin]);
+ if (result != 0) return result;
+
+ result = Integer.compare(_intData[_FI_end], o[_FI_end]);
+ return (result == 0) ? 0 : -result; // reverse compare
+ }
+
+ /**
+ * Compare two annotations incl type order
+ * @param other
+ * @return
+ */
+ public int compareAnnotation(Annotation other, LinearTypeOrder lto) {
+ int[] o = other._intData;
+ int result = Integer.compare(_intData[_FI_begin], o[_FI_begin]);
+ if (result != 0) return result;
+
+ result = Integer.compare(_intData[_FI_end], o[_FI_end]);
+ if (result != 0) return -result;
+
+ return lto.compare(this, other);
+ }
+
+
+ /**
+ * Compare two annotations, with type order, with id compare
+ * @param other
+ * @return
+ */
+ public int compareAnnotationWithId(Annotation other) {
+ int result = compareAnnotation(other);
+ if (result != 0) return result;
+ return Integer.compare(_id, other._id);
+ }
+
+ /**
+ * Compare two annotations, with type order, with id compare
+ * @param other
+ * @return
+ */
+ public int compareAnnotationWithId(Annotation other, LinearTypeOrder lto) {
+ int result = compareAnnotation(other, lto);
+ if (result != 0) return result;
+ return Integer.compare(_id, other._id);
+ }
+
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/CasCopier.java Mon Mar 7 21:50:08 2016
@@ -798,9 +798,9 @@ public class CasCopier {
if (fi.isAnnotBaseSofaRef) {
continue;
}
- TOP refFs = srcFS.getFeatureValueNc(fi);
+ TOP refFs = srcFS._getFeatureValueNc(fi);
if (null != refFs) {
- tgtFS.setFeatureValueNcNj(tgtFi, copyFsInner(refFs)); // recursive call
+ tgtFS._setFeatureValueNcNj(tgtFi, copyFsInner(refFs)); // recursive call
}
}
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/Misc.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/Misc.java?rev=1733992&r1=1733991&r2=1733992&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/Misc.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/util/Misc.java Mon Mar 7 21:50:08 2016
@@ -31,8 +31,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.WeakHashMap;
import java.util.function.Consumer;
@@ -134,6 +132,7 @@ public class Misc {
int shft = 31 - Integer.numberOfLeadingZeros(x); // x == 8, shft = 3
return (i < 1) ? x : ((i+(x - 1)) >>> shft) << shft;
}
+
/**
* Given a class, a lookup context, and a protected method and its arg classes,
* return the method handle for that method.
@@ -326,6 +325,29 @@ public class Misc {
}
}
+ /**
+ * @return the name of the caller in the stack
+ */
+ public static String getCaller() {
+ StackTraceElement[] e = Thread.currentThread().getStackTrace();
+ return formatcaller(e[4]) + "called by: " + formatcaller(e[5]);
+ }
+
+ private static String formatcaller(StackTraceElement e) {
+ String n = e.getClassName();
+ return n.substring(1 + n.lastIndexOf('.')) + "." + e.getMethodName() + "[" + e.getLineNumber() + "]";
+ }
+
+ /**
+ * format a list of items for pretty printing as [item1, item2, ... ]
+ * @param items to print
+ * @return [item1, item2, ... ]
+ */
+ public static String ppList(List<?> items) {
+ StringBuilder sb = new StringBuilder(items.size() * 5 + 2);
+ return addElementsToStringBuilder(sb, items).toString();
+ }
+
//private static final Function<String, Class> uimaSystemFindLoadedClass;
//static {
// try {