public TypeSystemImpl getTypeSystem() { final TypeSystemImpl ts = new TypeSystemImpl(); int pos = isStringSubtype(i); if (pos >= 0) { ts.addStringSubtype(name, getStringArray(pos)); } else if (TypeSystemImpl.isArrayTypeNameButNotBuiltIn(name)) { ts.getArrayType(ts.getType(TypeSystemImpl.getArrayComponentName(name))); } else { ts.addType(name, this.typeInheritance[i]); ts.addFeature(name, this.featDecls[i * 3], this.featDecls[(i * 3) + 1], this.featDecls[(i * 3) + 2] == 1);
this.sofaNum = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFANUM); this.annotBaseType = (TypeImpl) getType(CAS.TYPE_NAME_ANNOTATION_BASE); this.startFeat = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_BEGIN); this.endFeat = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_END); this.langFeat = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_LANGUAGE); initTypeCodeVars();
public boolean isType(int type) { return ((type > 0) && (type <= getLargestTypeCode())); }
/** * Check if feature is appropriate for type (i.e., type is subsumed by domain type of feature). * @param type - * @param feat - * @return true if feature is appropriate for type (i.e., type is subsumed by domain type of feature). */ public boolean isApprop(int type, int feat) { return subsumes(intro(feat), type); }
final int getTypeArraySize() { return getNumberOfTypes() + getSmallestType(); }
private Vector<Type> getStringSubtypes(TypeSystemImpl ts) { return ts.getDirectlySubsumedTypes(ts.getType(CAS.TYPE_NAME_STRING)); }
public boolean getBooleanValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_BOOLEAN))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BOOLEAN)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getBooleanValue(this.getAddress(), featCode); }
private static void forceSetFeatureValue(FeatureStructure aFS, String aFeatureName, String aValue) { CASImpl casImpl = (CASImpl) aFS.getCAS().getLowLevelCAS(); TypeSystemImpl ts = (TypeSystemImpl) aFS.getCAS().getTypeSystem(); Feature feat = aFS.getType().getFeatureByBaseName(aFeatureName); int featCode = ((FeatureImpl) feat).getCode(); int thisType = ((TypeImpl) aFS.getType()).getCode(); if (!ts.isApprop(thisType, featCode)) { throw new IllegalArgumentException("Feature structure does not have that feature"); } if (!ts.subsumes(ts.getType(CAS.TYPE_NAME_STRING), feat.getRange())) { throw new IllegalArgumentException("Not a string feature!"); } casImpl.ll_setStringValue(casImpl.ll_getFSRef(aFS), featCode, aValue); }
tgtTypeCode = srcTypeCode; } else { Type srcType = srcTsi.ll_getTypeForCode(srcTypeCode); Type tgtType = tgtTsi.getType(srcType.getName()); if (tgtType == null) { tgtTypeCode = tgtTsi.ll_getCodeForType(tgtType); int[] srcFeatCodes = srcTsi.ll_getAppropriateFeatures(srcTypeCode); int arrayLength = srcFeatCodes.length << 1; for (int i = 0; i < srcFeatCodes.length; i++) { final int srcFeatCode = srcFeatCodes[i]; Feature srcFeat = srcTsi.ll_getFeatureForCode(srcFeatCode); setRangeClass((TypeImpl) srcFeat.getRange(), i); final int i2 = i << 1; for (int i = 0; i < srcFeatCodes.length; i++) { final int srcFeatCode = srcFeatCodes[i]; Feature srcFeat = srcTsi.ll_getFeatureForCode(srcFeatCode); String srcFeatName = srcFeat.getName(); Feature tgtFeat = tgtTsi.getFeatureByFullName(srcFeatName); if (tgtFeat == null) {
private void initCreatableTypeTable() { this.creatableType = new boolean[ts.getTypeArraySize()]; Arrays.fill(this.creatableType, true); int typeCode; for (int i = 0; i < nonCreatableTypes.length; i++) { typeCode = ((TypeImpl) ts.getType(nonCreatableTypes[i])).getCode(); for (int subType = ts.getSmallestType(); subType < this.creatableType.length; subType++) { if (ts.subsumes(typeCode, subType)) { this.creatableType[subType] = false; } } } }
final int fsRef = cas.getHeapValue(position++); if (isFiltering) { String typeName = tsi.ll_getTypeForCode(cas.getHeapValue(fsRef)).getName(); if (filterTypeSystem.getType(typeName) == null) { continue; // don't enqueue this type because it's filtered out int[] feats = tsi.ll_getAppropriateFeatures(typeCode); for (int feat : feats) { if (isFiltering) { String fullFeatName = tsi.ll_getFeatureForCode(feat).getName(); if (filterTypeSystem.getFeatureByFullName(fullFeatName) == null) { continue; final int fsClass = classifyType(tsi.range(feat)); switch (fsClass) { case LowLevelCAS.TYPE_CLASS_FS: {
int filterType(int addr) { if (isFiltering) { String typeName = tsi.ll_getTypeForCode(cas.getHeapValue(addr)).getName(); if (filterTypeSystem.getType(typeName) == null) { return 0; } } return addr; }
String componentTypeName = getBuiltinArrayComponent(typeName); if (componentTypeName != null) { return getArrayType(getType(componentTypeName)); checkTypeSyntax(typeName); final int typeCode = this.addType(typeName, ((TypeImpl) mother).getCode()); if (typeCode < this.typeNameST.getStart()) { return null;
/** * @see org.apache.uima.cas.TypeNameSpace#getType(java.lang.String) */ public Type getType(String typeName) { return this.ts.getType(this.name + TypeSystem.NAMESPACE_SEPARATOR + typeName); }
private final void checkTypingConditions(int domTypeCode, int ranTypeCode, int featCode) { checkDomTypeConditions(domTypeCode, featCode); final TypeSystemImpl ts = this.svd.casMetadata.ts; if (!ts.subsumes(ts.range(featCode), ranTypeCode)) { LowLevelException e = new LowLevelException(LowLevelException.FEAT_RAN_ERROR); e.addArgument(Integer.toString(featCode)); e.addArgument(ts.ll_getFeatureForCode(featCode).getName()); e.addArgument(Integer.toString(ranTypeCode)); e.addArgument(ts.ll_getTypeForCode(ranTypeCode).getName()); throw e; } }
/** * @param t the type code to test * @return true if that type is subsumed by AnnotationBase type */ public boolean isSubtypeOfAnnotationBaseType(int t) { return this.svd.casMetadata.ts.subsumes(TypeSystemImpl.annotBaseTypeCode, t); }
private static int[] addTypes(TypeSystemImpl tsSrc, TypeSystemImpl tsTgt) { Map<TypeImpl, TypeImpl> mSrc2Tgt = new LinkedHashMap<TypeImpl, TypeImpl>(); for (Iterator<Type> it = tsSrc.getTypeIterator(); it.hasNext();) { TypeImpl tSrc = (TypeImpl) it.next(); TypeImpl tTgt = (TypeImpl) tsTgt.getType(tSrc.getName()); if (tTgt != null) { mSrc2Tgt.put(tSrc, tTgt); } } int[] r = new int[tsSrc.getNumberOfTypes() + 1]; // type codes are numbered starting with 1 for (Entry<TypeImpl, TypeImpl> e : mSrc2Tgt.entrySet()) { r[e.getKey().getCode()] = e.getValue().getCode(); } return r; }
List<Type> typesLocal = getProperlySubsumedTypes(ll_getTypeForCode(domain)); typesLocal.add(ll_getTypeForCode(domain)); Feature oldFeature = getFeatureByFullName(featureName); Type oldDomain = oldFeature.getDomain(); Type oldRange = oldFeature.getRange(); if (range == ll_getCodeForType(oldRange)) { return -1; e.addArgument(ll_getTypeForCode(domain).getName()); e.addArgument(ll_getTypeForCode(range).getName()); e.addArgument(oldDomain.getName()); e.addArgument(oldRange.getName()); max = this.typeNameST.size(); for (int i = 1; i <= max; i++) { if (subsumes(domain, i)) { (this.approp.get(i)).add(feat);
public void setStringValue(Feature feat, String val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); final int featCode = ((FeatureImpl) feat).getCode(); final int rangeType = ts.range(featCode); final int thisType = this.getCASImpl().getHeapValue(this.getAddress()); final int stringType = ((TypeImpl) this.getCASImpl().getTypeSystem().getType( CAS.TYPE_NAME_STRING)).getCode(); if (!ts.isApprop(thisType, featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT, new String[] { feat.getName(), this.getType().getName() }); throw e; } if (!ts.subsumes(stringType, rangeType)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE, new String[] { feat.getRange().getName(), this.getCAS().getTypeSystem().getType(CAS.TYPE_NAME_STRING).getName() }); throw e; } this.getCAS().getLowLevelCAS().ll_setStringValue(this.getAddress(), featCode, val); }
private void encodeTypeInheritance(TypeSystemImpl ts) { final int max = ts.getSmallestType() + ts.getNumberOfTypes(); this.typeInheritance = new int[max]; TypeImpl parent; // The smallest type is top, which doesn't inherit. for (int i = ts.getSmallestType() + 1; i < max; i++) { parent = (TypeImpl) ts.getParent(ts.ll_getTypeForCode(i)); this.typeInheritance[i] = parent.getCode(); } }