Search in sources :

Example 1 with TypeSystemImpl

use of org.apache.uima.cas.impl.TypeSystemImpl in project webanno by webanno.

the class RemoteApiController2 method forceSetFeatureValue.

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);
}
Also used : CASImpl(org.apache.uima.cas.impl.CASImpl) FeatureImpl(org.apache.uima.cas.impl.FeatureImpl) TypeSystemImpl(org.apache.uima.cas.impl.TypeSystemImpl) Feature(org.apache.uima.cas.Feature) TypeImpl(org.apache.uima.cas.impl.TypeImpl)

Aggregations

Feature (org.apache.uima.cas.Feature)1 CASImpl (org.apache.uima.cas.impl.CASImpl)1 FeatureImpl (org.apache.uima.cas.impl.FeatureImpl)1 TypeImpl (org.apache.uima.cas.impl.TypeImpl)1 TypeSystemImpl (org.apache.uima.cas.impl.TypeSystemImpl)1