edu.ucsb.nceas.morpho.query
Class ResultSet

edu.ucsb.nceas.morpho.query.ResultSet
Direct Known Subclasses:
HeadResultSet

public class ResultSet
implements ColumnSortableTableModel

A ResultSet encapsulates the list of results returned from either a local query or a Metacat query. It contains a reference to its original query, so the result set can be refreshed by re-running the query. Current MetaCat query returns a element for each 'hit' in query. That element has 5 fixed children: , , , , and . Other child elements are determined by query and are returned as elements with a "name" attribute and the value as the content.


Field Summary
static javax.swing.ImageIcon blankIcon
          the icon for blank, nothing there
protected static int CREATEDATEINDEX
          Store the index of createdate in resultsVector
protected static int DOCIDINDEX
          Store the index of docid in resultsVector
protected static int DOCNAMEINDEX
          Store the index of doc name in resultsVector
protected static int DOCTYPEINDEX
          Store the index of doc type in resultsVector
protected static int ISLOCALINDEX
          Store the index of islocal in resultsVector
protected static int ISMETACATINDEX
          Store the index of ismetacat in resultsVector
protected static int KEYWORDSINDEX
          Store the index of keywords in resultsVector
static javax.swing.ImageIcon localIcon
          The icon for representing local storage.
static javax.swing.ImageIcon metacatIcon
          The icon for representing metacat storage.
static javax.swing.ImageIcon packageDataIcon
          The icon for representing pakcage and data file
static javax.swing.ImageIcon packageIcon
          The icon for representing package
protected static int PACKAGEICONINDEX
          Store the index of package icon in resultsVector
protected  java.util.Vector resultsVector
          Store each row of the result set as a row in a Vector
protected static int SURNAMEINDEX
          Store the index of surname in resultsVector
protected static int TITLEINDEX
          Store the index of titl in resultsVector
protected static int TRIPLEINDEX
          Store the index of triple in resultsVector
protected static int UPDATEDATEINDEX
          Store the index of update in resultsVector
 
Constructor Summary
ResultSet(Query query, java.lang.String source, java.io.InputStream resultsXMLStream, Morpho morpho)
          Construct a ResultSet instance given a query object and a InputStream that represents an XML encoding of the results.
ResultSet(Query query, java.lang.String source, java.util.Vector vec, Morpho morpho)
          Construct a ResultSet instance from a vector of vectors; for use with LocalQuery
 
Method Summary
 void characters(char[] ch, int start, int length)
          SAX handler callback that is called for character content of an element when parsing an XML document.
 void endDocument()
          Unused SAX handler
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          SAX handler callback that is called upon the end of an element when parsing an XML document.
 void endPrefixMapping(java.lang.String prefix)
          Unused SAX handler
 java.lang.Class getColumnClass(int c)
          Return the Class for each column so that they can be rendered correctly.
 int getColumnCount()
          Return the number of columns in this result set
 java.lang.String getColumnName(int col)
          Determine the name of a column by its index
 Morpho getFramework()
          Get a reference to the Morpho application framework
 Query getQuery()
          Get the query that was used to construct these results
 java.util.Vector getResultsVector()
          get the resultsVector
 int getRowCount()
          Return the number of records in this result set
 int getRowHeight()
          Return the correct row height for table rows
 java.lang.Object getValueAt(int row, int col)
          Determine the value of a column by its row and column index
 void ignorableWhitespace(char[] cbuf, int start, int len)
          Unused SAX handler
protected  int lookupResultsVectorIndex(int headerIndex)
          Lookup an array to find resultsVector index for header index header index resultVector index 0 PACKAGEICONEX(0) 1 TITLEINDEX(1) 2 DOCIDINDEX(6) 3 SURNAMEINDEX(2) 4 KEYWORKDINDEX(3) 5 UPDATEDATEINDEX(5) 6 ISLOCALINDEX(9) 7 ISMETACATINDEX(10)
 void merge(ResultSet r2)
          Merge a ResultSet onto this one using the docid as the join column
 void openResultRecord(int row)
          Open a given row index of the result set using a delegated handler class
protected  void openResultRecord(java.util.Vector rowVector)
          Open a given row of the result set using a delegated handler class
 void processingInstruction(java.lang.String target, java.lang.String data)
          Unused SAX handler
 void setDocumentLocator(org.xml.sax.Locator locator)
          Unused SAX handler
 void setQuery(Query query)
          Set the query that was used to construct these results (for use by LocalQuery)
 void setResultsVector(java.util.Vector rv)
          set the resultsVector
 void skippedEntity(java.lang.String name)
          Unused SAX handler
 void sortTableByColumn(int col, java.lang.String order)
          Method implements from SortTableModel.
 void startDocument()
          SAX handler callback that is called when an XML document is initially parsed.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          SAX handler callback that is called upon the start of an element when parsing an XML document.
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          Unused SAX handler
 

Field Detail

resultsVector

