public class CharacterCaseTagger extends AbstractDocumentTagger
Changes the character case of field values according to one of the following methods:
Since 2.3.0, the change of character case can be applied to one of the following (defaults to "value" when unspecified):
Field names are referenced in a case insensitive manner.
<tagger class="com.norconex.importer.handler.tagger.impl.CharacterCaseTagger"> <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) --> <characterCase fieldName="(field to change)" type="[upper|lower|words|string|swap]" applyTo="[value|field|both]" /> <!-- multiple characterCase tags allowed --> </tagger>
Documents can use different character case for their title field names. This example makes them all lower case. We also make sure the value starts with an upper case.
<tagger class="com.norconex.importer.handler.tagger.impl.CharacterCaseTagger"> <characterCase fieldName="title" type="lower" applyTo="field" /> <characterCase fieldName="title" type="string" applyTo="value" /> </tagger>
Modifier and Type | Field and Description |
---|---|
static String |
APPLY_BOTH |
static String |
APPLY_FIELD |
static String |
APPLY_VALUE |
static String |
CASE_LOWER |
static String |
CASE_STRING |
static String |
CASE_SWAP |
static String |
CASE_UPPER |
static String |
CASE_WORDS |
Constructor and Description |
---|
CharacterCaseTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addFieldCase(String field,
String caseType) |
void |
addFieldCase(String field,
String caseType,
String applyTo)
Adds field case changing instructions.
|
boolean |
equals(Object other) |
String |
getApplyTo(String fieldName)
Gets what the case changing instructions apply to.
|
String |
getCaseType(String fieldName) |
Set<String> |
getFieldNames() |
int |
hashCode() |
protected void |
loadHandlerFromXML(org.apache.commons.configuration.XMLConfiguration xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveHandlerToXML(EnhancedXMLStreamWriter writer)
Saves configuration settings specific to the implementing class.
|
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 String CASE_WORDS
public static final String CASE_UPPER
public static final String CASE_LOWER
public static final String CASE_SWAP
public static final String CASE_STRING
public static final String APPLY_VALUE
public static final String APPLY_FIELD
public static final String APPLY_BOTH
public void tagApplicableDocument(String reference, InputStream document, ImporterMetadata metadata, boolean parsed) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
public void addFieldCase(String field, String caseType, String applyTo)
field
- the field to apply the case changingcaseType
- the type of case change to applyapplyTo
- what to apply the case change topublic String getApplyTo(String fieldName)
fieldName
- the field nameprotected 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.