public class ForceSingleValueTagger extends AbstractDocumentTagger
Forces a metadata field to be single-value. The action can be one of the following:
Can be used both as a pre-parse or post-parse handler.
keepFirst Keeps the first occurrence found. keepLast Keeps the first occurrence found. mergeWith:<sep> Merges all occurrences, joining them with the specified separator (<sep>).
If you do not specify any action, the default behavior is to merge all occurrences, joining values with a comma.
<tagger class="com.norconex.importer.handler.tagger.impl.ForceSingleValueTagger"> <restrictTo caseSensitive="[false|true]" field="(name of header/metadata field name to match)"> (regular expression of value to match) </restrictTo> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <singleValue field="FIELD_NAME" action="[keepFirst|keepLast|mergeWith:<separator>]"/> <!-- multiple single value fields allowed --> </tagger>
For documents where multiple title fields are found, the following only keeps the first title value captured.
<tagger class="com.norconex.importer.handler.tagger.impl.ForceSingleValueTagger"> <singleValue field="title" action="keepFirst"/> </tagger>
Constructor and Description |
---|
ForceSingleValueTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addSingleValueField(String field,
String action) |
boolean |
equals(Object other) |
Map<String,String> |
getSingleValueFields() |
int |
hashCode() |
protected void |
loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Loads configuration settings specific to the implementing class.
|
void |
removeSingleValueField(String name) |
protected void |
saveHandlerToXML(EnhancedXMLStreamWriter writer)
Saves configuration settings specific to the implementing class.
|
void |
tagApplicableDocument(String reference,
InputStream document,
ImporterMetadata metadata,
boolean parsed) |
String |
toString() |
tagDocument
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
public void tagApplicableDocument(String reference, InputStream document, ImporterMetadata metadata, boolean parsed) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public void removeSingleValueField(String name)
protected void loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml) throws IOException
AbstractImporterHandler
loadHandlerFromXML
in class AbstractImporterHandler
xml
- xml configurationIOException
- could not load from XMLprotected void saveHandlerToXML(EnhancedXMLStreamWriter writer) throws XMLStreamException
AbstractImporterHandler
saveHandlerToXML
in class AbstractImporterHandler
writer
- the xml writerXMLStreamException
- could not save to XMLpublic boolean equals(Object other)
equals
in class AbstractImporterHandler
public int hashCode()
hashCode
in class AbstractImporterHandler
public String toString()
toString
in class AbstractImporterHandler
Copyright © 2009–2021 Norconex Inc.. All rights reserved.