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); }
if (resultSet != null) { Iterator i = ((NodeSet) resultSet).iterator(); if(i != null) { while (i.hasNext()) { p = (NodeProxy) i.next(); entry = new Vector(); entry.addElement(p.doc.getFileName()); entry.addElement(Long.toString(p.getGID())); result.addElement(entry); } } else LOG.debug("iterator was null. Should not!"); } else LOG.debug("result set was null. Should not!");
	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;		Value resultValue = null;		DBBroker broker = null;		try {			broker = brokerPool.get(user);			if (docName != null && s_id != null) {				long id = Long.parseLong(s_id);				DocumentImpl doc;				if (!documentCache.containsKey(docName)) {					doc = (DocumentImpl) broker.getDocument(docName);					documentCache.put(docName, doc);				} 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);		}		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;	}