Package org.apache.torque.generator.processor.string

## Class ConstantNameCreator

- java.lang.Object
- - org.apache.torque.generator.processor.string.CharReplacer
  - - org.apache.torque.generator.processor.string.ConstantNameCreator

- All Implemented Interfaces:
    `StringProcessor`

      public class ConstantNameCreator
      extends CharReplacer

  Creates the name of a constant from a string. All letters in the String are capitalized, and underscores (_) are used as separators per default. If the string is empty or starts with a number, an underscore(_) is prefixed to the constant name.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `UPPER_CASE_SEPPARATION_PREFIX` | The String which is usually used as prefix in front of upper case characters in java constants.

    - ### Fields inherited from class org.apache.torque.generator.processor.string.CharReplacer

      `JAVA_CLASSNAME_REPLACEMENT, JAVA_CLASSNAME_SPECIAL_CHARS`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ConstantNameCreator()` | Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `String` | `getUpperCaseSeparationPrefix()` | Returns the prefix which is used as Separator when an upper case character is encountered after a lower case character.
    `String` | `process​(String toProcess)` | Replaces all characters in `toProcess` which occur in `toReplace` with `toReplaceWith`; groups of special characters are treated as one.
    `void` | `setUpperCaseSeparationPrefix​(String upperCaseSeparationPrefix)` | Sets the prefix which is used as Separator when an upper case character is encountered after a lower case character.

    - ### Methods inherited from class org.apache.torque.generator.processor.string.CharReplacer

      `getToReplace, getToReplaceWith, setToReplace, setToReplaceWith, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### UPPER_CASE_SEPPARATION_PREFIX

          public static final String UPPER_CASE_SEPPARATION_PREFIX

      The String which is usually used as prefix in front of upper case characters in java constants.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ConstantNameCreator

          public ConstantNameCreator()

      Constructor.

  - ### Method Detail

    - #### getUpperCaseSeparationPrefix

          public String getUpperCaseSeparationPrefix()

      Returns the prefix which is used as Separator when an upper case character is encountered after a lower case character.
      Returns:
        the separator which is inserted between a lower case character and an upper case character.

    - #### setUpperCaseSeparationPrefix

          public void setUpperCaseSeparationPrefix​(String upperCaseSeparationPrefix)

      Sets the prefix which is used as Separator when an upper case character is encountered after a lower case character.
      Parameters:
        `upperCaseSeparationPrefix` - the separator which is inserted between a lower case character and an upper case character.

    - #### process

          public String process​(String toProcess)

      Replaces all characters in `toProcess` which occur in `toReplace` with `toReplaceWith`; groups of special characters are treated as one. Inserts `UPPER_CASE_SEPPARATION_PREFIX` if an upper case character follows a lower case character, and converts all charcters to upper case. If the string starts is empty or start with a number, the character `toReplaceWith` is prefixed to the constant name. Finally, the new String is returned.

      Example: "prOceSS-*+ing~#._Test" is converted to "PR_OCE_SS_ING_TEST"

      Specified by:
        `process` in interface `StringProcessor`
      Overrides:
        `process` in class `CharReplacer`
      Parameters:
        `toProcess` - the String in which replacement should occur, not null.
      Returns:
        the processed String, not null.