private boolean isBuiltInFeature(Feature aFeature) { Set<String> builtInTypes = new HashSet<>(asList( CAS.TYPE_NAME_TOP, CAS.TYPE_NAME_ANNOTATION_BASE, CAS.TYPE_NAME_ANNOTATION)); return builtInTypes.contains(aFeature.getDomain().getName()); }
@Override public Type getDomain() { checkDelegate(); return delegate.getDomain(); }
private boolean isBuiltInFeature(Feature aFeature) { Set<String> builtInTypes = new HashSet<>(asList( CAS.TYPE_NAME_TOP, CAS.TYPE_NAME_ANNOTATION_BASE, CAS.TYPE_NAME_ANNOTATION)); return builtInTypes.contains(aFeature.getDomain().getName()); }
public FSFeatureMatcher(Feature feature, Matcher<E> valueMatcher) { this.feature = feature; this.valueMatcher = valueMatcher; if (isCollectionType(feature.getRange())) { throw new IllegalArgumentException(String.format( "Feature '%s' (of type '%s') range is array", feature, feature.getDomain())); } }
public FSCollectionFeatureMatcher(Feature feature, Matcher<E> elemMatcher, boolean ignoreOrder) { super(feature, elemMatcher, ignoreOrder); Type elemType = getComponentType(feature.getRange()); if (elemType.isPrimitive()) { throw new IllegalArgumentException(String.format( "Feature '%s' (of type '%s') range is array of primitives", feature, feature.getDomain())); } }
public static CleartkExtractorException notPrimitive(Feature feature) { String key = KEY_PREFIX + "notPrimitive"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, feature.getDomain(), feature.getRange()); }
public static CleartkExtractorException notPrimitiveArray(Feature feature) { String key = KEY_PREFIX + "notPrimitiveArray"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, feature.getDomain(), feature.getRange()); }
public CollectionFeatureMatcherBase(Feature feature, Matcher<E> elemMatcher, boolean ignoreOrder) { this.feature = feature; this.elemMatcher = elemMatcher; this.ignoreOrder = ignoreOrder; if (!isCollectionType(feature.getRange())) { throw new IllegalArgumentException(String.format( "Feature '%s' (of type '%s') range is not array", feature, feature.getDomain())); } collectionMatcherDelegate = new CollectionMatcher<E, Collection<E>>( elemMatcher, ignoreOrder); }
public PrimitiveFeatureMatcher(Feature feature) { this.feature = feature; if (!feature.getRange().isPrimitive()) { throw new IllegalArgumentException(String.format( "Feature %s.%s is not primitive", feature.getDomain(), feature)); } // TODO if (feature.getRange().getName().equals("uima.cas.Float") || feature.getRange().getName().equals("uima.cas.Double")) { throw new UnsupportedOperationException( "Floating point types matching is not implemented yet"); } }
private void annotate(CAS cas, Feature feature, int begin, int end, String value) { Type type = feature.getDomain(); AnnotationFS annotation = cas.createAnnotation(type, begin, end); annotation.setStringValue(feature,value); cas.addFsToIndexes(annotation); }
public static void testType(JCas jcas, TOP top) throws Exception { Class<?> cls = top.getClass(); if (top instanceof Annotation) { testAnnotationType(jcas, (Annotation) top); } Type type = jcas.getTypeSystem().getType(cls.getName()); for (Object obj : type.getFeatures()) { Feature feature = (Feature) obj; if (feature.getDomain().equals(type)) { invokeMethods(cls, type, top, jcas, feature.getShortName()); } } }
private void encodeFeatureDecls(TypeSystemImpl ts) { final int max = ts.getSmallestFeature() + ts.getNumberOfFeatures(); this.featureNames = new String[max]; this.featDecls = new int[max * 3]; Feature f; for (int i = ts.getSmallestFeature(); i < max; i++) { f = ts.ll_getFeatureForCode(i); this.featureNames[i] = f.getShortName(); this.featDecls[i * 3] = ((TypeImpl) f.getDomain()).getCode(); this.featDecls[(i * 3) + 1] = ((TypeImpl) f.getRange()).getCode(); this.featDecls[(i * 3) + 2] = f.isMultipleReferencesAllowed() ? 1 : 0; } }
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 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 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 void setIntValue(Feature feat, int 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_INTEGER)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_INTEGER)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }
public void setByteValue(Feature feat, byte val) 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_BYTE)).getCode())) { throwIllegalRangeExc(feat, ts.getType(CAS.TYPE_NAME_BYTE)); } final int featCode = ((FeatureImpl) feat).getCode(); this.getCASImpl().setFeatureValue(this.getAddress(), featCode, val); }