public byte[] retrieve( int resultId, int num, java.lang.String encoding, boolean prettyPrint ) throws java.rmi.RemoteException { Sessions sessions = Sessions.getInstance(); DBBroker broker = null; try { broker = pool.get(); Value qr = (Value) sessions.getQueryResult( resultId ); if ( qr == null ) throw new RemoteException( "result set unknown or timed out" ); String xml = null; switch ( qr.getType() ) { case Value.isNodeList: NodeList resultSet = qr.getNodeList(); --num; if ( num < 0 && num >= resultSet.getLength() ) throw new RuntimeException( "index " + num + " out of bounds (" + resultSet.getLength() + ")" ); NodeProxy proxy = ( (NodeSet) resultSet ).get( num ); if ( proxy == null ) throw new RuntimeException( "not found: " + num ); LOG.debug( "loaded node " + proxy.gid ); Serializer serializer = broker.getSerializer(); Map properties = new TreeMap(); properties.put(Serializer.ENCODING, encoding); properties.put(Serializer.PRETTY_PRINT, Boolean.toString(prettyPrint)); serializer.setProperties( properties ); xml = serializer.serialize( proxy ); break; default: ValueSet valueSet = qr.getValueSet(); Value val = valueSet.get( num ); xml = val.getStringValue(); } return xml.getBytes( encoding ); } catch ( Exception e ) { LOG.warn( e ); e.printStackTrace(); throw new RemoteException( e.getMessage(), e ); } finally { pool.release( broker ); } }
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(); Value qr = (Value) session.getQueryResult().result; if (qr == null) throw new RemoteException("result set unknown or timed out"); String xml[] = null; switch (qr.getType()) { case Value.isNodeList : NodeList resultSet = qr.getNodeList(); --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(); Map properties = new TreeMap(); properties.put(Serializer.ENCODING, "UTF-8"); properties.put(Serializer.PRETTY_PRINT, Boolean.toString(indent)); properties.put(Serializer.EXPAND_XINCLUDES, Boolean.toString(xinclude)); properties.put(Serializer.HIGHLIGHT_MATCHES, highlight); serializer.setProperties(properties);  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 : ValueSet valueSet = qr.getValueSet(); --start; if (start < 0 || start >= valueSet.getLength()) throw new RemoteException("index " + start + " out of bounds"); if (start + howmany >= valueSet.getLength()) howmany = valueSet.getLength() - start; xml = new String[howmany]; for (int i = 0; i < howmany; i++) { Value val = valueSet.get(start); xml[i] = val.getStringValue(); } } return xml; } catch (Exception e) { LOG.warn(e); e.printStackTrace(); throw new RemoteException(e.getMessage(), e); } finally { pool.release(broker); } }
    public byte[] retrieve( int resultId, int num, java.lang.String encoding,                            boolean prettyPrint )         throws java.rmi.RemoteException {        Sessions sessions = Sessions.getInstance();        DBBroker broker = null;        try {            broker = pool.get();            Value qr = (Value) sessions.getQueryResult( resultId );            if ( qr == null )                throw new RemoteException( "result set unknown or timed out" );            String xml = null;            switch ( qr.getType() ) {                case Value.isNodeList:                    NodeList resultSet = qr.getNodeList();                    --num;                    if ( num < 0 && num >= resultSet.getLength() )                        throw new RuntimeException( "index " + num +                            " out of bounds (" +                            resultSet.getLength() +                            ")" );                    NodeProxy proxy = ( (NodeSet) resultSet ).get( num );                    if ( proxy == null )                        throw new RuntimeException( "not found: " + num );                    LOG.debug( "loaded node " + proxy.gid );                    Serializer serializer = broker.getSerializer();                    Map properties = new TreeMap();                    properties.put(Serializer.ENCODING, encoding);                    properties.put(Serializer.PRETTY_PRINT, Boolean.toString(prettyPrint));                    serializer.setProperties( properties );                    xml = serializer.serialize( proxy );                    break;                default:                    ValueSet valueSet = qr.getValueSet();                    Value val = valueSet.get( num );                    xml = val.getStringValue();            }            return xml.getBytes( encoding );        } catch ( Exception e ) {            LOG.warn( e );            e.printStackTrace();            throw new RemoteException( e.getMessage(), e );        } finally {            pool.release( broker );        }    }