org.umber.core.util
Class PropertyName

java.lang.Object
  extended byorg.umber.core.util.PropertyName

public class PropertyName
extends java.lang.Object

Helper class to convert a property name into various forms. Includes case-delimited ("PropertyName"), bean-property ("propertyName"), hyphenated ("property-name"), underscored ("property_name"), and underscore-caps ("PROPERTY_NAME").

Author:
jsheets

Nested Class Summary
static class PropertyName.PropertyStyle
          Enumeration for property naming styles.
 
Field Summary
static PropertyName.PropertyStyle CASE_DELIM_STYLE
          Property formatting style for case-delimited names, e.g., MyProperty
static PropertyName.PropertyStyle DEFAULT_STYLE
          Default property formatting style
static PropertyName.PropertyStyle JAVABEAN_STYLE
          Property formatting style for JavaBean names, e.g., myProperty
static PropertyName.PropertyStyle LOWER_HYPHEN_STYLE
          Property formatting style for lowercase hyphen-separated names, e.g., my-property
static PropertyName.PropertyStyle LOWER_UNDERSCORE_STYLE
          Property formatting style for lowercase underscore-separated names, e.g., my_property
static PropertyName.PropertyStyle UPPER_HYPHEN_STYLE
          Property formatting style for uppercase hyphen-separated names, e.g., MY-PROPERTY
static PropertyName.PropertyStyle UPPER_UNDERSCORE_STYLE
          Property formatting style for uppercase underscore-separated names, e.g., MY_PROPERTY
 
Constructor Summary
PropertyName(java.lang.String propertyName)
          Creates a new instance of PropertyName.
 
Method Summary
static java.lang.String applyStyle(java.lang.String name, PropertyName.PropertyStyle style)
          Converts the name to the requested naming style.
 java.lang.String getBeanPropertyName()
          Returns the property name in JavaBean property format, e.g., "propertyName".
 java.lang.String getCaseDelimitedName()
          Returns the property name in case-delimited format, e.g., "PropertyName".
 java.lang.String getLowerHyphenatedName()
          Returns the property name in hyphenated format, e.g., "property-name".
 java.lang.String getLowerUnderscoredName()
          Returns the property name in underscored format, e.g., "property_name".
 java.lang.String getPropertyName()
          Returns the original property name.
 java.lang.String getUpperHyphenatedName()
          Returns the property name in hyphenated format, e.g., "property-name".
 java.lang.String getUpperUnderscoredName()
          Returns the property name in underscored all-caps format, e.g., "PROPERTY_NAME".
 java.lang.String toString()
          Returns a stringified version of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOWER_HYPHEN_STYLE

public static final PropertyName.PropertyStyle LOWER_HYPHEN_STYLE
Property formatting style for lowercase hyphen-separated names, e.g., my-property


LOWER_UNDERSCORE_STYLE

public static final PropertyName.PropertyStyle LOWER_UNDERSCORE_STYLE
Property formatting style for lowercase underscore-separated names, e.g., my_property


UPPER_HYPHEN_STYLE

public static final PropertyName.PropertyStyle UPPER_HYPHEN_STYLE
Property formatting style for uppercase hyphen-separated names, e.g., MY-PROPERTY


UPPER_UNDERSCORE_STYLE

public static final PropertyName.PropertyStyle UPPER_UNDERSCORE_STYLE
Property formatting style for uppercase underscore-separated names, e.g., MY_PROPERTY


CASE_DELIM_STYLE

public static final PropertyName.PropertyStyle CASE_DELIM_STYLE
Property formatting style for case-delimited names, e.g., MyProperty


JAVABEAN_STYLE

public static final PropertyName.PropertyStyle JAVABEAN_STYLE
Property formatting style for JavaBean names, e.g., myProperty


DEFAULT_STYLE

public static final PropertyName.PropertyStyle DEFAULT_STYLE
Default property formatting style

Constructor Detail

PropertyName

public PropertyName(java.lang.String propertyName)
Creates a new instance of PropertyName.

Parameters:
propertyName - the name of the property
Method Detail

applyStyle

public static java.lang.String applyStyle(java.lang.String name,
                                          PropertyName.PropertyStyle style)
Converts the name to the requested naming style.

Parameters:
name - the name to convert
style - the naming style
Returns:
the name in the requested naming style

getPropertyName

public java.lang.String getPropertyName()
Returns the original property name.

Returns:
the original property name

getCaseDelimitedName

public java.lang.String getCaseDelimitedName()
Returns the property name in case-delimited format, e.g., "PropertyName".

Returns:
the property name in case-delimited format

getBeanPropertyName

public java.lang.String getBeanPropertyName()
Returns the property name in JavaBean property format, e.g., "propertyName".

Returns:
the property name in JavaBean property format

getLowerHyphenatedName

public java.lang.String getLowerHyphenatedName()
Returns the property name in hyphenated format, e.g., "property-name".

Returns:
the property name in hyphenated format

getLowerUnderscoredName

public java.lang.String getLowerUnderscoredName()
Returns the property name in underscored format, e.g., "property_name".

Returns:
the property name in underscored format

getUpperHyphenatedName

public java.lang.String getUpperHyphenatedName()
Returns the property name in hyphenated format, e.g., "property-name".

Returns:
the property name in hyphenated format

getUpperUnderscoredName

public java.lang.String getUpperUnderscoredName()
Returns the property name in underscored all-caps format, e.g., "PROPERTY_NAME".

Returns:
the property name in underscored all-caps format

toString

public java.lang.String toString()
Returns a stringified version of this object.

Returns:
a stringified version of this object