org.exist.collections.triggers
Class FilteringTrigger

java.lang.Object
  extended by org.exist.collections.triggers.FilteringTrigger
All Implemented Interfaces:
DocumentTrigger, Trigger, ContentHandler, LexicalHandler
Direct Known Subclasses:
Dumper, HistoryTrigger, STXTransformerTrigger, XQueryTrigger

public abstract class FilteringTrigger
extends Object
implements DocumentTrigger

Abstract default implementation of a Trigger. This implementation just forwards all SAX events to the output content handler.

Author:
wolf

Field Summary
 
Fields inherited from interface org.exist.collections.triggers.Trigger
CREATE_COLLECTION_EVENT, DELETE_COLLECTION_EVENT, REMOVE_DOCUMENT_EVENT, RENAME_COLLECTION_EVENT, STORE_DOCUMENT_EVENT, UPDATE_DOCUMENT_EVENT
 
Constructor Summary
FilteringTrigger()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void comment(char[] ch, int start, int length)
           
 void configure(DBBroker broker, Collection parent, Map parameters)
          Configure the trigger.
 void endCDATA()
           
 void endDocument()
           
 void endDTD()
           
 void endElement(String namespaceURI, String localName, String qname)
           
 void endEntity(String arg0)
           
 void endPrefixMapping(String prefix)
           
 void finish(int event, DBBroker broker, Txn transaction, XmldbURI documentPath, DocumentImpl document)
          This method is called after the operation completed.
 Collection getCollection()
           
 ContentHandler getInputHandler()
          Returns the input content handler.
 LexicalHandler getLexicalInputHandler()
          Returns the lexical input handler for this trigger.
 LexicalHandler getLexicalOutputHandler()
          Called by the database to set the lexical output handler for this trigger.
 Logger getLogger()
          Returns a Logger object.
 ContentHandler getOutputHandler()
          Returns the output handler to which SAX events should be forwarded.
 void ignorableWhitespace(char[] ch, int start, int length)
           
 boolean isValidating()
          Returns true if the SAX parser is currently in validation phase.
 void processingInstruction(String target, String data)
           
 void setDocumentLocator(Locator locator)
           
 void setLexicalOutputHandler(LexicalHandler handler)
          Called by the database to set the lexical output content handler for this trigger.
 void setOutputHandler(ContentHandler handler)
          Called by the database to set the output content handler for this trigger.
 void setValidating(boolean validating)
          Called by the database to report that it is entering validation phase.
 void skippedEntity(String arg0)
           
 void startCDATA()
           
 void startDocument()
           
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String namespaceURI, String localName, String qname, Attributes attributes)
           
 void startEntity(String arg0)
           
 void startPrefixMapping(String prefix, String namespaceURI)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.exist.collections.triggers.DocumentTrigger
prepare
 

Constructor Detail

FilteringTrigger

public FilteringTrigger()
Method Detail

configure

public void configure(DBBroker broker,
                      Collection parent,
                      Map parameters)
               throws CollectionConfigurationException
Configure the trigger. The default implementation just stores the parent collection reference into the field collection. Use method getCollection to later retrieve the collection.

Specified by:
configure in interface Trigger
Parameters:
broker - the database instance used to load the collection configuration. The broker object is required for all database actions. Please note: the broker instance used for configuration is probably different from the one passed to the prepare method. Don't store the broker object in your class.
parent - the collection to which this trigger belongs.
parameters - a Map containing any key/value parameters defined in the configuration file.
Throws:
CollectionConfigurationException - if the trigger cannot be initialized.

finish

public void finish(int event,
                   DBBroker broker,
                   Txn transaction,
                   XmldbURI documentPath,
                   DocumentImpl document)
Description copied from interface: DocumentTrigger
This method is called after the operation completed. At this point, the document has already been stored.

Specified by:
finish in interface DocumentTrigger
Parameters:
event - the type of event that triggered this call (see the constants defined in this interface).
broker - the database instance used to process the current action.
transaction - the current transaction context
documentPath - the path of the document, if removed the old path of the document
document - the stored document or null if the document is removed

setValidating

public void setValidating(boolean validating)
Description copied from interface: DocumentTrigger
Called by the database to report that it is entering validation phase.

Specified by:
setValidating in interface DocumentTrigger

isValidating

public boolean isValidating()
Description copied from interface: DocumentTrigger
Returns true if the SAX parser is currently in validation phase. During validation phase, the trigger may safely throw a SAXException. However, if is isValidating returns false, no exceptions should be thrown.

Specified by:
isValidating in interface DocumentTrigger
Returns:
true if the parser is in validation phase.

getCollection

public Collection getCollection()

getInputHandler

public ContentHandler getInputHandler()
Description copied from interface: DocumentTrigger
Returns the input content handler. Usually, this method should just return the trigger object itself, i.e. this. However, the trigger may choose to provide a different content handler.

Specified by:
getInputHandler in interface DocumentTrigger
Returns:
the ContentHandler to be called by the database.

getLexicalInputHandler

public LexicalHandler getLexicalInputHandler()
Description copied from interface: DocumentTrigger
Returns the lexical input handler for this trigger. See getInputHandler.

Specified by:
getLexicalInputHandler in interface DocumentTrigger
Returns:
The LexicalHandler instance for the input.

getOutputHandler

public ContentHandler getOutputHandler()
Description copied from interface: DocumentTrigger
Returns the output handler to which SAX events should be forwarded.

Specified by:
getOutputHandler in interface DocumentTrigger
Returns:
The ContentHandler instance for the output.

getLexicalOutputHandler

public LexicalHandler getLexicalOutputHandler()
Description copied from interface: DocumentTrigger
Called by the database to set the lexical output handler for this trigger.

Specified by:
getLexicalOutputHandler in interface DocumentTrigger
Returns:
The LexicalHandler instance for the output.

setOutputHandler

public void setOutputHandler(ContentHandler handler)
Description copied from interface: DocumentTrigger
Called by the database to set the output content handler for this trigger.

Specified by:
setOutputHandler in interface DocumentTrigger

setLexicalOutputHandler

public void setLexicalOutputHandler(LexicalHandler handler)
Description copied from interface: DocumentTrigger
Called by the database to set the lexical output content handler for this trigger.

Specified by:
setLexicalOutputHandler in interface DocumentTrigger

getLogger

public Logger getLogger()
Description copied from interface: Trigger
Returns a Logger object. Use this to log debugging information.

Specified by:
getLogger in interface Trigger

setDocumentLocator

public void setDocumentLocator(Locator locator)
Specified by:
setDocumentLocator in interface ContentHandler

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String namespaceURI)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Throws:
SAXException

endPrefixMapping

public void endPrefixMapping(String prefix)
                      throws SAXException
Specified by:
endPrefixMapping in interface ContentHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qname,
                         Attributes attributes)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Throws:
SAXException

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qname)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Throws:
SAXException

characters

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

ignorableWhitespace

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

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Specified by:
processingInstruction in interface ContentHandler
Throws:
SAXException

skippedEntity

public void skippedEntity(String arg0)
                   throws SAXException
Specified by:
skippedEntity in interface ContentHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

startEntity

public void startEntity(String arg0)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String arg0)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException


Copyright (C) Wolfgang Meier. All rights reserved.