Class DeleteTagger
- java.lang.Object
-
- com.norconex.importer.handler.AbstractImporterHandler
-
- com.norconex.importer.handler.tagger.AbstractDocumentTagger
-
- com.norconex.importer.handler.tagger.impl.DeleteTagger
-
- All Implemented Interfaces:
IXMLConfigurable
,IImporterHandler
,IDocumentTagger
public class DeleteTagger extends AbstractDocumentTagger
Delete the metadata fields provided. Exact field names (case-insensitive) to delete can be provided as well as a regular expression that matches one or many fields.
Can be used both as a pre-parse or post-parse handler.
XML configuration usage:
<handler class="com.norconex.importer.handler.tagger.impl.DeleteTagger"> <!-- multiple "restrictTo" tags allowed (only one needs to match) --> <restrictTo> <fieldMatcher>(field-matching expression)</fieldMatcher> <valueMatcher>(value-matching expression)</valueMatcher> </restrictTo> <fieldMatcher>(one or more matching fields to delete)</fieldMatcher> </handler>
XML usage example:
<handler class="DeleteTagger"> <fieldMatcher method="regex"> ^[Xx]-.* </fieldMatcher> </handler>
The above deletes all metadata fields starting with "X-".
- Author:
- Pascal Essiembre
-
-
Constructor Summary
Constructors Constructor Description DeleteTagger()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addField(String field)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
boolean
equals(Object other)
TextMatcher
getFieldMatcher()
Gets field matcher for fields to delete.List<String>
getFields()
Deprecated.Since 3.0.0, usegetFieldMatcher()
String
getFieldsRegex()
Deprecated.Since 3.0.0, usegetFieldMatcher()
int
hashCode()
protected void
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.void
removeField(String field)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
protected void
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.void
setFieldMatcher(TextMatcher fieldMatcher)
Sets the field matcher for fields to delete.void
setFields(List<String> fieldsToRemove)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
void
setFieldsRegex(String fieldsRegex)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
void
tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState)
String
toString()
-
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:
tagApplicableDocument
in classAbstractDocumentTagger
- Throws:
ImporterHandlerException
-
getFieldMatcher
public TextMatcher getFieldMatcher()
Gets field matcher for fields to delete.- Returns:
- field matcher
- Since:
- 3.0.0
-
setFieldMatcher
public void setFieldMatcher(TextMatcher fieldMatcher)
Sets the field matcher for fields to delete.- Parameters:
fieldMatcher
- field matcher- Since:
- 3.0.0
-
getFields
@Deprecated public List<String> getFields()
Deprecated.Since 3.0.0, usegetFieldMatcher()
Gets the pattern for fields to delete as first element.- Returns:
- fields to delete
-
addField
@Deprecated public void addField(String field)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
Adds the pattern for fields to delete.- Parameters:
field
- fields to add
-
removeField
@Deprecated public void removeField(String field)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
Does nothing.- Parameters:
field
- field to remove
-
setFields
@Deprecated public void setFields(List<String> fieldsToRemove)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
Sets the fields to delete. Will convert to regex expression.- Parameters:
fieldsToRemove
- fields to delete
-
getFieldsRegex
@Deprecated public String getFieldsRegex()
Deprecated.Since 3.0.0, usegetFieldMatcher()
Gets field matcher pattern.- Returns:
- field matcher pattern
-
setFieldsRegex
@Deprecated public void setFieldsRegex(String fieldsRegex)
Deprecated.Since 3.0.0, usesetFieldMatcher(TextMatcher)
Sets field matcher pattern.- Parameters:
fieldsRegex
- field matcher pattern.
-
loadHandlerFromXML
protected void loadHandlerFromXML(XML xml)
Description copied from class:AbstractImporterHandler
Loads configuration settings specific to the implementing class.- Specified by:
loadHandlerFromXML
in classAbstractImporterHandler
- Parameters:
xml
- XML configuration
-
saveHandlerToXML
protected void saveHandlerToXML(XML xml)
Description copied from class:AbstractImporterHandler
Saves configuration settings specific to the implementing class.- Specified by:
saveHandlerToXML
in classAbstractImporterHandler
- Parameters:
xml
- the XML
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classAbstractImporterHandler
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractImporterHandler
-
toString
public String toString()
- Overrides:
toString
in classAbstractImporterHandler
-
-