protected java.util.Vector resultsVector
Store each row of the result set as a row in a Vector

localIcon

public static javax.swing.ImageIcon localIcon
The icon for representing local storage.

metacatIcon

public static javax.swing.ImageIcon metacatIcon
The icon for representing metacat storage.

blankIcon

public static javax.swing.ImageIcon blankIcon
the icon for blank, nothing there

packageIcon

public static javax.swing.ImageIcon packageIcon
The icon for representing package

packageDataIcon

public static javax.swing.ImageIcon packageDataIcon
The icon for representing pakcage and data file

PACKAGEICONINDEX

protected static final int PACKAGEICONINDEX
Store the index of package icon in resultsVector

TITLEINDEX

protected static final int TITLEINDEX
Store the index of titl in resultsVector

SURNAMEINDEX

protected static final int SURNAMEINDEX
Store the index of surname in resultsVector

KEYWORDSINDEX

protected static final int KEYWORDSINDEX
Store the index of keywords in resultsVector

CREATEDATEINDEX

protected static final int CREATEDATEINDEX
Store the index of createdate in resultsVector

UPDATEDATEINDEX

protected static final int UPDATEDATEINDEX
Store the index of update in resultsVector

DOCIDINDEX

protected static final int DOCIDINDEX
Store the index of docid in resultsVector

DOCNAMEINDEX

protected static final int DOCNAMEINDEX
Store the index of doc name in resultsVector

DOCTYPEINDEX

protected static final int DOCTYPEINDEX
Store the index of doc type in resultsVector

ISLOCALINDEX

protected static final int ISLOCALINDEX
Store the index of islocal in resultsVector

ISMETACATINDEX

protected static final int ISMETACATINDEX
Store the index of ismetacat in resultsVector

TRIPLEINDEX

protected static final int TRIPLEINDEX
Store the index of triple in resultsVector
Constructor Detail

ResultSet

public ResultSet(Query query,
                 java.lang.String source,
                 java.util.Vector vec,
                 Morpho morpho)
Construct a ResultSet instance from a vector of vectors; for use with LocalQuery

ResultSet

public ResultSet(Query query,
                 java.lang.String source,
                 java.io.InputStream resultsXMLStream,
                 Morpho morpho)
Construct a ResultSet instance given a query object and a InputStream that represents an XML encoding of the results.
Method Detail

getResultsVector

public java.util.Vector getResultsVector()
get the resultsVector

setResultsVector

public void setResultsVector(java.util.Vector rv)
set the resultsVector

getColumnCount

public int getColumnCount()
Return the number of columns in this result set

getRowCount

public int getRowCount()
Return the number of records in this result set

getRowHeight

public int getRowHeight()
Return the correct row height for table rows

getColumnName

public java.lang.String getColumnName(int col)
Determine the name of a column by its index

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Determine the value of a column by its row and column index

lookupResultsVectorIndex

protected int lookupResultsVectorIndex(int headerIndex)
Lookup an array to find resultsVector index for header index header index resultVector index 0 PACKAGEICONEX(0) 1 TITLEINDEX(1) 2 DOCIDINDEX(6) 3 SURNAMEINDEX(2) 4 KEYWORKDINDEX(3) 5 UPDATEDATEINDEX(5) 6 ISLOCALINDEX(9) 7 ISMETACATINDEX(10)

getColumnClass

public java.lang.Class getColumnClass(int c)
Return the Class for each column so that they can be rendered correctly.

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
SAX handler callback that is called upon the start of an element when parsing an XML document.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
SAX handler callback that is called upon the end of an element when parsing an XML document.

characters

public void characters(char[] ch,
                       int start,
                       int length)
SAX handler callback that is called for character content of an element when parsing an XML document.

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
SAX handler callback that is called when an XML document is initially parsed.

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Unused SAX handler

ignorableWhitespace

public void ignorableWhitespace(char[] cbuf,
                                int start,
                                int len)
Unused SAX handler

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Unused SAX handler

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Unused SAX handler

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Unused SAX handler

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Unused SAX handler

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator locator)
Unused SAX handler

getQuery

public Query getQuery()
Get the query that was used to construct these results

setQuery

public void setQuery(Query query)
Set the query that was used to construct these results (for use by LocalQuery)

openResultRecord

public void openResultRecord(int row)
Open a given row index of the result set using a delegated handler class

openResultRecord

protected void openResultRecord(java.util.Vector rowVector)
Open a given row of the result set using a delegated handler class

merge

public void merge(ResultSet r2)
Merge a ResultSet onto this one using the docid as the join column

getFramework

public Morpho getFramework()
Get a reference to the Morpho application framework

sortTableByColumn

public void sortTableByColumn(int col,
                              java.lang.String order)
Method implements from SortTableModel. To make sure a col can be sort or not. We decide it always be sortable.
Specified by:
sortTableByColumn in interface ColumnSortableTableModel
Parameters:
col, - the index of column which need to be sorted
order, - the sort order


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.