edu.ucsb.nceas.morpho.query
Class ResultSet

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byedu.ucsb.nceas.morpho.query.ResultSet
All Implemented Interfaces:
ColumnSortableTableModel, java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
HeadResultSet

public class ResultSet
extends javax.swing.table.AbstractTableModel
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.

See Also:
Serialized Form

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
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
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
 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
 Morpho getMorpho()
          Get the morpho attribute
 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
 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)
 int lookupResultsVectorIndex(java.lang.String headName)
           
 void merge(ResultSet r2)
          Merge a ResultSet onto this one using the docid as the join column
 void merge(java.util.Vector r2Rows)
          Merge a vector 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 setHeader(java.lang.String[] anotherHeader)
          This method will change the clonum name of model
 void setMapping(java.util.Hashtable hash)
          This method will set a mapping table
 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 sortTableByColumn(int col, java.lang.String order)
          Method implements from SortTableModel.
protected  void sortVector(java.util.Vector vector, int col, java.lang.String order)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, isCellEditable, removeTableModelListener, setValueAt
 

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

See Also:
Constant Field Values

TITLEINDEX

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

See Also:
Constant Field Values

SURNAMEINDEX

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

See Also:
Constant Field Values

KEYWORDSINDEX

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

See Also:
Constant Field Values

CREATEDATEINDEX

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

See Also:
Constant Field Values

UPDATEDATEINDEX

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

See Also:
Constant Field Values

DOCIDINDEX

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

See Also:
Constant Field Values

DOCNAMEINDEX

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

See Also:
Constant Field Values

DOCTYPEINDEX

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

See Also:
Constant Field Values

ISLOCALINDEX

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

See Also:
Constant Field Values

ISMETACATINDEX

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

See Also:
Constant Field Values

TRIPLEINDEX

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

See Also:
Constant Field Values
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

Specified by:
getColumnCount in interface javax.swing.table.TableModel

getRowCount

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

Specified by:
getRowCount in interface javax.swing.table.TableModel

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

Specified by:
getColumnName in interface javax.swing.table.TableModel

getValueAt

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

Specified by:
getValueAt in interface javax.swing.table.TableModel

getMorpho

public Morpho getMorpho()
Get the morpho attribute

Returns:
Morpho

setHeader

public void setHeader(java.lang.String[] anotherHeader)
This method will change the clonum name of model

Parameters:
anotherHeader - String[]

setMapping

public void setMapping(java.util.Hashtable hash)
This method will set a mapping table

Parameters:
hash - Hashtable

lookupResultsVectorIndex

public 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)


lookupResultsVectorIndex

public int lookupResultsVectorIndex(java.lang.String headName)

getColumnClass

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

Specified by:
getColumnClass in interface javax.swing.table.TableModel

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


merge

public void merge(java.util.Vector r2Rows)
Merge a vector 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

sortVector

protected void sortVector(java.util.Vector vector,
                          int col,
                          java.lang.String order)


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