Class NameConverter.Standard

    • Constructor Summary

      Constructors 
      Constructor Description
      Standard()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String capitalize​(java.lang.String s)
      Capitalizes the first character of the specified string, and de-capitalize the rest of characters.
      protected int classify​(char c0)
      Classify a character into 5 categories that determine the word break.
      static void escape​(java.lang.StringBuilder sb, java.lang.String s, int start)
      Escapes characters is the given string so that they can be printed by only using US-ASCII characters.
      protected static boolean isDigit​(char c)  
      protected boolean isLetter​(char c)  
      protected static boolean isLower​(char c)  
      protected boolean isPunct​(char c)  
      protected static boolean isUpper​(char c)  
      java.lang.String toClassName​(java.lang.String s)
      converts a string into an identifier suitable for classes.
      java.lang.String toConstantName​(java.lang.String token)
      Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
      java.lang.String toConstantName​(java.util.List<java.lang.String> ss)
      Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
      java.lang.String toInterfaceName​(java.lang.String token)
      converts a string into an identifier suitable for interfaces.
      protected java.lang.String toMixedCaseName​(java.util.List<java.lang.String> ss, boolean startUpper)  
      protected java.lang.String toMixedCaseVariableName​(java.lang.String[] ss, boolean startUpper, boolean cdrUpper)  
      java.lang.String toPackageName​(java.lang.String nsUri)
      Computes a Java package name from a namespace URI, as specified in the spec.
      java.lang.String toPropertyName​(java.lang.String s)
      converts a string into an identifier suitable for properties.
      java.lang.String toVariableName​(java.lang.String s)
      Converts a string into an identifier suitable for variables.
      java.util.List<java.lang.String> toWordList​(java.lang.String s)
      Tokenizes a string into words and capitalizes the first character of each word.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Standard

        public Standard()
    • Method Detail

      • toClassName

        public java.lang.String toClassName​(java.lang.String s)
        Description copied from interface: NameConverter
        converts a string into an identifier suitable for classes. In general, this operation should generate "NamesLikeThis".
        Specified by:
        toClassName in interface NameConverter
      • toVariableName

        public java.lang.String toVariableName​(java.lang.String s)
        Description copied from interface: NameConverter
        Converts a string into an identifier suitable for variables. In general it should generate "namesLikeThis".
        Specified by:
        toVariableName in interface NameConverter
      • toInterfaceName

        public java.lang.String toInterfaceName​(java.lang.String token)
        Description copied from interface: NameConverter
        converts a string into an identifier suitable for interfaces. In general, this operation should generate "NamesLikeThis". But for example, it can prepend every interface with 'I'.
        Specified by:
        toInterfaceName in interface NameConverter
      • toPropertyName

        public java.lang.String toPropertyName​(java.lang.String s)
        Description copied from interface: NameConverter
        converts a string into an identifier suitable for properties. In general, this operation should generate "NamesLikeThis", which will be used with known prefixes like "get" or "set".
        Specified by:
        toPropertyName in interface NameConverter
      • toConstantName

        public java.lang.String toConstantName​(java.lang.String token)
        Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
        Specified by:
        toConstantName in interface NameConverter
        Returns:
        Always return a string but there's no guarantee that the generated code is a valid Java identifier.
      • toPackageName

        public java.lang.String toPackageName​(java.lang.String nsUri)
        Computes a Java package name from a namespace URI, as specified in the spec.
        Specified by:
        toPackageName in interface NameConverter
        Returns:
        null if it fails to derive a package name.
      • isPunct

        protected boolean isPunct​(char c)
      • isDigit

        protected static boolean isDigit​(char c)
      • isUpper

        protected static boolean isUpper​(char c)
      • isLower

        protected static boolean isLower​(char c)
      • isLetter

        protected boolean isLetter​(char c)
      • capitalize

        public java.lang.String capitalize​(java.lang.String s)
        Capitalizes the first character of the specified string, and de-capitalize the rest of characters.
      • classify

        protected int classify​(char c0)
        Classify a character into 5 categories that determine the word break.
      • toWordList

        public java.util.List<java.lang.String> toWordList​(java.lang.String s)
        Tokenizes a string into words and capitalizes the first character of each word.

        This method uses a change in character type as a splitter of two words. For example, "abc100ghi" will be splitted into {"Abc", "100","Ghi"}.

      • toMixedCaseName

        protected java.lang.String toMixedCaseName​(java.util.List<java.lang.String> ss,
                                                   boolean startUpper)
      • toMixedCaseVariableName

        protected java.lang.String toMixedCaseVariableName​(java.lang.String[] ss,
                                                           boolean startUpper,
                                                           boolean cdrUpper)
      • toConstantName

        public java.lang.String toConstantName​(java.util.List<java.lang.String> ss)
        Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
        Returns:
        Always return a string but there's no guarantee that the generated code is a valid Java identifier.
      • escape

        public static void escape​(java.lang.StringBuilder sb,
                                  java.lang.String s,
                                  int start)
        Escapes characters is the given string so that they can be printed by only using US-ASCII characters. The escaped characters will be appended to the given StringBuffer.
        Parameters:
        sb - StringBuffer that receives escaped string.
        s - String to be escaped. s.substring(start) will be escaped and copied to the string buffer.