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.Rule
This class is used as a rule for included documents duringDigester
parsing. Whenever this element matches inDigester
,begin
/end
will 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 ContentHandler
destContentHandler
protected 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 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 elements created ininitDocument()
.ContentHandler
getContentHandler()
return the currentContentHandler
.protected void
initDocument()
Add some elements when document started.void
setContentHandler(ContentHandler ch)
Sets the SAXContentHandler
that gets all SAX Events after thestartElement
event.void
setDigester(org.apache.commons.digester.Digester digester)
Set theDigester
with which thisRule
is associated.void
setExcludeNamespaces(Set<String> excludeNamespaces)
Sets aSet<String>
containing all Namespace URIs that should not be feed to the targetContentHandler
on 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 theDigester
with which thisRule
is associated.- Overrides:
setDigester
in classorg.apache.commons.digester.Rule
- Throws:
IllegalArgumentException
- ifdigester
is not anExtendedDigester
instance.
-
setContentHandler
public void setContentHandler(ContentHandler ch)
Sets the SAXContentHandler
that gets all SAX Events after thestartElement
event.
-
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 targetContentHandler
on match. Default (or setting tonull
) means no restriction: All namespace prefixes visible in the current context will be reported.
-
initDocument
protected void initDocument() throws SAXException
Add some elements when document started. The default implementation does nothing. This method should be overwritten to feed some additional elements after thestartDocument
SAX event.- Throws:
SAXException
-
finishDocument
protected void finishDocument() throws SAXException
Closes the elements created ininitDocument()
. The default implementation does nothing. This method should be overwritten to feed some ending elements before theendDocument
SAX event.- Throws:
SAXException
-
begin
public void begin(String namespace, String name, Attributes attributes) throws Exception
- Overrides:
begin
in classorg.apache.commons.digester.Rule
- Throws:
Exception
-
-