public class CopyTagger extends AbstractDocumentTagger
Copies metadata fields.
If a target field with the same name already exists for a document,
values will be added to the end of the existing value list.
It is possible to change this default behavior by supplying a
PropertySetter
.
Can be used both as a pre-parse or post-parse handler.
<handler
class="com.norconex.importer.handler.tagger.impl.CopyTagger">
<!-- 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>
<!-- multiple copy tags allowed -->
<copy
toField="(to field)"
onSet="[append|prepend|replace|optional]">
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(one or more matching fields to copy)
</fieldMatcher>
</copy>
</handler>
<handler
class="CopyTagger">
<copy
toField="author"
onSet="append">
<fieldMatcher
method="regex">
(creator|publisher)
</fieldMatcher>
</copy>
</handler>
Copies the value of a "creator" and "publisher" fields into an "author" field, adding to any existing values in the "author" field.
Constructor and Description |
---|
CopyTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addCopyDetails(String fromField,
String toField)
Adds copy instructions, adding to any existing values on the target
field.
|
void |
addCopyDetails(String fromField,
String toField,
boolean overwrite)
Deprecated.
Since 3.0.0, use
addCopyDetails(TextMatcher, String, PropertySetter) . |
void |
addCopyDetails(TextMatcher fieldMatcher,
String toField,
PropertySetter onSet)
Adds copy instructions.
|
boolean |
equals(Object other) |
int |
hashCode() |
protected void |
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.
|
void |
tagApplicableDocument(HandlerDoc doc,
InputStream document,
ParseState parseState) |
String |
toString() |
tagDocument
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
public void tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public void addCopyDetails(String fromField, String toField)
fromField
- source field nametoField
- target field namepublic void addCopyDetails(TextMatcher fieldMatcher, String toField, PropertySetter onSet)
fieldMatcher
- source field(s)toField
- target field nameonSet
- strategy to use when a value is copied over an existing one@Deprecated public void addCopyDetails(String fromField, String toField, boolean overwrite)
addCopyDetails(TextMatcher, String, PropertySetter)
.fromField
- source field nametoField
- target field nameoverwrite
- whether toField overwrite target field if it existsprotected void loadHandlerFromXML(XML xml)
AbstractImporterHandler
loadHandlerFromXML
in class AbstractImporterHandler
xml
- XML configurationprotected void saveHandlerToXML(XML xml)
AbstractImporterHandler
saveHandlerToXML
in class AbstractImporterHandler
xml
- the 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–2023 Norconex Inc.. All rights reserved.