Class CharacterCaseTagger

  • All Implemented Interfaces:
    IXMLConfigurable, IImporterHandler, IDocumentTagger

    public class CharacterCaseTagger
    extends AbstractDocumentTagger

    Changes the character case of matching fields and values according to one of the following methods:

    • upper: Changes all characters to upper case.
    • lower: Changes all characters values to lower case.
    • words: Converts the first letter of each words to upper case, and leaves the character case of other characters unchanged.
    • wordsFully: Converts the first letter of each words to upper case, and the rest to lower case.
    • sentences: Converts the first letter of each sentence to upper case, and leaves the character case of other characters unchanged.
    • sentencesFully: Converts the first letter of each sentence to upper case, and converts other characters to lower case.
    • string: Converts the first letter of a string to upper case, and leaves the character case of other characters unchanged.
    • stringFully: Converts the first letter of a string to upper case, and converts other characters to lower case.
    • swap: Converts all upper case characters to lower case, and all lower case to upper case.

    The change of character case can be applied to one of the following (defaults to "value" when unspecified):

    • value: Applies to the field values.
    • field: Applies to the field name.
    • both: Applies to both the field name and its values.

    Field names are referenced in a case insensitive manner.

    XML configuration usage:

    
    <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>(field-matching expression)</fieldMatcher>
        <valueMatcher>(value-matching expression)</valueMatcher>
      </restrictTo>
      <fieldMatcher>(expression to narrow by matching fields)</fieldMatcher>
    </handler>

    XML usage example:

    
    <!-- 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.

    Since:
    2.0.0
    Author:
    Pascal Essiembre