Joda System API

org.joda.property.impl
Class PropertyHelper

java.lang.Object
  |
  +--org.joda.property.impl.PropertyHelper

public class PropertyHelper
extends java.lang.Object

Static class to aid with the creation of hard coded, not proxy generated ModelProperty implementations.

Author:
Stephen Colebourne

Method Summary
static java.lang.String capitalize(java.lang.String str)
          Capitalizes a String
static java.lang.String capitalizeFirstSection(java.lang.String str)
          Recapitalize the string, by capitalizing everything up to the first capital
static java.lang.String decapitalize(java.lang.String name)
          Utility method to take a string and convert it to normal Java variable name capitalization.
static java.lang.Class getBaseTypeFromGetter(java.lang.Class cls, java.lang.String name)
          Get the type of a property from its name and class by looking for a matching get method.
static java.lang.Class getBaseTypeFromProperty(java.lang.Class cls)
          Get the type of a property from the static DEFAULT_TYPE field that should be declared on every property interface.
static java.lang.reflect.Method getIndexedPropertyMethod(java.lang.Class cls, java.lang.String name)
          Get the method object for an indexed property by name.
static java.lang.reflect.Method getPropertyMethod(java.lang.Class cls, java.lang.String name)
          Get the method object for a property by name.
static java.lang.String makeGetter(java.lang.String str)
          Convert the property name into a getter method name
static java.lang.String makeIser(java.lang.String str)
          Convert the property name into an is method name
static java.lang.String makeProperty(java.lang.String name)
          Convert the getter or setter to a property name.
static java.lang.String makeProperty(java.lang.String str, int prefixLength)
          Convert the getter or setter to a property name.
static java.lang.String makeSetter(java.lang.String str)
          Convert the property name into a setter method name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

decapitalize

public static java.lang.String decapitalize(java.lang.String name)
Utility method to take a string and convert it to normal Java variable name capitalization. This normally means converting the first character from upper case to lower case, but in the (unusual) special case when there is more than one character and both the first and second characters are upper case, we leave it alone.

Thus "FooBah" becomes "fooBah" and "X" becomes "x", but "URL" stays as "URL".

(From java.beans.Introspector)

Parameters:
name - The string to be decapitalized.
Returns:
The decapitalized version of the string.

capitalize

public static java.lang.String capitalize(java.lang.String str)
Capitalizes a String

Returns:
capitalized string

capitalizeFirstSection

public static java.lang.String capitalizeFirstSection(java.lang.String str)
Recapitalize the string, by capitalizing everything up to the first capital

Returns:
capitalized string

makeGetter

public static java.lang.String makeGetter(java.lang.String str)
Convert the property name into a getter method name

Parameters:
str - string to be converted to a getter
Returns:
get method name

makeIser

public static java.lang.String makeIser(java.lang.String str)
Convert the property name into an is method name

Parameters:
str - string to be converted to a is type getter
Returns:
get method name

makeSetter

public static java.lang.String makeSetter(java.lang.String str)
Convert the property name into a setter method name

Parameters:
str - string to be converted to a setter
Returns:
set method name

makeProperty

public static java.lang.String makeProperty(java.lang.String str,
                                            int prefixLength)
Convert the getter or setter to a property name.

Parameters:
str - string to be converted to a property
prefixLength - the length of the prefix, 3 for get/set, 2 for is
Returns:
set method name

makeProperty

public static java.lang.String makeProperty(java.lang.String name)
Convert the getter or setter to a property name.

Returns:
set method name

getBaseTypeFromGetter

public static java.lang.Class getBaseTypeFromGetter(java.lang.Class cls,
                                                    java.lang.String name)
Get the type of a property from its name and class by looking for a matching get method.

Parameters:
cls - the class to search in
name - the property name
Returns:
the property type, null if no match

getBaseTypeFromProperty

public static java.lang.Class getBaseTypeFromProperty(java.lang.Class cls)
Get the type of a property from the static DEFAULT_TYPE field that should be declared on every property interface.

Parameters:
cls - the property class to search
Returns:
the property type, null if no match

getPropertyMethod

public static java.lang.reflect.Method getPropertyMethod(java.lang.Class cls,
                                                         java.lang.String name)
Get the method object for a property by name.

Parameters:
cls - the class to search in
name - the name, either a getter or property name
Returns:
the property type, null if no match

getIndexedPropertyMethod

public static java.lang.reflect.Method getIndexedPropertyMethod(java.lang.Class cls,
                                                                java.lang.String name)
Get the method object for an indexed property by name.

Parameters:
cls - the class to search in
name - the name, either a getter or property name
Returns:
the property type, null if no match

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.