public abstract class AbstractRestrictiveHandler extends Object implements Serializable
Base class for handlers applying only to certain type of documents by providing a way to restrict applicable documents based on a metadata value (matched via regex).
Subclasses implementing IXMLConfigurable
should allow this inner
configuration:
<restrictTo caseSensitive="[false|true]" > property="(name of header/metadata name to match)" (regular expression of value to match) </restrictTo>
Subclasses must test if a document is accepted using the
documentAccepted(String, Properties, boolean)
method.
Subclasses can safely be used as either pre-parse or post-parse handlers.
Constructor and Description |
---|
AbstractRestrictiveHandler() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
documentAccepted(String reference,
Properties metadata,
boolean parsed)
Class to invoke by subclasses to find out if this handler should be
rejected or not based on the metadata restriction provided.
|
boolean |
equals(Object obj) |
int |
hashCode() |
protected void |
loadFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Convenience method for subclasses to load metadata property restrictions.
|
protected void |
saveToXML(XMLStreamWriter writer)
Convenience method for subclasses to save metadata restrictions.
|
void |
setRestriction(String metaProperty,
String regex,
boolean caseSensitive)
Sets what this handler should be restricted to.
|
String |
toString() |
public void setRestriction(String metaProperty, String regex, boolean caseSensitive)
metaProperty
- metadata property/fieldregex
- regular expressioncaseSensitive
- whether regular expression should be case sensitiveprotected boolean documentAccepted(String reference, Properties metadata, boolean parsed) throws IOException
reference
- document referencemetadata
- document metadata.parsed
- if the document was parsed (i.e. imported) alreadytrue
if the document is acceptedIOException
protected void loadFromXML(org.apache.commons.configuration.XMLConfiguration xml)
xml
- xml configurationprotected void saveToXML(XMLStreamWriter writer) throws XMLStreamException
writer
- XML writerXMLStreamException
- problem saving extra content typesCopyright © 2009-2014 Norconex Inc.. All Rights Reserved.