/** * Gets the allowed values for a string subtype. * * @param aType * the type, which must be a subtype of uima.cas.String * @param aTypeSystem the type system to use * @return array of allowed values for <code>aType</code> TODO - this should be a method on * Type. */ public static String[] getAllowedValuesForType(Type aType, TypeSystem aTypeSystem) { LowLevelTypeSystem lts = aTypeSystem.getLowLevelTypeSystem(); return lts.ll_getStringSet(lts.ll_getCodeForType(aType)); }
fsType = ts.ll_getCodeForTypeName(this.typeNameInSnippet); int[] features = ts.ll_getAppropriateFeatures(fsType); boolean found = false; Feature feature = ts.ll_getFeatureForCode(features[i]); found = feature.getShortName().equals(this.featureName); rangeTypeCode = ts.ll_getRangeType(this.featureCode); } else { Type type = ts.ll_getTypeForCode(fsType); CASRuntimeException exception = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT, new String[] { this.featureName, type.getName() }); Type type = ts.ll_getTypeForCode(rangeTypeCode); this.featureRangeType = rangeTypeCode; int arrayType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_ARRAY_BASE); this.isArrayType = ((TypeSystemImpl) ts).subsumes(arrayType, rangeTypeCode); if (!this.isArrayType) { int candidateType = ts.ll_getCodeForTypeName(LIST_TYPE_NAMES[i]); this.isListType = ((TypeSystemImpl) ts).subsumes(candidateType, rangeTypeCode); if (this.isListType) { this.headFeature = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FS_LIST_HEAD); this.tailFeature = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FS_LIST_TAIL); break; case TYPE_CLASS_STRINGLIST:
.ll_getCodeForType(featurePathType); .ll_getCodeForFeature(feature)); this.featurePathElements.add(feature);
/** * Classify types into FS type, array type etc. For the full list of return types, see the * <code>LowLevelCAS.TYPE_CLASS*</code> constants, as well as the documentation for * {@link LowLevelCAS#ll_getTypeClass(int) LowLevelCAS.ll_getTypeClass(int)}. * * @param type * The type to classify. * @return An integer encoding the the type class. See above. */ public static final int classifyType(Type type) { LowLevelTypeSystem llts = ((TypeImpl) type).getTypeSystem().getLowLevelTypeSystem(); return llts.ll_getTypeClass(llts.ll_getCodeForType(type)); }
private XCASDeserializerHandler(CASImpl aCAS, OutOfTypeSystemData ootsData) { super(); this.cas = aCAS.getBaseCAS(); // Reset the CAS. cas.resetNoQuestions(); this.fsTree = new RedBlackTree<FSInfo>(); this.idLess = new ArrayList<FSInfo>(); this.buffer = new StringBuffer(); this.outOfTypeSystemData = ootsData; this.indexRepositories = new ArrayList<FSIndexRepository>(); this.views = new ArrayList<CAS>(); // using the baseCas for indexing Sofas indexRepositories.add(this.cas.getBaseIndexRepository()); // There should always be another index for the Initial View indexRepositories.add(this.cas.getView(CAS.NAME_DEFAULT_SOFA).getIndexRepository()); this.sofaTypeCode = cas.ll_getTypeSystem().ll_getCodeForType( cas.getTypeSystem().getType(CAS.TYPE_NAME_SOFA)); this.annotBaseType = this.cas.getAnnotationType(); this.sofaRefMap = new IntVector(); this.indexMap = new IntVector(); // add entry for baseCAS ... point non-compliant annotations at first Sofa sofaRefMap.add(1); // add entry for baseCAS ... _indexed=0 stays in 0 indexMap.add(0); }
Type rangeType = feat.getRange(); if (rangeType.isArray()) { final int typeClass = llts.ll_getTypeClass(llts.ll_getCodeForType(rangeType)); String typeName = null; switch (typeClass) { final int typeCode = lts.ll_getCodeForType(type); String[] strings = lts.ll_getStringSet(typeCode); AllowedValue[] allowedVals = new AllowedValue[strings.length]; for (int i = 0; i < strings.length; i++) {
featurePathValue.setTypeClass(llCas.ll_getTypeClass(typeCode)); featurePathValue.setFeatureType(llCas.ll_getTypeSystem() .ll_getTypeForCode(typeCode)); return featurePathValue; .ll_subsumes(this.featurePathBaseTypeCode, llCas.ll_getFSRefType(fsRef, true)); Type currentType = llCas.ll_getTypeSystem().ll_getTypeForCode( fsRefTypeCode); .ll_getCodeForFeature(feature); currentRangeTypeCode = llCas.ll_getTypeSystem().ll_getRangeType( currentFeatureCode); switch (llCas.ll_getTypeClass(currentRangeTypeCode)) { .ll_getTypeForCode(currentRangeTypeCode)); return featurePathValue;
this.annots = new int[it.ll_indexSize()]; final LowLevelTypeSystem ts = cas.ll_getTypeSystem(); final int annotType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_ANNOTATION); final int startFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_BEGIN); final int endFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_END); if (ts.ll_subsumes(annotType, curType)) {
private final void getPrintRefs(PrintReferences printRefs, int ref) { boolean seenBefore = printRefs.addReference(ref); if (seenBefore) { return; } LowLevelCAS llcas = this.getCASImpl().getLowLevelCAS(); LowLevelTypeSystem llts = llcas.ll_getTypeSystem(); final int typeCode; try { typeCode = llcas.ll_getFSRefType(ref, true); } catch (LowLevelException e) { return; // can't find ref, may be invalid or null } int[] feats = llts.ll_getAppropriateFeatures(typeCode); for (int i = 0; i < feats.length; i++) { if (llcas.ll_isRefType(llts.ll_getRangeType(feats[i]))) { int valRef = llcas.ll_getRefValue(ref, feats[i]); if (valRef != LowLevelCAS.NULL_FS_REF) { getPrintRefs(printRefs, valRef); } } } }
void copyFeatures(int trgAddr, int srcAddr) throws CASRuntimeException { int typeCode = getHeapValue(trgAddr); if (typeCode != getHeapValue(srcAddr)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE); // What's that supposed to mean? Internationalized, my foot. // TODO: fix exception argument. // e.addArgument("Type of source and target feature structures do not // match"); throw (e); } // get features to copy int[] featcodes = getTypeSystem().getLowLevelTypeSystem().ll_getAppropriateFeatures(typeCode); for (int i = 0; i < featcodes.length; i++) { // get range type of this feature Feature feature = getTypeSystem().getLowLevelTypeSystem().ll_getFeatureForCode(featcodes[i]); Type rangeType = feature.getRange(); // get feature code int featCode = ((FeatureImpl) feature).getCode(); // get the value for this feature offset in src fs int val = getHeapValue(srcAddr + this.svd.casMetadata.featureOffset[featCode]); // if this is a string, create a new reference in the string // reference heap // and point to the same string as the string feature in src fs. setFeatureValueNotJournaled(trgAddr, featCode, isStringType(rangeType) ? this.getStringHeap().cloneStringReference(val) : getHeapValue(srcAddr + this.svd.casMetadata.featureOffset[featCode])); } }
void setDocTextFromDeserializtion(String text) { if (mySofaIsValid()) { final int SofaStringCode = ll_getTypeSystem().ll_getCodeForFeature( this.getTypeSystem().getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFASTRING)); ll_setStringValue(this.getSofaRef(), SofaStringCode, text); } }
private static int[] encodeTypeList(String[] typeList, TypeSystem ts) throws CASException { int[] a = new int[typeList.length]; LowLevelTypeSystem llts = (LowLevelTypeSystem) ts; for (int i = 0; i < a.length; i++) { int t = llts.ll_getCodeForTypeName(typeList[i]); if (t == LowLevelTypeSystem.UNKNOWN_TYPE_CODE) { CASException e = new CASException(CASException.TYPEORDER_UNKNOWN_TYPE, new String[] { typeList[i] }); throw e; } a[i] = t; } return a; }
private XCASDocSerializer(ContentHandler ch, CASImpl cas) { super(); this.ch = ch; this.cas = cas; this.queued = new IntRedBlackTree(); this.duplicates = new IntRedBlackTree(); this.numDuplicates = 0; this.dupVectors = new Vector<IntVector>(); this.queue = new IntStack(); this.indexedFSs = new IntVector(); this.indexReps = new IntVector(); this.sofaTypeCode = cas.ll_getTypeSystem().ll_getCodeForType( cas.getTypeSystem().getType(CAS.TYPE_NAME_SOFA)); }
.getTypeSystem().getLowLevelTypeSystem(); this.ll_featurePathElements.add(llTypeSystem .ll_getCodeForFeature(feat)); } else { this.ll_featurePathElements = null;
/** * Gets the restricted values. * * @param ts the ts * @param type the type * @return the restricted values */ public static String[] getRestrictedValues(TypeSystem ts, Type type) { if (isRestrictedByAllowedValues(ts, type)) { throw new IllegalArgumentException("Type " + type.getName() + " does not defines allowed values!"); } LowLevelTypeSystem lts = ts.getLowLevelTypeSystem(); final int typeCode = lts.ll_getCodeForType(type); return lts.ll_getStringSet(typeCode); }
int typeClass = ll_cas.ll_getTypeClass(ll_typeSystem.ll_getCodeForType(fs.getRange())); this.fileWriter.write(fs.getShortName() + "=");
/** * Checks if is restricted by allowed values. * * @param ts the ts * @param type the type * @return true, if is restricted by allowed values */ public static boolean isRestrictedByAllowedValues(TypeSystem ts, Type type) { if (ts.getType(CAS.TYPE_NAME_STRING).equals(type) || ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), type)) { LowLevelTypeSystem lts = ts.getLowLevelTypeSystem(); final int typeCode = lts.ll_getCodeForType(type); String[] strings = lts.ll_getStringSet(typeCode); return strings.length > 0; } else { return false; } }
int typeClass = ll_cas.ll_getTypeClass(ll_typeSystem.ll_getCodeForType(fs.getRange())); this.fileWriter.write(fs.getShortName() + "=");
final int typeClass = this.getCASImpl().ll_getTypeClass(llts.ll_getCodeForType(this.getType()));
int typeCode = mLowLevelDestCas.ll_getTypeSystem().ll_getCodeForType(destType); int destFsAddr = mLowLevelDestCas.ll_createFS(typeCode); FeatureStructure destFs = mDestCas.getLowLevelCAS().ll_getFSForRef(destFsAddr);