Package com.simplicite.util.tools
Class SyntaxTool
- java.lang.Object
-
- com.simplicite.util.tools.SyntaxTool
-
public final class SyntaxTool extends java.lang.Object
Syntax toolbox: naming conventions transformations
This class only provides static variables and methods
-
-
Method Summary
All Methods Static Methods Concrete Methods 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 anotherstatic java.lang.String
forceCase(java.lang.String str, int to, boolean guessCase)
Forces a string to a casestatic java.lang.String
getErrorMessage(ObjectField field, int caseType, java.lang.String prefix)
Get error messagestatic java.lang.String
getFunctionDisplayCode(java.lang.String functionCode)
Get function display codestatic java.lang.String
getModulePrefix(java.lang.String moduleId)
Get module prefix from module row IDstatic java.lang.String
getObjectModulePrefix(java.lang.String objectId)
Get object's module prefix from object row IDstatic java.lang.String
getObjectPrefix(java.lang.String objectId)
Get object prefix from object row IDstatic 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 prefixedstatic java.lang.String
getWarningMessage(ObjectField field, int caseType, java.lang.String prefix)
Get warning messagestatic 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 typestatic 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 java.lang.String
prefixate(int caseType, java.lang.String word, java.lang.String[] prefixes)
Prefixates a string with a lis of prefixes in a given case.static java.lang.String
service(org.json.JSONObject data)
Servicestatic boolean
validate(int caseType, java.lang.String str)
Validates that a given String respects a case convention
-
-
-
Field Detail
-
PASCAL
public static final int PASCAL
PascalCase- See Also:
- Constant Field Values
-
CAMEL
public static final int CAMEL
camelCase- See Also:
- Constant Field Values
-
SNAKE
public static final int SNAKE
snake_case- See Also:
- Constant Field Values
-
UPPER
public static final int UPPER
UPPER_CASE- See Also:
- Constant Field Values
-
-
Method Detail
-
isSyntaxEnabled
public static boolean isSyntaxEnabled(Grant g)
Are syntax suggestions enabled?- Returns:
- True if syntax suggestions are enabled
-
getModulePrefix
public static java.lang.String getModulePrefix(java.lang.String moduleId)
Get module prefix from module row ID- Parameters:
moduleId
- Module row ID- Returns:
- Module prefix
-
getObjectPrefix
public static java.lang.String getObjectPrefix(java.lang.String objectId)
Get object prefix from object row ID- Parameters:
objectId
- Object row ID- Returns:
- Object prefix
-
getObjectModulePrefix
public static java.lang.String getObjectModulePrefix(java.lang.String objectId)
Get object's module prefix from object row ID- Parameters:
objectId
- Object row ID- Returns:
- Object's module prefix
-
getFunctionDisplayCode
public static java.lang.String getFunctionDisplayCode(java.lang.String functionCode)
Get function display code- Parameters:
functionCode
- Function code- Returns:
- Function display code
-
validate
public static boolean validate(int caseType, java.lang.String str)
Validates that a given String respects a case convention- Parameters:
caseType
- case conventionstr
- 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.- Parameters:
caseType
- case conventionword
- the string to prefixateprefix
- prefix- Returns:
- prefixated string or null if case convention doesn't exist or given string doesn't respect the case
-
prefixate
public static java.lang.String prefixate(int caseType, java.lang.String word, java.lang.String[] prefixes)
Prefixates a string with a lis of prefixes in a given case.- Parameters:
caseType
- case conventionword
- the string to prefixateprefixes
- prefixes- 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)
Get warning message- Parameters:
field
- FieldcaseType
- Case typeprefix
- Prefix- Returns:
- Warning message
-
getErrorMessage
public static java.lang.String getErrorMessage(ObjectField field, int caseType, java.lang.String prefix)
Get error message- Parameters:
field
- FieldcaseType
- Case typeprefix
- Prefix- Returns:
- Error message
-
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
- FieldcaseType
- Case typeprefix
- PrefixmsgType
- 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
- Stringfrom
- Fromto
- 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
- Stringto
- ToguessCase
- Tries to identify case before splitting- Returns:
- String or null il strin gis null or case doesn't exist
-
service
public static java.lang.String service(org.json.JSONObject data)
Service- Parameters:
data
- JSON data- Returns:
- JSOn or null
-
-