public abstract class AbstractImporterHandler extends Object implements IXMLConfigurable
myHandler.setRestriction(new PropertyMatcher("document.contentType", new TextMatcher(Method.REGEX).setPattern("^text/.*$")));
Subclasses must test if a document is accepted using the
isApplicable(HandlerDoc, ParseState)
method.
Subclasses can safely be used as either pre-parse or post-parse handlers.
<!-- multiple "restrictTo" tags allowed (only one needs to match) -->
<restrictTo>
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(field-matching expression)
</fieldMatcher>
<valueMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(value-matching expression)
</valueMatcher>
</restrictTo>
Subclasses inherit the above IXMLConfigurable
configuration.
<restrictTo>
<fieldMatcher>document.contentType</fieldMatcher>
<valueMatcher
method="wildcard">
text/*
</valueMatcher>
</restrictTo>
The above will apply to any content type starting with "text/".
Constructor and Description |
---|
AbstractImporterHandler() |
Modifier and Type | Method and Description |
---|---|
void |
addRestriction(PropertyMatcher... restrictions)
Adds one or more restrictions this handler should be restricted to.
|
void |
addRestriction(String field,
String regex,
boolean caseSensitive)
Deprecated.
Since 3.0.0, use
addRestriction(PropertyMatcher...) . |
void |
addRestrictions(List<PropertyMatcher> restrictions)
Adds restrictions this handler should be restricted to.
|
void |
clearRestrictions()
Clears all restrictions.
|
protected String |
detectCharsetIfBlank(HandlerDoc doc,
InputStream is,
String charset,
ParseState parseState)
Deprecated.
Since 3.0.0, charset was already detected or use
CharsetUtil.firstNonBlankOrUTF8(ParseState, String...) |
boolean |
equals(Object other) |
PropertyMatchers |
getRestrictions()
Gets all restrictions
|
int |
hashCode() |
protected boolean |
isApplicable(HandlerDoc doc,
ParseState parseState)
Class to invoke by subclasses to find out if this handler should be
rejected or not based on the metadata restriction provided.
|
void |
loadFromXML(XML xml) |
protected abstract void |
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.
|
boolean |
removeRestriction(PropertyMatcher restriction)
Removes a restriction.
|
int |
removeRestriction(String field)
Removes all restrictions on a given field.
|
protected abstract void |
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.
|
void |
saveToXML(XML xml) |
String |
toString() |
@Deprecated public void addRestriction(String field, String regex, boolean caseSensitive)
addRestriction(PropertyMatcher...)
.field
- metadata property/fieldregex
- regular expressioncaseSensitive
- whether regular expression should be case sensitivepublic void addRestriction(PropertyMatcher... restrictions)
restrictions
- the restrictionspublic void addRestrictions(List<PropertyMatcher> restrictions)
restrictions
- the restrictionspublic int removeRestriction(String field)
field
- the field to remove restrictions onpublic boolean removeRestriction(PropertyMatcher restriction)
restriction
- the restriction to removetrue
if this handler contained the restrictionpublic void clearRestrictions()
public PropertyMatchers getRestrictions()
protected final boolean isApplicable(HandlerDoc doc, ParseState parseState)
doc
- documentparseState
- if the document was parsed (i.e. imported) alreadytrue
if this handler is applicable to the document@Deprecated protected final String detectCharsetIfBlank(HandlerDoc doc, InputStream is, String charset, ParseState parseState)
CharsetUtil.firstNonBlankOrUTF8(ParseState, String...)
doc
- the document to detect charset onis
- the document input streamcharset
- the character encoding to test if blankparseState
- whether the document has already been parsed or not.public final void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
protected abstract void loadHandlerFromXML(XML xml)
xml
- XML configurationpublic void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
protected abstract void saveHandlerToXML(XML xml)
xml
- the XMLCopyright © 2009–2023 Norconex Inc.. All rights reserved.