use of com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParser in project vespa by vespa-engine.
the class FeatureList method parse.
/**
* Parses the content of a reader object as a list of feature nodes.
*
* @param reader A reader object that contains an feature list.
* @return A list of those features named in the string.
* @throws ParseException if the string could not be parsed.
*/
private static List<ReferenceNode> parse(Reader reader) throws ParseException {
List<ReferenceNode> lst;
try {
lst = new RankingExpressionParser(reader).featureList();
} catch (TokenMgrError e) {
ParseException t = new ParseException();
throw (ParseException) t.initCause(e);
}
List<ReferenceNode> ret = new ArrayList<ReferenceNode>(lst.size());
for (Object obj : lst) {
if (!(obj instanceof ReferenceNode)) {
throw new IllegalStateException("Feature list contains a " + obj.getClass().getName() + ".");
}
ret.add((ReferenceNode) obj);
}
return ret;
}
Aggregations