Package de.pangaea.metadataportal.utils
Class SaxRule
- java.lang.Object
-
- org.apache.commons.digester.Rule
-
- de.pangaea.metadataportal.utils.SaxRule
-
- Direct Known Subclasses:
OAIMetadataSaxRule
public class SaxRule extends org.apache.commons.digester.RuleThis class is used as a rule for included documents duringDigesterparsing. Whenever this element matches inDigester,begin/endwill be called, that then puts all further SAX events to the specified SAXContentHandler.- Author:
- Uwe Schindler
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHandlerdestContentHandlerprotected Set<String>excludeNamespaces
-
Constructor Summary
Constructors Constructor Description SaxRule()Default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin(String namespace, String name, Attributes attributes)static SaxRuleemptyRule()Creates an empty "useless" SaxRule.voidend(String namespace, String name)protected voidfinishDocument()Closes the elements created ininitDocument().ContentHandlergetContentHandler()return the currentContentHandler.protected voidinitDocument()Add some elements when document started.voidsetContentHandler(ContentHandler ch)Sets the SAXContentHandlerthat gets all SAX Events after thestartElementevent.voidsetDigester(org.apache.commons.digester.Digester digester)Set theDigesterwith which thisRuleis associated.voidsetExcludeNamespaces(Set<String> excludeNamespaces)Sets aSet<String>containing all Namespace URIs that should not be feed to the targetContentHandleron match.
-
-
-
Field Detail
-
destContentHandler
protected ContentHandler destContentHandler
-
-
Method Detail
-
emptyRule
public static SaxRule emptyRule()
Creates an empty "useless" SaxRule. The pupose is to not throw an exception on known but ignored elements (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 theDigesterwith which thisRuleis associated.- Overrides:
setDigesterin classorg.apache.commons.digester.Rule- Throws:
IllegalArgumentException- ifdigesteris not anExtendedDigesterinstance.
-
setContentHandler
public void setContentHandler(ContentHandler ch)
Sets the SAXContentHandlerthat gets all SAX Events after thestartElementevent.
-
getContentHandler
public ContentHandler getContentHandler()
return the currentContentHandler.
-
setExcludeNamespaces
public void setExcludeNamespaces(Set<String> excludeNamespaces)
Sets aSet<String>containing all Namespace URIs that should not be feed to the targetContentHandleron match. Default (or setting tonull) means no restriction: All namespace prefixes visible in the current context will be reported.
-
initDocument
protected void initDocument() throws SAXExceptionAdd some elements when document started. The default implementation does nothing. This method should be overwritten to feed some additional elements after thestartDocumentSAX event.- Throws:
SAXException
-
finishDocument
protected void finishDocument() throws SAXExceptionCloses the elements created ininitDocument(). The default implementation does nothing. This method should be overwritten to feed some ending elements before theendDocumentSAX event.- Throws:
SAXException
-
begin
public void begin(String namespace, String name, Attributes attributes) throws Exception
- Overrides:
beginin classorg.apache.commons.digester.Rule- Throws:
Exception
-
-