com.hp.hpl.jena.rdf.query
Class QueryResultsFormatter

java.lang.Object
  |
  +--com.hp.hpl.jena.rdf.query.QueryResultsFormatter

public class QueryResultsFormatter
extends java.lang.Object

Takes a QueryResult object and returns formatted (in various ways) Useful for the scripting interface. May help for display in other contexts.

Note: this is compute intensive and memory intensive. It needs to read all the results first (all the results are now in-memory - not kept here) in order to find things like the maximum length of a column value; then it needs to pass over the results again, turning them into Strings again, in order to return them.

We prefer slow and less memory intensive because it is more rebust for scripting.

Don't keep QueryResultsFormatter's around unnecessarily!


Constructor Summary
QueryResultsFormatter(QueryResults qresults)
          Create a formatter for a QueryResults object
 
Method Summary
 void close()
          Forcefully clearup.
 void consume()
          This operation faithfully walks the results but does nothing with them.
 void dump(java.io.PrintWriter pw, boolean format)
          Write out a compact form.
 int numColumns()
          How wide is the result table
 int numRows()
          How deep is the result table.
 void printAll(java.io.PrintWriter pw, java.lang.String colSep)
          Textual representation
 void printAll(java.io.PrintWriter pw, java.lang.String colSep, java.lang.String lineEnd)
           
 void printHTML(java.io.PrintWriter pw)
          HTML representation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryResultsFormatter

public QueryResultsFormatter(QueryResults qresults)
Create a formatter for a QueryResults object
Method Detail

numColumns

public int numColumns()
How wide is the result table

numRows

public int numRows()
How deep is the result table. Negative implies unknown

close

public void close()
Forcefully clearup. As results might have been read into memory, this operation signals intermediate data is no longer needed.

dump

public void dump(java.io.PrintWriter pw,
                 boolean format)
Write out a compact form. This encodes all the information is a vaguely readable way but is suitable for reading in again. Used for testing.

printAll

public void printAll(java.io.PrintWriter pw,
                     java.lang.String colSep)
Textual representation

printAll

public void printAll(java.io.PrintWriter pw,
                     java.lang.String colSep,
                     java.lang.String lineEnd)

printHTML

public void printHTML(java.io.PrintWriter pw)
HTML representation

consume

public void consume()
This operation faithfully walks the results but does nothing with them. Used in timing operations. Becareful that a compiler does not optimize some or all of it away!


Copyright © 2001 Hewlett-Packard. All Rights Reserved.