edu.ucsb.nceas.metacat
Class DBSAXHandler

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--edu.ucsb.nceas.metacat.DBSAXHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.ext.DeclHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.ext.LexicalHandler, java.lang.Runnable
Direct Known Subclasses:
EmlSAXHandler

public class DBSAXHandler
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ext.LexicalHandler, org.xml.sax.ext.DeclHandler, java.lang.Runnable

A database aware Class implementing callback bethods for the SAX parser to call when processing the XML stream and generating events


Field Summary
protected  java.lang.String action
           
protected  boolean atFirstElement
           
protected  DBConnection connection
           
protected  DocumentImpl currentDocument
           
protected  java.lang.String docid
           
protected  java.lang.String docname
           
protected  java.lang.String doctype
           
protected  long endNodeId
           
protected  java.lang.String[] groups
           
protected  boolean hitTextNode
           
protected static long INDEXDELAY
           
protected static int MAXDATACHARS
           
protected  java.util.Hashtable namespaces
           
protected  java.util.Vector nodeIndex
           
protected  java.util.Stack nodeStack
           
protected  boolean processingDTD
           
protected  java.lang.String pub
           
protected  java.lang.String revision
           
protected  DBSAXNode rootNode
           
protected  int serverCode
           
protected  java.lang.String systemid
           
protected  java.lang.StringBuffer textBuffer
           
protected  java.util.Stack textBufferStack
           
protected  java.lang.String user
           
protected  java.lang.Thread xmlIndex
           
 
Constructor Summary
DBSAXHandler(DBConnection conn)
          Construct an instance of the handler class
DBSAXHandler(DBConnection conn, java.lang.String action, java.lang.String docid, java.lang.String user, java.lang.String[] groups, java.lang.String pub, int serverCode)
          Construct an instance of the handler class
DBSAXHandler(DBConnection conn, java.lang.String action, java.lang.String docid, java.lang.String revision, java.lang.String user, java.lang.String[] groups, java.lang.String pub, int serverCode)
          Construct an instance of the handler class In this constructor, user can specify the version need to upadate
 
Method Summary
 void attributeDecl(java.lang.String eName, java.lang.String aName, java.lang.String type, java.lang.String valueDefault, java.lang.String value)
          SAX Handler that receives notification of attribute declarations
 void characters(char[] cbuf, int start, int len)
          SAX Handler that is called for each XML text node
 void comment(char[] ch, int start, int length)
          SAX Handler that receives notification of comments in the DTD
 void elementDecl(java.lang.String name, java.lang.String model)
          SAX Handler that receives notification of element declarations
 void endCDATA()
          SAX Handler that receives notification of the end of CDATA sections
 void endDocument()
          SAX Handler that receives notification of end of the document
 void endDTD()
          SAX Handler that receives notification of end of DTD
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          SAX Handler that is called at the end of each XML element
 void endEntity(java.lang.String name)
          SAX Handler that receives notification of the end of entities
 void error(org.xml.sax.SAXParseException exception)
          SAX Handler that receives notification of recoverable parsing errors
 void externalEntityDecl(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          SAX Handler that receives notification of external entity declarations
 void fatalError(org.xml.sax.SAXParseException exception)
          SAX Handler that receives notification of fatal parsing errors
 java.lang.String getDocname()
          get the document name
 void ignorableWhitespace(char[] cbuf, int start, int len)
          SAX Handler that is called for each XML text node that is Ignorable white space
 void internalEntityDecl(java.lang.String name, java.lang.String value)
          SAX Handler that receives notification of internal entity declarations
 boolean processingDTD()
          get the document processing state
 void processingInstruction(java.lang.String target, java.lang.String data)
          SAX Handler called once for each processing instruction found: node that PI may occur before or after the root element.
 void run()
           
 void startCDATA()
          SAX Handler that receives notification of the start of CDATA sections
 void startDocument()
          SAX Handler that receives notification of beginning of the document
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          SAX Handler that receives notification of DOCTYPE.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
          SAX Handler that is called at the start of each XML element
 void startEntity(java.lang.String name)
          SAX Handler that receives notification of the start of entities
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
          SAX Handler that is called at the start of Namespace
 void warning(org.xml.sax.SAXParseException exception)
          SAX Handler that receives notification of warnings
protected  long writeTextForDBSAXNode(long previousEndNodeId, java.lang.StringBuffer strBuffer, DBSAXNode node)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

atFirstElement

protected boolean atFirstElement

processingDTD

protected boolean processingDTD

docname

protected java.lang.String docname

doctype

protected java.lang.String doctype

systemid

protected java.lang.String systemid

nodeStack

protected java.util.Stack nodeStack

nodeIndex

protected java.util.Vector nodeIndex

connection

protected DBConnection connection

currentDocument

protected DocumentImpl currentDocument

rootNode

protected DBSAXNode rootNode

action

protected java.lang.String action

docid

protected java.lang.String docid

revision

protected java.lang.String revision

user

protected java.lang.String user

groups

protected java.lang.String[] groups

pub

protected java.lang.String pub

xmlIndex

protected java.lang.Thread xmlIndex

serverCode

protected int serverCode

namespaces

protected java.util.Hashtable namespaces

hitTextNode

protected boolean hitTextNode

textBuffer

protected java.lang.StringBuffer textBuffer

textBufferStack

protected java.util.Stack textBufferStack

MAXDATACHARS

protected static final int MAXDATACHARS
See Also:
Constant Field Values

INDEXDELAY

protected static final long INDEXDELAY
See Also:
Constant Field Values

endNodeId

protected long endNodeId
Constructor Detail

DBSAXHandler

public DBSAXHandler(DBConnection conn)
Construct an instance of the handler class

Parameters:
conn - the JDBC connection to which information is written

DBSAXHandler

public DBSAXHandler(DBConnection conn,
                    java.lang.String action,
                    java.lang.String docid,
                    java.lang.String user,
                    java.lang.String[] groups,
                    java.lang.String pub,
                    int serverCode)
Construct an instance of the handler class

Parameters:
conn - the JDBC connection to which information is written
action - - "INSERT" or "UPDATE"
docid - to be inserted or updated into JDBC connection
user - the user connected to MetaCat servlet and owns the document
groups - the groups to which user belongs
pub - flag for public "read" access on document
serverCode - the serverid from xml_replication on which this document resides.

DBSAXHandler

public DBSAXHandler(DBConnection conn,
                    java.lang.String action,
                    java.lang.String docid,
                    java.lang.String revision,
                    java.lang.String user,
                    java.lang.String[] groups,
                    java.lang.String pub,
                    int serverCode)
Construct an instance of the handler class In this constructor, user can specify the version need to upadate

Parameters:
conn - the JDBC connection to which information is written
action - - "INSERT" or "UPDATE"
docid - to be inserted or updated into JDBC connection
user - the user connected to MetaCat servlet and owns the document
groups - the groups to which user belongs
pub - flag for public "read" access on document
serverCode - the serverid from xml_replication on which this document resides.
Method Detail

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
SAX Handler that receives notification of beginning of the document

Specified by:
startDocument in interface org.xml.sax.ContentHandler
Overrides:
startDocument in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
SAX Handler that receives notification of end of the document

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
SAX Handler that is called at the start of Namespace

Specified by:
startPrefixMapping in interface org.xml.sax.ContentHandler
Overrides:
startPrefixMapping in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

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 that is called at the start of each XML element

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

run

public void run()
Specified by:
run in interface java.lang.Runnable

characters

public void characters(char[] cbuf,
                       int start,
                       int len)
                throws org.xml.sax.SAXException
SAX Handler that is called for each XML text node

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] cbuf,
                                int start,
                                int len)
                         throws org.xml.sax.SAXException
