edu.ucsb.nceas.metacat
Class QuerySpecification

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--edu.ucsb.nceas.metacat.QuerySpecification
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class QuerySpecification
extends org.xml.sax.helpers.DefaultHandler

A Class that represents a structured query, and can be constructed from an XML serialization conforming to @see pathquery.dtd. The printSQL() method can be used to print a SQL serialization of the query.


Constructor Summary
QuerySpecification(java.io.Reader queryspec, java.lang.String parserName, java.lang.String accNumberSeparator)
          construct an instance of the QuerySpecification class
QuerySpecification(java.lang.String queryspec, java.lang.String parserName, java.lang.String accNumberSeparator)
          construct an instance of the QuerySpecification class
 
Method Summary
 void characters(char[] ch, int start, int length)
          callback method used by the SAX Parser when the text sequences of an xml stream are detected.
 boolean containsExtendedSQL()
          Returns true if the parsed query contains and extended xml query (i.e.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          callback method used by the SAX Parser when the end tag of an element is detected.
 java.util.Vector getReturnFieldList()
          Accessor method to return a vector of the extended return fields as defined in the <returnfield> tag in the pathquery dtd.
static void main(java.lang.String[] args)
          Main routine for testing
 java.lang.String printExtendedSQL(java.lang.String doclist)
          This method prints sql based upon the <returnfield> tag in the pathquery document.
static java.lang.String printGetDocByDoctypeSQL(java.lang.String docid)
           
static java.lang.String printPackageSQL()
          Prints sql that returns all relations in the database.
static java.lang.String printPackageSQL(java.lang.String docid)
          Prints sql that returns all relations in the database that were input under a specific docid
static java.lang.String printPackageSQL(java.lang.String subDocidURL, java.lang.String objDocidURL)
          Returns all of the relations that has a certain docid in the subject or the object.
static java.lang.String printRelationSQL(java.lang.String docid)
           
 java.lang.String printSQL()
          create a SQL serialization of the query that this instance represents
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          callback method used by the SAX Parser when the start tag of an element is detected.
 java.lang.String toString()
          create a String description of the query that this instance represents.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QuerySpecification

public QuerySpecification(java.io.Reader queryspec,
                          java.lang.String parserName,
                          java.lang.String accNumberSeparator)
                   throws java.io.IOException
construct an instance of the QuerySpecification class
Parameters:
queryspec - the XML representation of the query (should conform to pathquery.dtd) as a Reader
parserName - the fully qualified name of a Java Class implementing the org.xml.sax.XMLReader interface

QuerySpecification

public QuerySpecification(java.lang.String queryspec,
                          java.lang.String parserName,
                          java.lang.String accNumberSeparator)
                   throws java.io.IOException
construct an instance of the QuerySpecification class
Parameters:
queryspec - the XML representation of the query (should conform to pathquery.dtd) as a String
parserName - the fully qualified name of a Java Class implementing the org.xml.sax.Parser interface
Method Detail

main

public static void main(java.lang.String[] args)
Main routine for testing

containsExtendedSQL

public boolean containsExtendedSQL()
Returns true if the parsed query contains and extended xml query (i.e. there is at least one <returnfield> in the pathquery document)

getReturnFieldList

public java.util.Vector getReturnFieldList()
Accessor method to return a vector of the extended return fields as defined in the <returnfield> tag in the pathquery dtd.

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
callback method used by the SAX Parser when the start tag of an element is detected. Used in this context to parse and store the query information in class variables.
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
callback method used by the SAX Parser when the end tag of an element is detected. Used in this context to parse and store the query information in class variables.
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
callback method used by the SAX Parser when the text sequences of an xml stream are detected. Used in this context to parse and store the query information in class variables.
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

printSQL

public java.lang.String printSQL()
create a SQL serialization of the query that this instance represents

printExtendedSQL

public java.lang.String printExtendedSQL(java.lang.String doclist)
This method prints sql based upon the <returnfield> tag in the pathquery document. This allows for customization of the returned fields
Parameters:
doclist - the list of document ids to search by

printRelationSQL

public static java.lang.String printRelationSQL(java.lang.String docid)

printPackageSQL

public static java.lang.String printPackageSQL()
Prints sql that returns all relations in the database.

printPackageSQL

public static java.lang.String printPackageSQL(java.lang.String docid)
Prints sql that returns all relations in the database that were input under a specific docid
Parameters:
docid - the docid to search for.

printPackageSQL

public static java.lang.String printPackageSQL(java.lang.String subDocidURL,
                                               java.lang.String objDocidURL)
Returns all of the relations that has a certain docid in the subject or the object.
Parameters:
docid - the docid to search for

printGetDocByDoctypeSQL

public static java.lang.String printGetDocByDoctypeSQL(java.lang.String docid)

toString

public java.lang.String toString()
create a String description of the query that this instance represents. This should become a way to get the XML serialization of the query.
Overrides:
toString in class java.lang.Object


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