public void addAll(NodeSet other) { long start = System.currentTimeMillis(); NodeProxy p; IteratorItem item; DocumentSet docs = new DocumentSet(); for (Iterator i = other.iterator(); i.hasNext();) { p = (NodeProxy) i.next(); docs.add(p.doc); } DBBroker broker = null; try { broker = pool.get(user); StaticContext context = new StaticContext(broker); XPathLexer2 lexer = new XPathLexer2(new StringReader(sortExpr)); XPathParser2 parser = new XPathParser2(lexer); XPathTreeParser2 treeParser = new XPathTreeParser2(context); parser.xpath(); if (parser.foundErrors()) { LOG.debug(parser.getErrorMessage()); }  AST ast = parser.getAST(); LOG.debug("generated AST: " + ast.toStringTree());  expr = new PathExpr(); treeParser.xpath(ast, expr); if (treeParser.foundErrors()) { LOG.debug(treeParser.getErrorMessage()); } ndocs = expr.preselect(docs, context); for (Iterator i = other.iterator(); i.hasNext();) { p = (NodeProxy) i.next(); item = new IteratorItem(broker, p, expr, ndocs, context); list.add(item); } } catch (antlr.RecognitionException re) { LOG.debug(re); } catch (antlr.TokenStreamException tse) { LOG.debug(tse); } catch (XPathException e) { LOG.debug(e.getMessage(), e); } catch (EXistException e) { LOG.debug("exception during sort", e); } finally { pool.release(broker); } LOG.debug( "sort-expression found " + list.size() + " in " + (System.currentTimeMillis() - start) + "ms.");
public void addAll(Sequence other) throws XPathException { addAll(other.toNodeSet());
	public void addAll(NodeSet other) {		long start = System.currentTimeMillis();		NodeProxy p;		IteratorItem item;		DocumentSet docs = new DocumentSet();		for (Iterator i = other.iterator(); i.hasNext();) {			p = (NodeProxy) i.next();			docs.add(p.doc);		}		DBBroker broker = null;		try {			broker = pool.get(user);			StaticContext context = new StaticContext(broker);			XPathLexer2 lexer = new XPathLexer2(new StringReader(sortExpr));			XPathParser2 parser = new XPathParser2(lexer);			XPathTreeParser2 treeParser = new XPathTreeParser2(context);			parser.xpath();			if (parser.foundErrors()) {				LOG.debug(parser.getErrorMessage());			}			AST ast = parser.getAST();			LOG.debug("generated AST: " + ast.toStringTree());			expr = new PathExpr();			treeParser.xpath(ast, expr);			if (treeParser.foundErrors()) {				LOG.debug(treeParser.getErrorMessage());			}			ndocs = expr.preselect(docs, context);			for (Iterator i = other.iterator(); i.hasNext();) {				p = (NodeProxy) i.next();				item = new IteratorItem(broker, p, expr, ndocs, context);				list.add(item);			}		} catch (antlr.RecognitionException re) {			LOG.debug(re);		} catch (antlr.TokenStreamException tse) {			LOG.debug(tse);		} catch (XPathException e) {			LOG.debug(e.getMessage(), e);		} catch (EXistException e) {			LOG.debug("exception during sort", e);		} finally {			pool.release(broker);		}		LOG.debug(			"sort-expression found "				+ list.size()				+ " in "				+ (System.currentTimeMillis() - start)				+ "ms.");	}