SAX Handler that is called for each XML text node that is Ignorable white space

Specified by:
ignorableWhitespace in interface org.xml.sax.ContentHandler
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
SAX Handler called once for each processing instruction found: node that PI may occur before or after the root element.

Specified by:
processingInstruction in interface org.xml.sax.ContentHandler
Overrides:
processingInstruction in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
SAX Handler that is called at the end of each XML element

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
              throws org.xml.sax.SAXException
SAX Handler that receives notification of DOCTYPE. Sets the DTD

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

endDTD

public void endDTD()
            throws org.xml.sax.SAXException
SAX Handler that receives notification of end of DTD

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws org.xml.sax.SAXException
SAX Handler that receives notification of comments in the DTD

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

startCDATA

public void startCDATA()
                throws org.xml.sax.SAXException
SAX Handler that receives notification of the start of CDATA sections

Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

endCDATA

public void endCDATA()
              throws org.xml.sax.SAXException
SAX Handler that receives notification of the end of CDATA sections

Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

startEntity

public void startEntity(java.lang.String name)
                 throws org.xml.sax.SAXException
SAX Handler that receives notification of the start of entities

Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

endEntity

public void endEntity(java.lang.String name)
               throws org.xml.sax.SAXException
SAX Handler that receives notification of the end of entities

Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler
org.xml.sax.SAXException

elementDecl

public void elementDecl(java.lang.String name,
                        java.lang.String model)
                 throws org.xml.sax.SAXException
SAX Handler that receives notification of element declarations

Specified by:
elementDecl in interface org.xml.sax.ext.DeclHandler
org.xml.sax.SAXException

attributeDecl

public void attributeDecl(java.lang.String eName,
                          java.lang.String aName,
                          java.lang.String type,
                          java.lang.String valueDefault,
                          java.lang.String value)
                   throws org.xml.sax.SAXException
SAX Handler that receives notification of attribute declarations

Specified by:
attributeDecl in interface org.xml.sax.ext.DeclHandler
org.xml.sax.SAXException

internalEntityDecl

public void internalEntityDecl(java.lang.String name,
                               java.lang.String value)
                        throws org.xml.sax.SAXException
SAX Handler that receives notification of internal entity declarations

Specified by:
internalEntityDecl in interface org.xml.sax.ext.DeclHandler
org.xml.sax.SAXException

externalEntityDecl

public void externalEntityDecl(java.lang.String name,
                               java.lang.String publicId,
                               java.lang.String systemId)
                        throws org.xml.sax.SAXException
SAX Handler that receives notification of external entity declarations

Specified by:
externalEntityDecl in interface org.xml.sax.ext.DeclHandler
org.xml.sax.SAXException

fatalError

public void fatalError(org.xml.sax.SAXParseException exception)
                throws org.xml.sax.SAXException
SAX Handler that receives notification of fatal parsing errors

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

error

public void error(org.xml.sax.SAXParseException exception)
           throws org.xml.sax.SAXException
SAX Handler that receives notification of recoverable parsing errors

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

warning

public void warning(org.xml.sax.SAXParseException exception)
             throws org.xml.sax.SAXException
SAX Handler that receives notification of warnings

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

getDocname

public java.lang.String getDocname()
get the document name


processingDTD

public boolean processingDTD()
get the document processing state


writeTextForDBSAXNode

protected long writeTextForDBSAXNode(long previousEndNodeId,
                                     java.lang.StringBuffer strBuffer,
                                     DBSAXNode node)
                              throws org.xml.sax.SAXException
org.xml.sax.SAXException


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