uk.ac.starlink.vo
Class DalResultStreamer

java.lang.Object
  extended by uk.ac.starlink.votable.TableContentHandler
      extended by uk.ac.starlink.vo.DalResultStreamer
All Implemented Interfaces:
ContentHandler, TableHandler

public class DalResultStreamer
extends TableContentHandler
implements TableHandler

SAX table handler for processing VOTable documents returned from DAL services. The result table has to be in a type="results" RESOURCE following DAL rules. The QUERY_STATUS INFO elements are understood, and a table marked with error status causes an exception to be thrown by the SAX parser. A successful parse streams the table data to a supplied sink.

Since:
10 Apr 2013
Author:
Mark Taylor

Constructor Summary
DalResultStreamer(TableSink sink)
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(String namespaceURI, String localName, String qName)
           
 void endTable()
          Called when there are no more rows to be transmitted.
 boolean getOverflow()
          Indicates whether the DAL result was marked as overflowing (with QUERY_STATUS INFO).
 void rowData(Object[] row)
          Called when a row has been read.
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
           
 void startTable(StarTable meta)
          Called when a table is about to be transmitted.
static boolean streamResultTable(InputSource saxsrc, TableSink sink)
          Streams a DAL result table from a SAX source to a table sink.
 
Methods inherited from class uk.ac.starlink.votable.TableContentHandler
endDocument, endPrefixMapping, getLocator, getReadHrefTables, getTableHandler, ignorableWhitespace, processingInstruction, setDocumentLocator, setReadHrefTables, setTableHandler, skippedEntity, startDocument, startPrefixMapping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DalResultStreamer

public DalResultStreamer(TableSink sink)
Constructor.

Parameters:
sink - table destination
Method Detail

getOverflow

public boolean getOverflow()
Indicates whether the DAL result was marked as overflowing (with QUERY_STATUS INFO). Will be set or not set after a successful parse.

Returns:
true iff an overflow marker has been encountered

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class TableContentHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class TableContentHandler
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Specified by:
characters in interface ContentHandler
Overrides:
characters in class TableContentHandler
Throws:
SAXException

startTable

public void startTable(StarTable meta)
                throws SAXException
Description copied from interface: TableHandler
Called when a table is about to be transmitted. This call will occur somewhere between matched DATA element startElement and endElement calls. The metadata argument signals column and table metadata argument about the table whose rows are about to be transmitted. If the number of rows that will be transmitted via subsequent calls to rowData is known, this value should be made available as the row count of metadata (StarTable.getRowCount()); if it is not known, the row count should be -1. However, this object should not attempt to read any of meta's cell data.

The data to be transmitted in subsequent calls of acceptRow must match the metadata transmitted in this call in the same way that rows of a StarTable must match its own metadata (number and content clases of columns etc).

Specified by:
startTable in interface TableHandler
Parameters:
meta - metadata object
Throws:
SAXException

rowData

public void rowData(Object[] row)
             throws SAXException
Description copied from interface: TableHandler
Called when a row has been read. This method will be called between matched startTable and endTable calls.

Specified by:
rowData in interface TableHandler
Parameters:
row - array of data objects representing a row in the current table
Throws:
SAXException

endTable

public void endTable()
              throws SAXException
Description copied from interface: TableHandler
Called when there are no more rows to be transmitted.

Specified by:
endTable in interface TableHandler
Throws:
SAXException

streamResultTable

public static boolean streamResultTable(InputSource saxsrc,
                                        TableSink sink)
                                 throws IOException,
                                        SAXException
Streams a DAL result table from a SAX source to a table sink.

Parameters:
saxsrc - SAX event source
sink - table destination
Returns:
true iff the result was marked as overflowed
Throws:
IOException
SAXException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.