in SimpleServer/src/main/java/org/apache/uima/simpleserver/config/impl/SimpleFilterImpl.java [70:140]
private final boolean match(Stack<String> stack, FeatureStructure fs) {
if (stack.isEmpty()) {
// Can only be FS-type conditions
switch (this.getCondition().getConditionType()) {
case NULL: {
return (fs == null);
}
case NOT_NULL: {
return (fs != null);
}
default: {
// All other cases must be false
return false;
}
}
}
if (fs == null) {
return false;
}
// If we get here, we know the stack is not empty, so get the next feature.
String fName = stack.pop();
Feature f = fs.getType().getFeatureByBaseName(fName);
// If the feature is not defined for the type of the input FS, return false.
if (f == null) {
return false;
}
Type range = f.getRange();
final int typeClass = TypeSystemUtils.classifyType(range);
// If the next feature value is a FS, continue recursively.
if (typeClass == LowLevelCAS.TYPE_CLASS_FS) {
// If the type value is a regular FS, carry on recursively.
fs = fs.getFeatureValue(f);
return match(stack, fs);
}
// If we get here, the next feature value is not a FS, so the stack should be empty.
if (!stack.isEmpty()) {
return false;
}
// So now we know we're at the end of the path, the next feature value is what we evaluate
// against.
switch (typeClass) {
case LowLevelCAS.TYPE_CLASS_BOOLEAN: {
return checkBoolean(fs.getBooleanValue(f));
}
case LowLevelCAS.TYPE_CLASS_BYTE: {
return checkByte(fs.getByteValue(f));
}
case LowLevelCAS.TYPE_CLASS_DOUBLE: {
return checkDouble(fs.getDoubleValue(f));
}
case LowLevelCAS.TYPE_CLASS_FLOAT: {
return checkFloat(fs.getFloatValue(f));
}
case LowLevelCAS.TYPE_CLASS_INT: {
return checkInt(fs.getIntValue(f));
}
case LowLevelCAS.TYPE_CLASS_LONG: {
return checkLong(fs.getLongValue(f));
}
case LowLevelCAS.TYPE_CLASS_SHORT: {
return checkShort(fs.getShortValue(f));
}
case LowLevelCAS.TYPE_CLASS_STRING: {
return checkString(fs.getStringValue(f));
}
default: {
// Catch-all: any types we don't handle (arrays) will automatically return false.
return false;
}
}
}