public class ConstantTagger extends AbstractDocumentTagger
Define and add constant values to documents. To add multiple constant values under the same constant name, repeat the constant entry with a different value.
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
with setOnSet(PropertySetter)
.
Can be used both as a pre-parse or post-parse handler.
<handler
class="com.norconex.importer.handler.tagger.impl.ConstantTagger"
onSet="[append|prepend|replace|optional]">
<!-- 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 constant tags allowed -->
<constant
name="CONSTANT_NAME">
Constant Value
</constant>
</handler>
<handler
class="ConstantTagger">
<constant
name="source">
web
</constant>
</handler>
The above example adds a constant to incoming documents to identify they were web documents.
Modifier and Type | Class and Description |
---|---|
static class |
ConstantTagger.OnConflict
Deprecated.
|
Constructor and Description |
---|
ConstantTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addConstant(String name,
String value) |
boolean |
equals(Object other) |
Map<String,List<String>> |
getConstants() |
ConstantTagger.OnConflict |
getOnConflict()
Deprecated.
Since 3.0.0, use
getOnSet() instead |
PropertySetter |
getOnSet()
Gets the property setter to use when a value is set.
|
int |
hashCode() |
protected void |
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.
|
void |
removeConstant(String name) |
protected void |
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.
|
void |
setOnConflict(ConstantTagger.OnConflict onConflict)
Deprecated.
Since 3.0.0, use
setOnSet(PropertySetter) instead |
void |
setOnSet(PropertySetter onSet)
Sets the property setter to use when a value is set.
|
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 PropertySetter getOnSet()
public void setOnSet(PropertySetter onSet)
onSet
- property setter@Deprecated public ConstantTagger.OnConflict getOnConflict()
getOnSet()
instead@Deprecated public void setOnConflict(ConstantTagger.OnConflict onConflict)
setOnSet(PropertySetter)
insteadonConflict
- conflict resolution strategy.public void removeConstant(String name)
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.