Class JavaIdentifierTransformer


  • public abstract class JavaIdentifierTransformer
    extends java.lang.Object
    Transforms a string into a valid Java identifier.
    There are five predefined strategies:
    • NOOP: does not perform transformation.
    • CAMEL_CASE: follows the camel case convention, deletes non JavaIndentifierPart chars.
    • UNDERSCORE: transform whitespace and non JavaIdentifierPart chars to '_'.
    • WHITESPACE: deletes whitespace and non JavaIdentifierPart chars.
    • STRICT: always throws a JSONException, does not perform transformation.
    Author:
    Andres Almiray
    • Constructor Detail

      • JavaIdentifierTransformer

        public JavaIdentifierTransformer()
    • Method Detail

      • transformToJavaIdentifier

        public abstract java.lang.String transformToJavaIdentifier​(java.lang.String str)
      • shaveOffNonJavaIdentifierStartChars

        protected final java.lang.String shaveOffNonJavaIdentifierStartChars​(java.lang.String str)
        Removes all non JavaIdentifier chars from the start of the string.
        Throws:
        JSONException - if the resulting string has zero length.