public Value eval(DocumentSet docs, NodeSet context, NodeProxy node) { NodeSet nodes = (NodeSet) path.eval(docs, context, null).getNodeList();
public Value eval(StaticContext context, DocumentSet docs, NodeSet contextSet, NodeProxy contextNode) { NodeSet nodes = (NodeSet) path.eval(context, docs, contextSet, contextNode).getNodeList();
	public Value eval(DocumentSet docs, NodeSet context, NodeProxy node) {		NodeSet nodes = (NodeSet) path.eval(docs, context, null).getNodeList();		if (hits == null)			processQuery(docs);		long pid;		NodeProxy current;		NodeProxy parent;		NodeSet temp;		long start = System.currentTimeMillis();		for (int j = 0; j < hits.length; j++) {			temp = new ArraySet(100);			for (int k = 0; k < hits[j].length; k++) {				if (hits[j][k] == null)					continue;				for (Iterator i = hits[j][k].iterator(); i.hasNext();) {					current = (NodeProxy) i.next();					parent = nodes.parentWithChild(current, false, true);					if (parent != null) {						if (temp.contains(parent)) {							parent.addMatches(current.matches);						} else {							parent.addMatches(current.matches);							temp.add(parent);						}					}				}			}			hits[j][0] = temp;		}		NodeSet t0 = null;		NodeSet t1;		for (int j = 0; j < hits.length; j++) {			t1 = hits[j][0];			if (t0 == null)				t0 = t1;			else				t0 = t0.intersection(t1);		}		if (t0 == null) {			t0 = new ArraySet(1);			return new ValueNodeSet(t0);		}		// generate list of search term patterns		Pattern terms[] = new Pattern[containsExpr.size()];		for (int i = 0; i < terms.length; i++)			try {				terms[i] =					globCompiler.compile(						containsExpr.get(i).toString(),						GlobCompiler.CASE_INSENSITIVE_MASK							| GlobCompiler.QUESTION_MATCHES_ZERO_OR_ONE_MASK);			} catch (MalformedPatternException e) {				LOG.warn("malformed pattern", e);				return new ValueNodeSet(NodeSet.EMPTY_SET);			}		// walk through hits and calculate term-distances		String value;		Pattern term;		String word;		TextToken token;		ArraySet result = new ArraySet(100);		DBBroker broker = null;		PatternMatcher matcher = new Perl5Matcher();		try {			broker = pool.get();			Tokenizer tok = broker.getTextEngine().getTokenizer();			int j;			int distance;			for (Iterator i = t0.iterator(); i.hasNext();) {				current = (NodeProxy) i.next();				value = broker.getNodeValue(current);				tok.setText(value);				j = 0;				if (j < terms.length)					term = terms[j];				else					break;				distance = -1;				while ((token = tok.nextToken()) != null) {					word = token.getText().toLowerCase();					if (distance > max_distance) {						// reset						j = 0;						term = terms[j];						distance = -1;						continue;					}					if (matcher.matches(word, term)) {						distance = 0;						j++;						if (j == terms.length) {							// all terms found							result.add(current);							break;						} else							term = terms[j];					} else if (j > 0 && matcher.matches(word, terms[0])) {						// first search term found: start again						j = 0;						term = terms[j];						distance = -1;						continue;					} else if (-1 < distance)						++distance;				}			}		} catch (EXistException e) {			e.printStackTrace();		} finally {			pool.release(broker);		}		return new ValueNodeSet(result);	}