Sequence qr = (Sequence) session.getQueryResult().result; if (qr == null)
QueryResult queryResult = session.getQueryResult(); if (queryResult == null)
	public String[] retrieve(		String sessionId,		int start,		int howmany,		boolean indent,		boolean xinclude,		String highlight)		throws java.rmi.RemoteException {		Session session = SessionManager.getInstance().getSession(sessionId);		DBBroker broker = null;		try {			broker = pool.get(session.getUser());			Sequence qr = (Sequence) session.getQueryResult().result;			if (qr == null)				throw new RemoteException("result set unknown or timed out");			String xml[] = null;			switch (qr.getItemType()) {				case Type.NODE :					NodeSet resultSet = (NodeSet)qr;					--start;					if (start < 0 || start >= resultSet.getLength())						throw new RuntimeException(							"index " + start + " out of bounds (" + resultSet.getLength() + ")");					if (start + howmany >= resultSet.getLength())						howmany = resultSet.getLength() - start;					Serializer serializer = broker.getSerializer();					serializer.reset();					serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");					serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");					serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);					xml = new String[howmany];					for (int i = 0; i < howmany; i++) {						NodeProxy proxy = ((NodeSet) resultSet).get(start + i);						if (proxy == null)							throw new RuntimeException("not found: " + (start + i));						xml[i] = serializer.serialize(proxy);					}					break;				default :					--start;					if (start < 0 || start >= qr.getLength())						throw new RemoteException("index " + start + " out of bounds");					if (start + howmany >= qr.getLength())						howmany = qr.getLength() - start;					xml = new String[howmany];					for (int i = 0; i < howmany; i++) {						Item item = qr.itemAt(start);						xml[i] = item.getStringValue();					}			}			return xml;		} catch (Exception e) {			LOG.warn(e);			e.printStackTrace();			throw new RemoteException(e.getMessage(), e);		} finally {			pool.release(broker);		}	}