de.pangaea.metadataportal.utils
Class SaxRule

java.lang.Object
  extended by org.apache.commons.digester.Rule
      extended by de.pangaea.metadataportal.utils.SaxRule
Direct Known Subclasses:
OAIMetadataSaxRule

public class SaxRule
extends org.apache.commons.digester.Rule

This class is used as a rule for included documents during Digester parsing. Whenever this element matches in Digester, begin/end will be called, that then puts all further SAX events to the specified SAX ContentHandler.

Author:
Uwe Schindler

Field Summary
protected  ContentHandler destContentHandler
           
protected  Set<String> excludeNamespaces
           
 
Fields inherited from class org.apache.commons.digester.Rule
digester, namespaceURI
 
Constructor Summary
SaxRule()
          Default constructor
 
Method Summary
 void begin(String namespace, String name, Attributes attributes)
           
static SaxRule emptyRule()
          Creates an empty "useless" SaxRule.
 void end(String namespace, String name)
           
protected  void finishDocument()
          Closes the tags created in initDocument().
 ContentHandler getContentHandler()
          return the current ContentHandler.
protected  void initDocument()
          Add some tags when document started.
 void setContentHandler(ContentHandler ch)
          Sets the SAX ContentHandler that gets all SAX Events after the startElement event.
 void setDigester(org.apache.commons.digester.Digester digester)
          Set the Digester with which this Rule is associated.
 void setExcludeNamespaces(Set<String> excludeNamespaces)
          Sets a Set<String> containing all Namespace URIs that should not be feed to the target ContentHandler on match.
 
Methods inherited from class org.apache.commons.digester.Rule
begin, body, body, end, finish, getDigester, getNamespaceURI, setNamespaceURI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

destContentHandler

protected ContentHandler destContentHandler
See Also:
setContentHandler(org.xml.sax.ContentHandler)

excludeNamespaces

protected Set<String> excludeNamespaces
See Also:
setExcludeNamespaces(java.util.Set)
Constructor Detail

SaxRule

public SaxRule()
Default constructor

Method Detail

emptyRule

public static SaxRule emptyRule()
Creates an empty "useless" SaxRule. The pupose is to not throw an exception on known but ignored tags (optional with contents).

Returns:
an instance that does nothing by feeding all SAX events to an SAX DefaultHandler

setDigester

public void setDigester(org.apache.commons.digester.Digester digester)
Set the Digester with which this Rule is associated.

Overrides:
setDigester in class org.apache.commons.digester.Rule
Throws:
IllegalArgumentException - if digester is not an ExtendedDigester instance.

setContentHandler

public void setContentHandler(ContentHandler ch)
Sets the SAX ContentHandler that gets all SAX Events after the startElement event.


getContentHandler

public ContentHandler getContentHandler()
return the current ContentHandler.


setExcludeNamespaces

public void setExcludeNamespaces(Set<String> excludeNamespaces)
Sets a Set<String> containing all Namespace URIs that should not be feed to the target ContentHandler on match. Default (or setting to null) means no restriction: All namespace prefixes visible in the current context will be reported.


initDocument

protected void initDocument()
                     throws SAXException
Add some tags when document started. The default implementation does nothing. This method should be overwritten to feed some additional tags after the startDocument SAX event.

Throws:
SAXException

finishDocument

protected void finishDocument()
                       throws SAXException
Closes the tags created in initDocument(). The default implementation does nothing. This method should be overwritten to feed some ending tags before the endDocument SAX event.

Throws:
SAXException

begin

public void begin(String namespace,
                  String name,
                  Attributes attributes)
           throws Exception
Overrides:
begin in class org.apache.commons.digester.Rule
Throws:
Exception

end

public void end(String namespace,
                String name)
         throws Exception
Overrides:
end in class org.apache.commons.digester.Rule
Throws:
Exception


Copyright ©2007-2011 panFMP Developers c/o Uwe Schindler