public class RenameTagger extends AbstractDocumentTagger
Rename metadata fields to different names.
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
.
When using regular expressions, "toField" can also hold replacement patterns (e.g. $1, $2, etc).
Can be used both as a pre-parse or post-parse handler.
<handler
class="com.norconex.importer.handler.tagger.impl.RenameTagger">
<!-- 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 rename tags allowed -->
<rename
toField="(to field)"
onSet="[append|prepend|replace|optional]">
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
replaceAll="[false|true]"
partial="[false|true]">
(one or more matching fields to rename)
</fieldMatcher>
</rename>
</handler>
<handler
class="RenameTagger">
<rename
toField="title"
onSet="replace">
<fieldMatcher>dc.title</fieldMatcher>
</rename>
</handler>
The above example renames a "dc.title" field to "title", overwriting any existing values in "title".
Modifier and Type | Class and Description |
---|---|
static class |
RenameTagger.RenameDetails |
Constructor and Description |
---|
RenameTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addRename(String fromField,
String toField,
boolean overwrite)
Deprecated.
|
void |
addRename(String fromField,
String toField,
boolean overwrite,
boolean regex)
Deprecated.
|
void |
addRename(TextMatcher fieldMatcher,
String toField,
PropertySetter onSet) |
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 addRename(TextMatcher fieldMatcher, String toField, PropertySetter onSet)
@Deprecated public void addRename(String fromField, String toField, boolean overwrite)
@Deprecated public void addRename(String fromField, String toField, boolean overwrite, boolean regex)
protected 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.