/** * Creates a new instance for the given factory entity and query. * * @param factory the factory used to create constraints * @param descriptor the descriptor of entities being queried * @param query the query to compile * @param searchFields the default search fields to query */ protected QueryCompiler(FilterFactory<C> factory, EntityDescriptor descriptor, String query, List<QueryField> searchFields) { this.factory = factory; this.descriptor = descriptor; this.searchFields = searchFields; this.reader = new LookaheadReader(new StringReader(query)); }
@Override public QueryBuilder createQuery() { if (parsed.firstCall()) { LookaheadReader reader = new LookaheadReader(new StringReader(input)); QueryBuilder main = parseQuery(reader); if (!reader.current().isEndOfInput()) { IndexAccess.LOG.FINE("Unexpected character in query: " + reader.current()); } // If we cannot compile a query from a non empty input, we probably dropped all short tokens // like a search for "S 8" would be completely dropped. Therefore we resort to "S8". if (main == null && !Strings.isEmpty(input) && input.contains(" ")) { reader = new LookaheadReader(new StringReader(input.replaceAll("\\s", ""))); main = parseQuery(reader); } finishedQuery = main; } return finishedQuery; }
/** * Creates a new tokenizer for the given input * * @param input the input to parse. The reader will be buffered by the implementation so that it can be effectively * read character b character. */ public Tokenizer(Reader input) { this.input = new LookaheadReader(input); this.input.setProblemCollector(problemCollector); // Setup default string handling addStringDelimiter('"', '\\'); addStringDelimiter('\'', '\0'); }
/** * Creates a new tokenizer for the given input * * @param input the input to parse. The reader will be buffered by the implementation so that it can be effectively * read character b character. */ public Tokenizer(Reader input) { this.input = new LookaheadReader(input); this.input.setProblemCollector(problemCollector); // Setup default string handling addStringDelimiter('"', '\\'); addStringDelimiter('\'', '\0'); }