public float getFloatValue(String name) { return featureStructure.getFloatValue(getFeature(name)); }
public static Object floatListToArray(FeatureStructure fs) { List<Float> list = new ArrayList<Float>(); TypeSystem ts = fs.getCAS().getTypeSystem(); Type emptyFSList = ts.getType("uima.cas.EmptyFloatList"); Feature headFeature = ts.getFeatureByFullName("uima.cas.NonEmptyFloatList:head"); Feature tailFeature = ts.getFeatureByFullName("uima.cas.NonEmptyFloatList:tail"); Set<FeatureStructure> alreadySeen = new HashSet<FeatureStructure>(); FeatureStructure nextFs; for (FeatureStructure currentFs = fs; currentFs.getType() != emptyFSList; currentFs = nextFs) { list.add(Float.valueOf(currentFs.getFloatValue(headFeature))); nextFs = currentFs.getFeatureValue(tailFeature); if (alreadySeen.contains(nextFs)) { return loopInList(list); } alreadySeen.add(nextFs); } float[] floatArray = new float[list.size()]; for (int i = 0; i < floatArray.length; i++) { floatArray[i] = list.get(i).floatValue(); } return floatArray; }
public boolean match(FeatureStructure fs) { // compile(((FeatureStructureImpl) fs).getCAS().getTypeSystem()); final int max = this.featNames.size() - 1; // The last position in the // path! if (max < 0) { // If the path is empty, we can't get a float, and therefore the // constraint is not satisfied. return false; } Feature feat; for (int i = 0; i < max; i++) { feat = fs.getType().getFeatureByBaseName(this.featNames.get(i)); if (feat == null) { return false; } fs = fs.getFeatureValue(feat); } feat = fs.getType().getFeatureByBaseName(this.featNames.get(max)); if (feat == null) { return false; } return this.floatConstraint.match(fs.getFloatValue(feat)); }
result = structure.getLongValue(feature); } else if (Float.class.equals(primitiveClass)) { result = structure.getFloatValue(feature); } else if (Double.class.equals(primitiveClass)) { result = structure.getDoubleValue(feature);
private static void fillFeatures(DebugNameValuePair[] result, int startOffset, FeatureStructure fs, List<Feature> features) { int nbrFeats = features.size(); int i = startOffset; for (int j = 0; j < nbrFeats; j++) { Feature feat = features.get(j); DebugNameValuePair nv = new DebugNameValuePair(feat.getShortName(), null); String rangeTypeName = feat.getRange().getName(); if ("uima.cas.Integer".equals(rangeTypeName)) nv.setValue(Integer.valueOf(fs.getIntValue(feat))); else if ("uima.cas.Float".equals(rangeTypeName)) nv.setValue(Float.valueOf(fs.getFloatValue(feat))); else if ("uima.cas.Boolean".equals(rangeTypeName)) nv.setValue(Boolean.valueOf(fs.getBooleanValue(feat))); else if ("uima.cas.Byte".equals(rangeTypeName)) nv.setValue(Byte.valueOf(fs.getByteValue(feat))); else if ("uima.cas.Short".equals(rangeTypeName)) nv.setValue(Short.valueOf(fs.getShortValue(feat))); else if ("uima.cas.Long".equals(rangeTypeName)) nv.setValue(Long.valueOf(fs.getLongValue(feat))); else if ("uima.cas.Double".equals(rangeTypeName)) nv.setValue(Double.valueOf(fs.getDoubleValue(feat))); else if ("uima.cas.String".equals(rangeTypeName)) nv.setValue(fs.getStringValue(feat)); else nv.setValue(fs.getFeatureValue(feat)); result[i++] = nv; } }
break; case CAS.TYPE_NAME_FLOAT: generator.writeNumber(annotation.getFloatValue(feature)); break; case CAS.TYPE_NAME_STRING:
break; case LowLevelCAS.TYPE_CLASS_FLOAT: featurePathValue = Float.toString(currentFS.getFloatValue(feature)); noFurtherElementsPossible = true; break;
break; case LowLevelCAS.TYPE_CLASS_FLOAT: featurePathValue = Float.toString(currentFS.getFloatValue(feature)); noFurtherElementsPossible = true; break;
return featureStructure.getDoubleValue(feature); else if (type.equals(typeSystem.getType("uima.cas.Float"))) return featureStructure.getFloatValue(feature); else if (type.equals(typeSystem.getType("uima.cas.Byte"))) return featureStructure.getByteValue(feature);
private Number getNumberValue(MatchContext context, RutaStream stream) { AnnotationFS annotation = context.getAnnotation(); Number result = null; List<AnnotationFS> list = this.getTargetAnnotation(annotation, this.fe, context, stream); Collection<? extends FeatureStructure> featureStructures = this.fe.getFeatureStructures(list, false, context, stream); if (!featureStructures.isEmpty()) { Feature feature = this.fe.getFeature(context, stream); Type range = feature.getRange(); FeatureStructure next = featureStructures.iterator().next(); if (next instanceof AnnotationFS && !next.getType().equals(annotation.getType())) { feature = this.fe.getFeature(new MatchContext((AnnotationFS) next, context.getElement(), context.getRuleMatch(), context.getDirection()), stream); } if (CAS.TYPE_NAME_BYTE.equals(range.getName())) { result = next.getByteValue(feature); } else if (CAS.TYPE_NAME_DOUBLE.equals(range.getName())) { result = next.getDoubleValue(feature); } else if (CAS.TYPE_NAME_FLOAT.equals(range.getName())) { result = next.getFloatValue(feature); } else if (CAS.TYPE_NAME_INTEGER.equals(range.getName())) { result = next.getIntValue(feature); } else if (CAS.TYPE_NAME_LONG.equals(range.getName())) { result = next.getLongValue(feature); } else if (CAS.TYPE_NAME_SHORT.equals(range.getName())) { result = next.getShortValue(feature); } } return result; }
public static <T> T getFeature(FeatureStructure aFS, String aFeatureName) { Feature feature = aFS.getType().getFeatureByBaseName(aFeatureName); if (feature == null) { throw new IllegalArgumentException("Type [" + aFS.getType().getName() + "] has no feature called [" + aFeatureName + "]"); } switch (feature.getRange().getName()) { case CAS.TYPE_NAME_STRING: return (T) aFS.getStringValue(feature); case CAS.TYPE_NAME_BOOLEAN: return (T) (Boolean) aFS.getBooleanValue(feature); case CAS.TYPE_NAME_FLOAT: return (T) (Float) aFS.getFloatValue(feature); case CAS.TYPE_NAME_INTEGER: return (T) (Integer) aFS.getIntValue(feature); default: throw new IllegalArgumentException("Cannot get value of feature [" + feature.getName() + "] with type [" + feature.getRange().getName() + "]"); } }
public static <T> T getFeature(FeatureStructure aFS, String aFeatureName) { Feature feature = aFS.getType().getFeatureByBaseName(aFeatureName); if (feature == null) { throw new IllegalArgumentException("Type [" + aFS.getType().getName() + "] has no feature called [" + aFeatureName + "]"); } switch (feature.getRange().getName()) { case CAS.TYPE_NAME_STRING: return (T) aFS.getStringValue(feature); case CAS.TYPE_NAME_BOOLEAN: return (T) (Boolean) aFS.getBooleanValue(feature); case CAS.TYPE_NAME_FLOAT: return (T) (Float) aFS.getFloatValue(feature); case CAS.TYPE_NAME_INTEGER: return (T) (Integer) aFS.getIntValue(feature); default: throw new IllegalArgumentException("Cannot get value of feature [" + feature.getName() + "] with type [" + feature.getRange().getName() + "]"); } }
ps.setLong(argIdx, anno.getLongValue(feat)); } else if ("uima.cas.Float".equals(feat.getRange().getName())) { ps.setFloat(argIdx, anno.getFloatValue(feat)); } else if ("uima.cas.Double".equals(feat.getRange().getName())) { ps.setDouble(argIdx, anno.getDoubleValue(feat));
newFs.addFeature(new Feature<Double>(fName, fVal)); } else if (casF.getRange().getName().equals("uima.cas.Float")) { float fVal = casFs.getFloatValue(casF); newFs.addFeature(new Feature<Double>(fName, (double) fVal)); } else {
Float v1 = fs.getFloatValue(feature); if (getArg() instanceof INumberExpression) { INumberExpression expr = (INumberExpression) getArg();
/** * Get the feature value of this {@code Feature} on this annotation */ private static Object getFeatureValue(FeatureStructure aFS, Feature aFeature) { switch (aFeature.getRange().getName()) { case CAS.TYPE_NAME_STRING: return aFS.getFeatureValueAsString(aFeature); case CAS.TYPE_NAME_BOOLEAN: return aFS.getBooleanValue(aFeature); case CAS.TYPE_NAME_FLOAT: return aFS.getFloatValue(aFeature); case CAS.TYPE_NAME_INTEGER: return aFS.getIntValue(aFeature); case CAS.TYPE_NAME_BYTE: return aFS.getByteValue(aFeature); case CAS.TYPE_NAME_DOUBLE: return aFS.getDoubleValue(aFeature); case CAS.TYPE_NAME_LONG: aFS.getLongValue(aFeature); case CAS.TYPE_NAME_SHORT: aFS.getShortValue(aFeature); default: return null; // return aFS.getFeatureValue(aFeature); } }
/** * Get the feature value of this {@code Feature} on this annotation */ private static Object getFeatureValue(FeatureStructure aFS, Feature aFeature) { switch (aFeature.getRange().getName()) { case CAS.TYPE_NAME_STRING: return aFS.getFeatureValueAsString(aFeature); case CAS.TYPE_NAME_BOOLEAN: return aFS.getBooleanValue(aFeature); case CAS.TYPE_NAME_FLOAT: return aFS.getFloatValue(aFeature); case CAS.TYPE_NAME_INTEGER: return aFS.getIntValue(aFeature); case CAS.TYPE_NAME_BYTE: return aFS.getByteValue(aFeature); case CAS.TYPE_NAME_DOUBLE: return aFS.getDoubleValue(aFeature); case CAS.TYPE_NAME_LONG: aFS.getLongValue(aFeature); case CAS.TYPE_NAME_SHORT: aFS.getShortValue(aFeature); default: return null; // return aFS.getFeatureValue(aFeature); } }
newFS.setIntValue(feature, intValue); } else if (oldRange.getShortName().equals("Float")) { Float floatValue = oldFS.getFloatValue(oldFeature); newFS.setFloatValue(feature, floatValue); } else if (oldRange.getShortName().equals("Boolean")) {
newFS.setIntValue(feature, intValue); } else if (oldRange.getShortName().equals("Float")) { Float floatValue = oldFS.getFloatValue(oldFeature); newFS.setFloatValue(feature, floatValue); } else if (oldRange.getShortName().equals("Boolean")) {
break; case LowLevelCAS.TYPE_CLASS_FLOAT: checkCondidtion = checkFloat(currentFS.getFloatValue(feature), condition); noFurtherElementsPossible = true; break;