/** * Returns a node for the specified term. * * @param term term * @return node */ private ThesNode node(final byte[] term) { ThesNode node = nodes.get(term); if (node == null) { node = new ThesNode(); node.term = term; nodes.put(term, node); } return node; }
/** * Returns a regular expression pattern. * * @param pattern input pattern * @param modifier modifier item * @param ctx query context * @return pattern modifier * @throws QueryException query exception */ private Pattern pattern(final Expr pattern, final Expr modifier, final QueryContext ctx) throws QueryException { final byte[] pat = checkStr(pattern, ctx); final byte[] mod = modifier != null ? checkStr(modifier, ctx) : null; final TokenBuilder tb = new TokenBuilder(pat); if (mod != null) tb.add(0).add(mod); final byte[] key = tb.finish(); Pattern p = patterns.get(key); if (p == null) { p = RegExParser.parse(pat, mod, ctx.sc.xquery3(), info); patterns.add(key, p); } return p; }
/** * Finds a thesaurus term. * * @param ii input info * @param list result list * @param token token * @throws QueryException query exception */ void find(final InputInfo ii, final TokenList list, final byte[] token) throws QueryException { if (nodes.isEmpty()) init(ii); find(list, nodes.get(token), 1); }