}
}
public java.lang.String[] retrieveByDocument(java.lang.String sessionId, int start, int howmany, java.lang.String path, boolean indent, boolean xinclude, java.lang.String highlight) throws java.rmi.RemoteException {
final Session session = getSession(sessionId);
DBBroker broker = null;
try {
broker = pool.get(session.getUser());
final Sequence qr = (Sequence) session.getQueryResult().result;
if (qr == null)
{throw new RemoteException("result set unknown or timed out");}
String xml[] = null;
if (Type.subTypeOf(qr.getItemType(), Type.NODE)) {
// Fix typecast exception RMT
// NodeList resultSet = (NodeSet)qr;
final ExtArrayNodeSet hitsByDoc = new ExtArrayNodeSet();
NodeProxy p;
String ppath;
for (final SequenceIterator i = qr.iterate(); i.hasNext(); ) {
// for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext();) {
p = (NodeProxy) i.nextItem();
///TODO : use dedicated function in XmldbURI
ppath = p.getDocument().getCollection().getURI().toString() + '/' + p.getDocument().getFileURI();
if (ppath.equals(path))
{hitsByDoc.add(p);}
}
--start;
if (start < 0 || start > hitsByDoc.getLength())
{throw new RemoteException(
"index " + start + "out of bounds (" + hitsByDoc.getLength() + ")");}
if (start + howmany >= hitsByDoc.getLength())
{howmany = hitsByDoc.getLength() - start;}
final 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);