Class ConstantTagger
- java.lang.Object
-
- com.norconex.importer.handler.AbstractImporterHandler
-
- com.norconex.importer.handler.tagger.AbstractDocumentTagger
-
- com.norconex.importer.handler.tagger.impl.ConstantTagger
-
- All Implemented Interfaces:
IXMLConfigurable,IImporterHandler,IDocumentTagger
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.
Storing values in an existing field
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.
XML configuration usage:
<handler class="com.norconex.importer.handler.tagger.impl.ConstantTagger"> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <restrictTo> <fieldMatcher>(field-matching expression)</fieldMatcher> <valueMatcher>(value-matching expression)</valueMatcher> </restrictTo> <!-- multiple constant tags allowed --> <constant name="CONSTANT_NAME"> Constant Value </constant> </handler>XML usage example:
<handler class="ConstantTagger"> <constant name="source"> web </constant> </handler>The above example adds a constant to incoming documents to identify they were web documents.
- Author:
- Pascal Essiembre
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstantTagger.OnConflictDeprecated.
-
Constructor Summary
Constructors Constructor Description ConstantTagger()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConstant(String name, String value)booleanequals(Object other)Map<String,List<String>>getConstants()ConstantTagger.OnConflictgetOnConflict()Deprecated.Since 3.0.0, usegetOnSet()insteadPropertySettergetOnSet()Gets the property setter to use when a value is set.inthashCode()protected voidloadHandlerFromXML(XML xml)Loads configuration settings specific to the implementing class.voidremoveConstant(String name)protected voidsaveHandlerToXML(XML xml)Saves configuration settings specific to the implementing class.voidsetOnConflict(ConstantTagger.OnConflict onConflict)Deprecated.Since 3.0.0, usesetOnSet(PropertySetter)insteadvoidsetOnSet(PropertySetter onSet)Sets the property setter to use when a value is set.voidtagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState)StringtoString()-
Methods inherited from class com.norconex.importer.handler.tagger.AbstractDocumentTagger
tagDocument
-
Methods inherited from class com.norconex.importer.handler.AbstractImporterHandler
addRestriction, addRestriction, addRestrictions, clearRestrictions, detectCharsetIfBlank, getRestrictions, isApplicable, loadFromXML, removeRestriction, removeRestriction, saveToXML
-
-
-
-
Method Detail
-
tagApplicableDocument
public void tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState) throws ImporterHandlerException
- Specified by:
tagApplicableDocumentin classAbstractDocumentTagger- Throws:
ImporterHandlerException
-
getOnSet
public PropertySetter getOnSet()
Gets the property setter to use when a value is set.- Returns:
- property setter
- Since:
- 3.0.0
-
setOnSet
public void setOnSet(PropertySetter onSet)
Sets the property setter to use when a value is set.- Parameters:
onSet- property setter- Since:
- 3.0.0
-
getOnConflict
@Deprecated public ConstantTagger.OnConflict getOnConflict()
Deprecated.Since 3.0.0, usegetOnSet()insteadGets the conflict resolution strategy.- Returns:
- conflict resolution strategy
- Since:
- 2.7.0
-
setOnConflict
@Deprecated public void setOnConflict(ConstantTagger.OnConflict onConflict)
Deprecated.Since 3.0.0, usesetOnSet(PropertySetter)insteadSets the conflict resolution strategy.- Parameters:
onConflict- conflict resolution strategy.- Since:
- 2.7.0
-
removeConstant
public void removeConstant(String name)
-
loadHandlerFromXML
protected void loadHandlerFromXML(XML xml)
Description copied from class:AbstractImporterHandlerLoads configuration settings specific to the implementing class.- Specified by:
loadHandlerFromXMLin classAbstractImporterHandler- Parameters:
xml- XML configuration
-
saveHandlerToXML
protected void saveHandlerToXML(XML xml)
Description copied from class:AbstractImporterHandlerSaves configuration settings specific to the implementing class.- Specified by:
saveHandlerToXMLin classAbstractImporterHandler- Parameters:
xml- the XML
-
equals
public boolean equals(Object other)
- Overrides:
equalsin classAbstractImporterHandler
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractImporterHandler
-
toString
public String toString()
- Overrides:
toStringin classAbstractImporterHandler
-
-