Search in sources :

Example 1 with ItemContext

use of com.yahoo.search.query.textserialize.item.ItemContext in project vespa by vespa-engine.

the class TextSerialize method parse.

public static Item parse(String serializedQuery) {
    try {
        ItemContext context = new ItemContext();
        Object result = new Parser(new StringReader(serializedQuery.replace("'", "\"")), new ItemFormHandler(), context).start();
        context.connectItems();
        if (!(result instanceof Item)) {
            throw new RuntimeException("The serialized query '" + serializedQuery + "' did not evaluate to an Item" + "(type = " + result.getClass() + ")");
        }
        return (Item) result;
    } catch (ParseException e) {
        throw new RuntimeException(e);
    } catch (TokenMgrError e) {
        throw new RuntimeException(e);
    }
}
Also used : ItemContext(com.yahoo.search.query.textserialize.item.ItemContext) Item(com.yahoo.prelude.query.Item) ItemFormHandler(com.yahoo.search.query.textserialize.item.ItemFormHandler) StringReader(java.io.StringReader) TokenMgrError(com.yahoo.search.query.textserialize.parser.TokenMgrError) ParseException(com.yahoo.search.query.textserialize.parser.ParseException) Parser(com.yahoo.search.query.textserialize.parser.Parser)

Example 2 with ItemContext

use of com.yahoo.search.query.textserialize.item.ItemContext in project vespa by vespa-engine.

the class ParseItemTestCase method parse.

public static Object parse(String input) throws ParseException {
    ItemContext context = new ItemContext();
    Object result = new Parser(new StringReader(input.replace("'", "\"")), new ItemFormHandler(), context).start();
    context.connectItems();
    return result;
}
Also used : ItemContext(com.yahoo.search.query.textserialize.item.ItemContext) ItemFormHandler(com.yahoo.search.query.textserialize.item.ItemFormHandler) StringReader(java.io.StringReader) Parser(com.yahoo.search.query.textserialize.parser.Parser)

Aggregations

ItemContext (com.yahoo.search.query.textserialize.item.ItemContext)2 ItemFormHandler (com.yahoo.search.query.textserialize.item.ItemFormHandler)2 Parser (com.yahoo.search.query.textserialize.parser.Parser)2 StringReader (java.io.StringReader)2 Item (com.yahoo.prelude.query.Item)1 ParseException (com.yahoo.search.query.textserialize.parser.ParseException)1 TokenMgrError (com.yahoo.search.query.textserialize.parser.TokenMgrError)1