Refine search
/** initialize variables to correspond with Cas Type and Features * @generated */ public Header_Type(JCas jcas, Type casType) { super(jcas, casType); casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator()); casFeat_confidence = jcas.getRequiredFeatureDE(casType, "confidence", "uima.cas.Double", featOkTst); casFeatCode_confidence = (null == casFeat_confidence) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_confidence).getCode(); casFeat_normalizedTitle = jcas.getRequiredFeatureDE(casType, "normalizedTitle", "uima.cas.String", featOkTst); casFeatCode_normalizedTitle = (null == casFeat_normalizedTitle) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_normalizedTitle).getCode(); } }
public String toString() { return getName(); }
public void setBooleanValue(Feature feat, boolean b) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_BOOLEAN)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BOOLEAN)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, b); }
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); }
public void setFeatureValue(Feature feat, FeatureStructure fs) { final int valueAddr = this.getCASImpl().ll_getFSRef(fs); final int featCode = ((FeatureImpl) feat).getCode(); final int rangeType = this.getCASImpl().getTypeSystemImpl().range(featCode); if (valueAddr == CASImpl.NULL) { setNullValue(featCode, rangeType); return; } final int thisType = this.getCASImpl().getHeapValue(this.getAddress()); final int valueType = this.getCASImpl().getHeapValue(valueAddr); if (!this.getCASImpl().getTypeSystemImpl().isApprop(thisType, featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE, new String[] { feat.getName(), this.getType().getName() }); throw e; } if (!this.getCASImpl().getTypeSystemImpl().subsumes(rangeType, valueType)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_RANGE, new String[] { feat.getName(), feat.getRange().getName(), fs.getType().getName() }); throw e; } // keys are not fsRefs this.getCASImpl().setFeatureValueNoIndexCorruptionCheck(this.getAddress(), featCode, valueAddr); }
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); }
final int srcFeatCode = srcFeatCodes[i]; Feature srcFeat = srcTsi.ll_getFeatureForCode(srcFeatCode); setRangeClass((TypeImpl) srcFeat.getRange(), i); final int i2 = i << 1; codesAndOffsets[i2 + K_SRC_FEAT_OFFSET] = originalSrcCasImpl.getFeatureOffset(srcFeatCode); codesAndOffsets[i2 + K_TGT_FEAT_CODE] = srcFeatCodes[i]; final int srcFeatCode = srcFeatCodes[i]; Feature srcFeat = srcTsi.ll_getFeatureForCode(srcFeatCode); String srcFeatName = srcFeat.getName(); Feature tgtFeat = tgtTsi.getFeatureByFullName(srcFeatName); if (tgtFeat == null) { int tgtFeatCode = ((FeatureImpl)tgtFeat).getCode(); codesAndOffsets[i2 + K_SRC_FEAT_OFFSET] = originalSrcCasImpl.getFeatureOffset(srcFeatCode); codesAndOffsets[i2 + K_TGT_FEAT_CODE] = tgtFeatCode; TypeImpl srcRangeType = (TypeImpl) srcFeat.getRange();
public long getLongValue(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_LONG))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_LONG)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getLongValue(this.getAddress(), featCode); }
public float getFloatValue(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_FLOAT))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_FLOAT)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getFloatValue(this.getAddress(), featCode); }
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); }
public double getDoubleValue(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_DOUBLE))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_DOUBLE)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getDoubleValue(this.getAddress(), featCode); }
public byte getByteValue(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_BYTE))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BYTE)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getByteValue(this.getAddress(), featCode); }
public short getShortValue(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_SHORT))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_SHORT)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getShortValue(this.getAddress(), featCode); }
public void setFloatValue(Feature feat, float val) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(((TypeImpl) feat.getDomain()).getCode(), this.getCASImpl().getHeapValue( this.getAddress()))) { throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(((TypeImpl) feat.getRange()).getCode(), ((TypeImpl) ts .getType(CAS.TYPE_NAME_FLOAT)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_FLOAT)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFloatValue(this.getAddress(), featCode, val); }
public int getIntValue(Feature feat) { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); if (!ts.subsumes(feat.getDomain(), getType())) { // System.out.println( // "Domain: " // + feat.getDomain().getName() // + ", type: " // + getType().getName()); throwUndefinedFeatureExc(feat, getType()); } if (!ts.subsumes(feat.getRange(), ts.getType(CAS.TYPE_NAME_INTEGER))) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_INTEGER)); } final int featCode = ((FeatureImpl) feat).getCode(); return this.getCASImpl().getFeatureValue(this.getAddress(), featCode); }
public String getStringValue(Feature f) throws CASRuntimeException { final int thisType = ((TypeImpl) this.getType()).getCode(); final int domType = ((TypeImpl) f.getDomain()).getCode(); final int stringType = ((TypeImpl) this.getCASImpl().getTypeSystem().getType( CAS.TYPE_NAME_STRING)).getCode(); final int rangeType = ((TypeImpl) f.getRange()).getCode(); final TypeSystemImpl ts = (TypeSystemImpl) this.getCASImpl().getTypeSystem(); if (!ts.subsumes(domType, thisType)) { throwUndefinedFeatureExc(f, getType()); } if (!ts.subsumes(stringType, rangeType)) { throwIllegalRangeExc(f, this.getCASImpl().getTypeSystem().getType(CAS.TYPE_NAME_STRING)); } // final int stringAddr = casImpl.getFeatureValue(this.getAddress(), // ((FeatureImpl)f).getCode()); // return casImpl.getStringValue(stringAddr); return this.getCASImpl().getStringValue(this.getAddress(), ((FeatureImpl) f).getCode()); }
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])); } }
public FeatureStructure getFeatureValue(Feature feat) throws CASRuntimeException { final TypeSystemImpl ts = this.getCASImpl().getTypeSystemImpl(); // final int featCode = ts.getFeatureCode(feat.getName()); final int featCode = ((FeatureImpl) feat).getCode(); // assert(featCode > 0); if (!ts.isApprop(this.getCASImpl().getHeapValue(this.getAddress()), featCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT, new String[] { feat.getName(), this.getType().getName() }); throw e; } // Check that feature value is not primitive. final int rangeTypeCode = ts.ll_getRangeType(featCode); if (!this.getCASImpl().ll_isRefType(rangeTypeCode)) { CASRuntimeException e = new CASRuntimeException(CASRuntimeException.PRIMITIVE_VAL_FEAT, new String[] { feat.getName() }); throw e; } final int valAddr = this.getCASImpl().getFeatureValue(this.getAddress(), featCode); // assert(valAddr > 0); return this.getCASImpl().createFS(valAddr); }
private final void computeFeatureOffsets(Type t, int offset) { // Find all features for which the input type is the domain type. List<Feature> allFeats = t.getFeatures(); ArrayList<Feature> introFeats = new ArrayList<Feature>(); final int numAllFeats = allFeats.size(); Feature feat; for (int i = 0; i < numAllFeats; i++) { feat = allFeats.get(i); if (feat.getDomain() == t) { introFeats.add(feat); } } // For each feature for which the input type is the domain, assign an // offset // arbitrarily, starting with the input offset + 1. int featCode; final int numFeats = introFeats.size(); for (int i = 0; i < numFeats; i++) { featCode = ((FeatureImpl) introFeats.get(i)).getCode(); this.featureOffset[featCode] = offset + 1 + i; } // Call routine recursively for all subtypes. Increment input offset by // number of features introduced on this type. Vector<Type> immediateSubtypes = ts.getDirectlySubsumedTypes(t); final int numTypes = immediateSubtypes.size(); for (int i = 0; i < numTypes; i++) { computeFeatureOffsets(immediateSubtypes.get(i), offset + numFeats); } }
public XCASSerializer(TypeSystem ts, UimaContext uimaContext) { super(); // System.out.println("Creating serializer for type system."); this.ts = (TypeSystemImpl) ts; this.uimaContext = uimaContext; // Create feature name cache. final int featArraySize = this.ts.getNumberOfFeatures() + 1; this.featureNames = new String[featArraySize]; FeatureImpl feat; String featName; Iterator<Feature> it = this.ts.getFeatures(); while (it.hasNext()) { feat = (FeatureImpl) it.next(); if (feat.getRange().isPrimitive()) { featName = feat.getShortName(); } else { featName = REF_PREFIX + feat.getShortName(); } this.featureNames[feat.getCode()] = featName; } }