CAS cas = stream.getCas();
try {
jcas = cas.getJCas();
} catch (CASException e) {
}
TypeSystem typeSystem = cas.getTypeSystem();
Map<Type, Map<String, Object>> typeMap = fa.get(group);
if (typeMap != null) {
Map<String, Object> map = typeMap.get(type);
if (map != null) {
for (Entry<String, Object> eachEntry : map.entrySet()) {
String featureName = eachEntry.getKey();
Feature feature = type.getFeatureByBaseName(featureName);
if (feature != null) {
Object argExpr = eachEntry.getValue();
Type range = feature.getRange();
if (argExpr instanceof INumberExpression) {
INumberExpression ne = (INumberExpression) argExpr;
int cg = ne.getIntegerValue(getParent(), afs, stream);
if (range.getName().equals(UIMAConstants.TYPE_STRING)) {
String s = matchResult.group(cg);
afs.setStringValue(feature, s);
} else if (range.getName().equals(UIMAConstants.TYPE_BOOLEAN)) {
} else if (range.getName().equals(UIMAConstants.TYPE_BYTE)) {
} else if (range.getName().equals(UIMAConstants.TYPE_DOUBLE)) {
} else if (range.getName().equals(UIMAConstants.TYPE_FLOAT)) {
} else if (range.getName().equals(UIMAConstants.TYPE_INTEGER)) {
} else if (range.getName().equals(UIMAConstants.TYPE_LONG)) {
} else if (range.getName().equals(UIMAConstants.TYPE_SHORT)) {
} else {
if (typeSystem.subsumes(jcas.getCasType(FSArray.type), range)) {
// TODO add functionality for fsarrays
// AnnotationFS a = null;
// List<AnnotationFS> annotations = new ArrayList<AnnotationFS>(1);
// annotations.add(a);
// afs.setFeatureValue(feature, UIMAUtils.toFSArray(jcas, annotations));
} else {
int begin = delta + matchResult.start(cg);
int end = delta + matchResult.end(cg);
if (begin < end) {
AnnotationFS a = cas.createAnnotation(range, begin, end);
afs.setFeatureValue(feature, a);
}
}
}
} else {
if (argExpr instanceof TypeExpression
&& range.getName().equals(UIMAConstants.TYPE_STRING)) {
TypeExpression typeExpr = (TypeExpression) argExpr;
List<AnnotationFS> annotationsInWindow = stream.getAnnotationsInWindow(afs,
typeExpr.getType(getParent()));
if (annotationsInWindow != null && !annotationsInWindow.isEmpty()) {
AnnotationFS annotation = annotationsInWindow.get(0);
afs.setStringValue(feature, annotation.getCoveredText());
}
} else if (argExpr instanceof AbstractStringExpression
&& range.getName().equals(UIMAConstants.TYPE_STRING)) {
afs.setStringValue(feature,
((AbstractStringExpression) argExpr).getStringValue(getParent(), afs, stream));
// numbers are reserved for capturing groups
//
// } else if (argExpr instanceof NumberExpression) {
// if (range.getName().equals(UIMAConstants.TYPE_INTEGER)) {
// afs.setIntValue(feature,
// ((NumberExpression) argExpr).getIntegerValue(getParent()));
// } else if (range.getName().equals(UIMAConstants.TYPE_DOUBLE)) {
// afs.setDoubleValue(feature,
// ((NumberExpression) argExpr).getDoubleValue(getParent()));
// } else if (range.getName().equals(UIMAConstants.TYPE_FLOAT)) {
// afs.setFloatValue(feature,
// ((NumberExpression) argExpr).getFloatValue(getParent()));
// } else if (range.getName().equals(UIMAConstants.TYPE_BYTE)) {
// afs.setByteValue(feature,
// (byte) ((NumberExpression) argExpr).getIntegerValue(getParent()));
// } else if (range.getName().equals(UIMAConstants.TYPE_SHORT)) {
// afs.setShortValue(feature,
// (short) ((NumberExpression) argExpr).getIntegerValue(getParent()));
// } else if (range.getName().equals(UIMAConstants.TYPE_LONG)) {
// afs.setLongValue(feature,
// (long) ((NumberExpression) argExpr).getIntegerValue(getParent()));
// }
} else if (argExpr instanceof IBooleanExpression
&& range.getName().equals(UIMAConstants.TYPE_BOOLEAN)) {
afs.setBooleanValue(feature,
((IBooleanExpression) argExpr).getBooleanValue(getParent(), null, stream));
} else if (argExpr instanceof TypeExpression) {
TypeExpression typeExpr = (TypeExpression) argExpr;
List<AnnotationFS> annotationsInWindow = stream.getAnnotationsInWindow(afs,
typeExpr.getType(getParent()));
if (typeSystem.subsumes(jcas.getCasType(FSArray.type), range)) {
afs.setFeatureValue(feature, UIMAUtils.toFSArray(jcas, annotationsInWindow));
} else if (typeSystem.subsumes(range, typeExpr.getType(getParent()))
&& !annotationsInWindow.isEmpty()) {
AnnotationFS annotation = annotationsInWindow.get(0);
afs.setFeatureValue(feature, annotation);
}
}