Class SyntaxTool


  • public final class SyntaxTool
    extends java.lang.Object
    Syntax toolbox: naming conventions transformations
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int CAMEL
      camelCase
      static int PASCAL
      PascalCase
      static int SNAKE
      snake_case
      static int UPPER
      UPPER_CASE
    • Method Summary

      Modifier and Type Method Description
      static java.lang.String caseConvert​(java.lang.String str, int from, int to)
      Converts a string from one case to another
      static java.lang.String forceCase​(java.lang.String str, int to, boolean guessCase)
      Forces a string to a case
      static java.lang.String getErrorMessage​(ObjectField field, int caseType, java.lang.String prefix)  
      static java.lang.String getFunctionDisplayCode​(java.lang.String functionCode)  
      static java.lang.String getModulePrefix​(java.lang.String id)
      Get module prefix from row ID
      static java.lang.String getObjectPrefix​(java.lang.String id)
      Get object prefix from row ID
      static java.lang.String getValidationMessage​(ObjectField field, int caseType, java.lang.String prefix, java.lang.String msgType)
      Validates that a field does respect a given case and is properly prefixed
      static java.lang.String getWarningMessage​(ObjectField field, int caseType, java.lang.String prefix)  
      static boolean isSyntaxEnabled​(Grant g)
      Are syntax suggestions enabled?
      static java.lang.String join​(int caseType, java.lang.String[] words)
      Joins an array of word with specified case type
      static java.lang.String prefixate​(int caseType, java.lang.String word, java.lang.String prefix)
      Prefixates a string with a prefix in a given case.
      static boolean validate​(int caseType, java.lang.String str)
      Validates that a given String respects a case convention
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isSyntaxEnabled

        public static boolean isSyntaxEnabled​(Grant g)
        Are syntax suggestions enabled?
      • getModulePrefix

        public static java.lang.String getModulePrefix​(java.lang.String id)
        Get module prefix from row ID
      • getObjectPrefix

        public static java.lang.String getObjectPrefix​(java.lang.String id)
        Get object prefix from row ID
      • getFunctionDisplayCode

        public static java.lang.String getFunctionDisplayCode​(java.lang.String functionCode)
      • validate

        public static boolean validate​(int caseType,
                                       java.lang.String str)
        Validates that a given String respects a case convention
        Parameters:
        caseType - case convention
        str - string to validate
        Returns:
        false if case doesn't exist or string not valid
      • prefixate

        public static java.lang.String prefixate​(int caseType,
                                                 java.lang.String word,
                                                 java.lang.String prefix)
        Prefixates a string with a prefix in a given case. Returns null if given string doesn't already respect the case.
        Parameters:
        caseType - case convention
        word - the string to prefixate
        prefix - prefix
        Returns:
        prefixated string or null if case convention doesn't exist or given string doesn't respect the case
      • join

        public static java.lang.String join​(int caseType,
                                            java.lang.String[] words)
        Joins an array of word with specified case type
        Parameters:
        caseType -
        words -
        Returns:
        Joined array
      • getWarningMessage

        public static java.lang.String getWarningMessage​(ObjectField field,
                                                         int caseType,
                                                         java.lang.String prefix)
      • getErrorMessage

        public static java.lang.String getErrorMessage​(ObjectField field,
                                                       int caseType,
                                                       java.lang.String prefix)
      • getValidationMessage

        public static java.lang.String getValidationMessage​(ObjectField field,
                                                            int caseType,
                                                            java.lang.String prefix,
                                                            java.lang.String msgType)
        Validates that a field does respect a given case and is properly prefixed
        Parameters:
        field - Field
        caseType - Case type
        prefix - Prefix
        msgType - Message.WARN, Message.ERROR, etc.
        Returns:
        null if ok, formatted error if string doesn't respect case or misses prefix
      • caseConvert

        public static java.lang.String caseConvert​(java.lang.String str,
                                                   int from,
                                                   int to)
        Converts a string from one case to another
        Parameters:
        str - String
        from - From
        to - To
        Returns:
        String or null il strin gis null or case doesn't exist
      • forceCase

        public static java.lang.String forceCase​(java.lang.String str,
                                                 int to,
                                                 boolean guessCase)
        Forces a string to a case
        Parameters:
        str - String
        to - To
        guessCase - Tries to identify case before splitting
        Returns:
        String or null il strin gis null or case doesn't exist