public class CopyTagger extends AbstractDocumentTagger
Copies metadata fields. If a target field already
exists, the values of the original field name will be added, unless
"overwrite" is set to true
.
Can be used both as a pre-parse or post-parse handler.
<tagger class="com.norconex.importer.handler.tagger.impl.CopyTagger"> <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) --> <copy fromField="(from field)" toField="(to field)" overwrite="[false|true]" /> <-- multiple copy tags allowed --> </tagger>
Copies the value of a "creator" and "publisher" fields into an "author" field, adding to any existing values in the "author" field.
<tagger class="com.norconex.importer.handler.tagger.impl.CopyTagger"> <copy fromField="creator" toField="author" overwrite="true" /> <copy fromField="publisher" toField="author" overwrite="true" /> </tagger>
Constructor and Description |
---|
CopyTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addCopyDetails(String fromField,
String toField,
boolean overwrite)
Adds copy instructions.
|
boolean |
equals(Object other) |
int |
hashCode() |
protected void |
loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Loads configuration settings specific to the implementing class.
|
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 addCopyDetails(String fromField, String toField, boolean overwrite)
fromField
- source field nametoField
- target field nameoverwrite
- whether toField overwrite target field if it existsprotected 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.