} finally { brokerPool.release(broker); } } else doc = (DocumentImpl) documentCache.get(docName); NodeProxy node = new NodeProxy(doc, id); nodes = new ArraySet(1); nodes.add(node); docs = new DocumentSet(); docs.add(node.doc); } Value resultValue = doQuery(user, xpath, docs, nodes, namespaces); if (resultValue == null) return ret; switch (resultValue.getType()) { case Value.isNodeList : NodeSet resultSet = (NodeSet) resultValue.getNodeList(); if (sortBy != null) { SortedNodeSet sorted = new SortedNodeSet(brokerPool, user, sortBy); sorted.addAll(resultSet); resultSet = sorted; resultValue = new ValueNodeSet(sorted); } NodeProxy p; Vector entry; for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); entry = new Vector(); entry.addElement(p.doc.getFileName()); entry.addElement(Long.toString(p.getGID())); result.addElement(entry); } break; default : ValueSet valueSet = resultValue.getValueSet(); Value val; for (int i = 0; i < valueSet.getLength(); i++) { val = valueSet.get(i); result.addElement(val.getStringValue()); }
} else doc = (DocumentImpl) documentCache.get(docName); NodeProxy node = new NodeProxy(doc, id); nodes = new ArraySet(1); nodes.add(node); docs = new DocumentSet(); docs.add(node.doc); } resultValue = doQuery(user, broker, xpath, docs, nodes, namespaces); if (resultValue == null) return ret; switch (resultValue.getType()) { case Value.isNodeList : NodeSet resultSet = (NodeSet) resultValue.getNodeList(); if (sortBy != null) { SortedNodeSet sorted = new SortedNodeSet(brokerPool, user, sortBy); sorted.addAll(resultSet); resultSet = sorted; resultValue = new ValueNodeSet(sorted); } NodeProxy p; Vector entry; for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext(); ) { p = (NodeProxy) i.next(); entry = new Vector(); entry.addElement(p.doc.getFileName()); entry.addElement(Long.toString(p.getGID())); result.addElement(entry); } break; default : ValueSet valueSet = resultValue.getValueSet(); Value val; for (int i = 0; i < valueSet.getLength(); i++) { val = valueSet.get(i); result.addElement(val.getStringValue()); } } } finally { brokerPool.release(broker);
	public Hashtable queryP(		User user,		String xpath,		String docName,		String s_id,		String sortBy,		Hashtable namespaces)		throws Exception {		long startTime = System.currentTimeMillis();		Hashtable ret = new Hashtable();		Vector result = new Vector();		NodeSet nodes = null;		DocumentSet docs = null;		if (docName != null && s_id != null) {			long id = Long.parseLong(s_id);			DocumentImpl doc;			if (!documentCache.containsKey(docName)) {				DBBroker broker = null;				try {					broker = brokerPool.get();					doc = (DocumentImpl) broker.getDocument(docName);					documentCache.put(docName, doc);				} finally {					brokerPool.release(broker);				}			} else				doc = (DocumentImpl) documentCache.get(docName);			NodeProxy node = new NodeProxy(doc, id);			nodes = new ArraySet(1);			nodes.add(node);			docs = new DocumentSet();			docs.add(node.doc);		}		Value resultValue = doQuery(user, xpath, docs, nodes, namespaces);		if (resultValue == null)			return ret;		switch (resultValue.getType()) {			case Value.isNodeList :				NodeSet resultSet = (NodeSet) resultValue.getNodeList();				if (sortBy != null) {					SortedNodeSet sorted =						new SortedNodeSet(brokerPool, user, sortBy);					sorted.addAll(resultSet);					resultSet = sorted;					resultValue = new ValueNodeSet(sorted);				}				NodeProxy p;				Vector entry;				for (Iterator i = ((NodeSet) resultSet).iterator();					i.hasNext();					) {					p = (NodeProxy) i.next();					entry = new Vector();					entry.addElement(p.doc.getFileName());					entry.addElement(Long.toString(p.getGID()));					result.addElement(entry);				}				break;			default :				ValueSet valueSet = resultValue.getValueSet();				Value val;				for (int i = 0; i < valueSet.getLength(); i++) {					val = valueSet.get(i);					result.addElement(val.getStringValue());				}		}		QueryResult qr =			new QueryResult(				resultValue,				(System.currentTimeMillis() - startTime));		connectionPool.resultSets.put(qr.hashCode(), qr);		ret.put("id", new Integer(qr.hashCode()));		ret.put("results", result);		return ret;	}