GriffonNameUtils (Griffon 0.9.5-rc2)
Date: 2012-03-09

Overview | Package | Class | Deprecated | Index | Help
| Griffon 0.9.5-rc2
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## griffon.util
[Java] Class GriffonNameUtils

    java.lang.Object
      griffon.util.GriffonNameUtils

    public class GriffonNameUtils
    extends Object

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!

Field Summary
`private static String` | `PROPERTY_SET_PREFIX`

Constructor Summary
`GriffonNameUtils()`

Method Summary
`static String` | `capitalize(String str)` Capitalizes a String (makes the first char uppercase) taking care of blank strings and single character strings.
`static String` | `getClassName(String logicalName, String trailingName)` Returns the class name for the given logical name and trailing name.
`static String` | `getClassNameForLowerCaseHyphenSeparatedName(String name)` Converts foo-bar into FooBar.
`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` | `getHyphenatedName(Class clazz)` Retrieves the hyphenated name representation of the supplied class.
`static String` | `getHyphenatedName(String name)` Retrieves the hyphenated name representation of the given class name.
`static String` | `getLogicalName(Class clazz, String trailingName)` Retrieves the logical class name of a Griffon artifact given the Griffon 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` | `getNaturalName(String name)` Converts a property name into its natural language equivalent eg ('firstName' becomes 'First Name')
`static String` | `getPropertyName(String name)` Shorter version of getPropertyNameRepresentation
`static String` | `getPropertyName(Class clazz)` 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` | `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)`
`static String` | `uncapitalize(String str)` Uncapitalizes a String (makes the first char lowercase) taking care of blank strings and single character strings.

Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Field Detail

### PROPERTY_SET_PREFIX

    private static final String PROPERTY_SET_PREFIX

Constructor Detail

### GriffonNameUtils

    GriffonNameUtils()

Method Detail

### capitalize

    public static String capitalize(String str)

  Capitalizes a String (makes the first char uppercase) taking care of blank strings and single character strings.
  Parameters:
    `str` - The String to be capitalized
  Returns:
    Capitalized version of the target string if it is not blank

### getClassName

    public static String getClassName(String logicalName, String trailingName)

  Returns the class name for the given logical name and trailing name. For example "person" and "Controller" would evaluate to "PersonController"
  Parameters:
    `logicalName` - The logical name
    `trailingName` - The trailing name
  Returns:
    The class name

### getClassNameForLowerCaseHyphenSeparatedName

    public static String getClassNameForLowerCaseHyphenSeparatedName(String name)

  Converts foo-bar into FooBar. Empty and null strings are returned as-is.
  Parameters:
    `name` - The lower case hyphen separated name
  Returns:
    The class name equivalent.

### getClassNameRepresentation

    public static String getClassNameRepresentation(String name)

  Returns the class name representation of the given name
  Parameters:
    `name` - The name to convert
  Returns:
    The property name representation

### getGetterName

    public static String getGetterName(String propertyName)

  Calculate the name for a getter method to retrieve the specified property
  Parameters:
    propertyName
  Returns:
    The name for the getter method for this property, if it were to exist, i.e. getConstraints

### getHyphenatedName

    public static String getHyphenatedName(Class clazz)

  Retrieves the hyphenated name representation of the supplied class. For example MyFunkyGriffonThingy would be my-funky-griffon-thingy.
  Parameters:
    `clazz` - The class to convert
  Returns:
    The hyphenated name representation

### getHyphenatedName

    public static String getHyphenatedName(String name)

  Retrieves the hyphenated name representation of the given class name. For example MyFunkyGriffonThingy would be my-funky-griffon-thingy.
  Parameters:
    `name` - The class name to convert.
  Returns:
    The hyphenated name representation.

### getLogicalName

    public static String getLogicalName(Class clazz, String trailingName)

  Retrieves the logical class name of a Griffon artifact given the Griffon class and a specified trailing name
  Parameters:
    `clazz` - The class
    `trailingName` - The trailing name such as "Controller" or "TagLib"
  Returns:
    The logical class name

### getLogicalName

    public static String getLogicalName(String name, String trailingName)

  Retrieves the logical name of the class without the trailing name
  Parameters:
    `name` - The name of the class
    `trailingName` - The trailing name
  Returns:
    The logical name

### getLogicalPropertyName

    public static String getLogicalPropertyName(String className, String trailingName)

### getNaturalName

    public static String getNaturalName(String name)

  Converts a property name into its natural language equivalent eg ('firstName' becomes 'First Name')
  Parameters:
    `name` - The property name to convert
  Returns:
    The converted property name

### getPropertyName

    public static String getPropertyName(String name)

  Shorter version of getPropertyNameRepresentation
  Parameters:
    `name` - The name to convert
  Returns:
    The property name version

### getPropertyName

    public static String getPropertyName(Class clazz)

  Shorter version of getPropertyNameRepresentation
  Parameters:
    `clazz` - The clazz to convert
  Returns:
    The property name version

### getPropertyNameForLowerCaseHyphenSeparatedName

    public static String getPropertyNameForLowerCaseHyphenSeparatedName(String name)

  Converts foo-bar into fooBar
  Parameters:
    `name` - The lower case hyphen separated name
  Returns:
    The property name equivalent

### getPropertyNameRepresentation

    public static String getPropertyNameRepresentation(Class targetClass)

  Returns the property name equivalent for the specified class
  Parameters:
    `targetClass` - The class to get the property name for
  Returns:
    A property name reperesentation of the class name (eg. MyClass becomes myClass)

### getPropertyNameRepresentation

    public static String getPropertyNameRepresentation(String name)

  Returns the property name representation of the given name
  Parameters:
    `name` - The name to convert
  Returns:
    The property name representation

### getSetterName

    public static String getSetterName(String propertyName)

  Retrieves the name of a setter for the specified property name
  Parameters:
    `propertyName` - The property name
  Returns:
    The setter equivalent

### getShortName

    public static String getShortName(Class targetClass)

  Returns the class name without the package prefix
  Parameters:
    `targetClass` - The class to get a short name for
  Returns:
    The short name of the class

### getShortName

    public static String getShortName(String className)

  Returns the class name without the package prefix
  Parameters:
    `className` - The class name to get a short name for
  Returns:
    The short name of the class

### isBlank

    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 GriffonNameUtils to have a dependency on any external library to minimise the number of dependencies required to bootstrap Griffon.

  Parameters:
    `str` - The string to test.
  Returns:
    `true` if the string is `null`, or blank.

### uncapitalize

    public static String uncapitalize(String str)

  Uncapitalizes a String (makes the first char lowercase) taking care of blank strings and single character strings.
  Parameters:
    `str` - The String to be uncapitalized
  Returns:
    Uncapitalized version of the target string if it is not blank

Groovy Documentation