public class CharacterCaseTagger extends AbstractDocumentTagger
Changes the character case of matching fields and values according to one of the following methods:
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.
<handler
class="com.norconex.importer.handler.tagger.impl.CharacterCaseTagger"
type="[upper|lower|words|wordsFully|sentences|sentencesFully|string|stringFully|swap]"
applyTo="[value|field|both]">
<!-- 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>
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(expression to narrow by matching fields)
</fieldMatcher>
</handler>
<!-- Converts title to lowercase -->
<handler
class="CharacterCaseTagger"
type="lower"
applyTo="field">
<fieldMatcher>title</fieldMatcher>
</handler>
<!-- Make first title character uppercase -->
<handler
class="CharacterCaseTagger"
type="string"
applyTo="value">
<fieldMatcher>title</fieldMatcher>
</handler>
The above examples first convert a title to lower case except for the first character.
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_SENTENCES |
static String |
CASE_SENTENCES_FULLY |
static String |
CASE_STRING |
static String |
CASE_STRING_FULLY |
static String |
CASE_SWAP |
static String |
CASE_UPPER |
static String |
CASE_WORDS |
static String |
CASE_WORDS_FULLY |
Constructor and Description |
---|
CharacterCaseTagger() |
Modifier and Type | Method and Description |
---|---|
void |
addFieldCase(String field,
String caseType)
Deprecated.
Since 3.0.0, use
setFieldMatcher(TextMatcher) ,
setCaseType(String) . |
void |
addFieldCase(String field,
String caseType,
String applyTo)
Deprecated.
Since 3.0.0, use
setFieldMatcher(TextMatcher) ,
setCaseType(String) , and setApplyTo(String) . |
boolean |
equals(Object other) |
String |
getApplyTo()
Gets whether to apply the case transformation to fields, values,
or both.
|
String |
getApplyTo(String fieldName)
Deprecated.
Since 3.0.0 use
getApplyTo() |
String |
getCaseType()
Gets the type of character case transformation.
|
String |
getCaseType(String fieldName)
Deprecated.
Since 3.0.0 use
getCaseType() |
TextMatcher |
getFieldMatcher()
Gets field matcher.
|
Set<String> |
getFieldNames()
Deprecated.
Since 3.0.0 use
getFieldMatcher() |
int |
hashCode() |
protected void |
loadHandlerFromXML(XML xml)
Loads configuration settings specific to the implementing class.
|
protected void |
saveHandlerToXML(XML xml)
Saves configuration settings specific to the implementing class.
|
void |
setApplyTo(String applyTo)
Sets whether to apply the case transformation to fields, values,
or both.
|
void |
setCaseType(String caseType)
Sets the type of character case transformation.
|
void |
setFieldMatcher(TextMatcher fieldMatcher)
Sets field matcher.
|
void |
tagApplicableDocument(HandlerDoc doc,
InputStream document,
ParseState parseState) |
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_WORDS_FULLY
public static final String CASE_UPPER
public static final String CASE_LOWER
public static final String CASE_SWAP
public static final String CASE_SENTENCES
public static final String CASE_SENTENCES_FULLY
public static final String CASE_STRING
public static final String CASE_STRING_FULLY
public static final String APPLY_VALUE
public static final String APPLY_FIELD
public static final String APPLY_BOTH
public TextMatcher getFieldMatcher()
public void setFieldMatcher(TextMatcher fieldMatcher)
fieldMatcher
- field matcherpublic String getCaseType()
public void setCaseType(String caseType)
caseType
- type of case transformationpublic String getApplyTo()
public void setApplyTo(String applyTo)
applyTo
- one of "field", "value", or "both"public void tagApplicableDocument(HandlerDoc doc, InputStream document, ParseState parseState) throws ImporterHandlerException
tagApplicableDocument
in class AbstractDocumentTagger
ImporterHandlerException
@Deprecated public void addFieldCase(String field, String caseType)
setFieldMatcher(TextMatcher)
,
setCaseType(String)
.field
- the field to apply the case changingcaseType
- the type of case change to apply@Deprecated public void addFieldCase(String field, String caseType, String applyTo)
setFieldMatcher(TextMatcher)
,
setCaseType(String)
, and setApplyTo(String)
.field
- the field to apply the case changingcaseType
- the type of case change to applyapplyTo
- what to apply the case change to@Deprecated public Set<String> getFieldNames()
getFieldMatcher()
@Deprecated public String getCaseType(String fieldName)
getCaseType()
fieldName
- field name@Deprecated public String getApplyTo(String fieldName)
getApplyTo()
fieldName
- the field nameprotected 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.