public ResourceIterator getIterator(long start) throws XMLDBException {
return new NewResourceIterator(start);
}
public Resource getMembersAsResource() throws XMLDBException {
final SAXSerializer handler = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class);
final StringWriter writer = new StringWriter();
handler.setOutput(writer, outputProperties);
DBBroker broker = null;
try {
broker = brokerPool.get(user);
// configure the serializer
final Serializer serializer = broker.getSerializer();
serializer.reset();
collection.properties.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");
serializer.setProperties(outputProperties);
serializer.setUser(user);
serializer.setSAXHandlers(handler, handler);
// serialize results
handler.startDocument();
handler.startPrefixMapping("exist", Namespaces.EXIST_NS);
final AttributesImpl attribs = new AttributesImpl();
attribs.addAttribute(
"",
"hitCount",
"hitCount",
"CDATA",
Integer.toString(resources.size()));
handler.startElement(
Namespaces.EXIST_NS,
"result",
"exist:result",
attribs);
Item current;
char[] value;
for(final Iterator<Object> i = resources.iterator(); i.hasNext(); ) {
current = (Item)i.next();
if(Type.subTypeOf(current.getType(), Type.NODE)) {
((NodeValue)current).toSAX(broker, handler, outputProperties);
} else {
value = current.toString().toCharArray();
handler.characters(value, 0, value.length);
}
}
handler.endElement(Namespaces.EXIST_NS, "result", "exist:result");
handler.endPrefixMapping("exist");
handler.endDocument();
} catch (final EXistException e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, "serialization error", e);
} catch (final SAXException e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, "serialization error", e);
} finally {