use of org.mycore.parsers.bool.MCRParseException in project mycore by MyCoRe-Org.
the class MCRWorkflowRuleParser method parseString.
/* (non-Javadoc)
* @see org.mycore.access.mcrimpl.MCRRuleParser#parseString(java.lang.String)
*/
@Override
protected MCRCondition<?> parseString(String s) {
if (s.startsWith(STATUS)) {
s = s.substring(STATUS.length()).trim();
boolean not;
String value;
if (s.startsWith(EQUALS_NOT)) {
not = true;
value = s.substring(EQUALS_NOT.length()).trim();
} else if (s.startsWith(EQUALS)) {
not = false;
value = s.substring(EQUALS.length()).trim();
} else {
throw new MCRParseException("syntax error: " + s);
}
return new MCRCategoryCondition(STATUS, new MCRCategoryID(statusClassId.getRootID(), value), not);
}
return super.parseString(s);
}
use of org.mycore.parsers.bool.MCRParseException in project mycore by MyCoRe-Org.
the class MCRQueryParser method parseSimpleCondition.
/**
* Parses a String containing a simple query condition, for example: (title
* contains "Java") and (creatorID = "122132131")
*
* @param s
* the condition as a String
* @return the parsed MCRQueryCondition object
*/
@Override
protected MCRCondition<Void> parseSimpleCondition(String s) throws MCRParseException {
Matcher m = pattern.matcher(s);
if (!m.find()) {
throw new MCRParseException("Not a valid condition: " + s);
}
String field = m.group(1);
String operator = m.group(2);
String value = m.group(3);
if (value.startsWith("\"") && value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
}
return buildConditions(field, operator, value);
}
Aggregations