|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object grails.util.GrailsNameUtils
public class GrailsNameUtils
Contains utility methods for converting between different name types, for example from class names -> property names and vice-versa. The key aspect of this class is that it has no dependencies outside the JDK!
Constructor Summary | |
---|---|
GrailsNameUtils()
|
Method Summary | |
---|---|
static String |
getClassName(String logicalName,
String trailingName)
Returns the class name for the given logical name and trailing name. |
static String |
getClassNameRepresentation(String name)
Returns the class name representation of the given name |
static String |
getGetterName(String propertyName)
Calculate the name for a getter method to retrieve the specified property |
static String |
getLogicalName(Class clazz,
String trailingName)
Retrieves the logical class name of a Grails artifact given the Grails class and a specified trailing name |
static String |
getLogicalName(String name,
String trailingName)
Retrieves the logical name of the class without the trailing name |
static String |
getLogicalPropertyName(String className,
String trailingName)
|
static String |
getNameFromScript(String scriptName)
Calculates the class name from a script name in the form my-funk-grails-script |
static String |
getNaturalName(String name)
Converts a property name into its natural language equivalent eg ('firstName' becomes 'First Name') |
static String |
getPluginName(String descriptorName)
Returns the name of a plugin given the name of the *GrailsPlugin.groovy descriptor file. |
static String |
getPropertyName(Class clazz)
Shorter version of getPropertyNameRepresentation |
static String |
getPropertyName(String name)
Shorter version of getPropertyNameRepresentation |
static String |
getPropertyNameForLowerCaseHyphenSeparatedName(String name)
Converts foo-bar into fooBar |
static String |
getPropertyNameRepresentation(Class targetClass)
Returns the property name equivalent for the specified class |
static String |
getPropertyNameRepresentation(String name)
Returns the property name representation of the given name |
static String |
getScriptName(Class clazz)
Retrieves the script name representation of the supplied class. |
static String |
getScriptName(String name)
Retrieves the script name representation of the given class name. |
static String |
getSetterName(String propertyName)
Retrieves the name of a setter for the specified property name |
static String |
getShortName(Class targetClass)
Returns the class name without the package prefix |
static String |
getShortName(String className)
Returns the class name without the package prefix |
static boolean |
isBlank(String str)
Determines whether a given string is null , empty,
or only contains whitespace. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GrailsNameUtils()
Method Detail |
---|
public static String getSetterName(String propertyName)
propertyName
- The property name
public static String getGetterName(String propertyName)
propertyName
-
public static String getClassName(String logicalName, String trailingName)
logicalName
- The logical nametrailingName
- The trailing name
public static String getClassNameRepresentation(String name)
name
- The name to convert
public static String getLogicalName(Class clazz, String trailingName)
clazz
- The classtrailingName
- The trailing name such as "Controller" or "TagLib"
public static String getLogicalName(String name, String trailingName)
name
- The name of the classtrailingName
- The trailing name
public static String getLogicalPropertyName(String className, String trailingName)
public static String getPropertyName(String name)
name
- The name to convert
public static String getPropertyName(Class clazz)
clazz
- The clazz to convert
public static String getPropertyNameRepresentation(Class targetClass)
targetClass
- The class to get the property name for
public static String getPropertyNameRepresentation(String name)
name
- The name to convert
public static String getPropertyNameForLowerCaseHyphenSeparatedName(String name)
name
- The lower case hyphen separated name
public static String getShortName(Class targetClass)
targetClass
- The class to get a short name for
public static String getShortName(String className)
className
- The class name to get a short name for
public static String getScriptName(Class clazz)
clazz
- The class to convert
public static String getScriptName(String name)
name
- The class name to convert.
public static String getNameFromScript(String scriptName)
scriptName
- The script name
public static String getPluginName(String descriptorName)
descriptorName
- The simple name of the plugin descriptor.
null
if descriptorName is null
, or an empty string
if descriptorName is an empty string.
IllegalArgumentException
- if the given descriptor name is
not valid, i.e. if it doesn't end with "GrailsPlugin.groovy".public static String getNaturalName(String name)
name
- The property name to convert
public static boolean isBlank(String str)
Determines whether a given string is null
, empty,
or only contains whitespace. If it contains anything other than
whitespace then the string is not considered to be blank and the
method returns false
.
We could use Commons Lang for this, but we don't want GrailsNameUtils to have a dependency on any external library to minimise the number of dependencies required to bootstrap Grails.
str
- The string to test.
true
if the string is null
, or
blank.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |