public class BlankCondition extends Object implements IImporterCondition, IXMLConfigurable
A condition based on whether the document content (default) or
any of the specified metadata fields are blank or inexistent.
For metadata fields,
control characters (char <= 32) are removed before evaluating whether
their values are empty. Dealing with the document content will
rather check if it is null
or empty (no bytes returned
when read).
By default, ALL values for all fields matched by your field matcher
expression must be blank for this condition to be true
.
You can change the logic to have ANY values to be blank for the condition
to be true
with setMatchAnyBlank(boolean)
.
If no fields are matched, the conditions is also considered empty
(true
).
<condition
class="com.norconex.importer.handler.condition.impl.BlankCondition"
matchAnyBlank="[false|true]">
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(Optional expression matching fields we want to test if blank,
instead of using the document content.)
</fieldMatcher>
</handler>
<condition
class="BlankCondition">
<fieldMatcher
method="regex">
(title|dc:title)
</fieldMatcher>
</condition>
The above example condition will return true
if both
"title" or "dc:title" are blank.
Constructor and Description |
---|
BlankCondition() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
TextMatcher |
getFieldMatcher() |
int |
hashCode() |
boolean |
isMatchAnyBlank() |
void |
loadFromXML(XML xml) |
void |
saveToXML(XML xml) |
void |
setFieldMatcher(TextMatcher fieldMatcher) |
void |
setMatchAnyBlank(boolean matchAnyBlank) |
boolean |
testDocument(HandlerDoc doc,
InputStream input,
ParseState parseState)
Tests a given document.
|
String |
toString() |
public TextMatcher getFieldMatcher()
public void setFieldMatcher(TextMatcher fieldMatcher)
public boolean isMatchAnyBlank()
public void setMatchAnyBlank(boolean matchAnyBlank)
public boolean testDocument(HandlerDoc doc, InputStream input, ParseState parseState) throws ImporterHandlerException
IImporterCondition
testDocument
in interface IImporterCondition
doc
- the document to testinput
- document contentparseState
- whether the document has been parsed already or not (a
parsed document should normally be text-based)true
if the condition evaluates as suchImporterHandlerException
- problem reading the documentpublic void loadFromXML(XML xml)
loadFromXML
in interface IXMLConfigurable
public void saveToXML(XML xml)
saveToXML
in interface IXMLConfigurable
Copyright © 2009–2023 Norconex Inc.. All rights reserved.