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 field with the same name already exists for a document, the constant value(s) will be added to the list of already existing values.
Since 2.7.0, it is possible to change this default behavior
with setOnConflict(OnConflict)
. Possible values are:
Can be used both as a pre-parse or post-parse handler.
<tagger class="com.norconex.importer.handler.tagger.impl.ConstantTagger" onConflict="[add|replace|noop]" > <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) --> <constant name="CONSTANT_NAME">Constant Value</constant> <!-- multiple constant tags allowed --> </tagger>
Adds a constant to incoming documents to identify they were web documents.
<tagger class="com.norconex.importer.handler.tagger.impl.ConstantTagger"> <constant name="source">web</constant> </tagger>
Modifier and Type | Class and Description |
---|---|
static class |
ConstantTagger.OnConflict |
Modifier and Type | Field and Description |
---|---|
static ConstantTagger.OnConflict |
DEFAULT_ON_CONFLICT |
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()
Gets the conflict resolution strategy.
|
int |
hashCode() |
protected void |
loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Loads configuration settings specific to the implementing class.
|
void |
removeConstant(String name) |
protected void |
saveHandlerToXML(EnhancedXMLStreamWriter writer)
Saves configuration settings specific to the implementing class.
|
void |
setOnConflict(ConstantTagger.OnConflict onConflict)
Sets the conflict resolution strategy.
|
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 static final ConstantTagger.OnConflict DEFAULT_ON_CONFLICT
public void tagApplicableDocument(String reference, InputStream document, ImporterMetadata metadata, boolean parsed) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public ConstantTagger.OnConflict getOnConflict()
public void setOnConflict(ConstantTagger.OnConflict onConflict)
onConflict
- conflict resolution strategy.public void removeConstant(String name)
protected void loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
AbstractImporterHandler
loadHandlerFromXML
in class AbstractImporterHandler
xml
- xml configurationprotected 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.