|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.betwixt.strategy.HyphenatedNameMapper
public class HyphenatedNameMapper
A name mapper which converts types to a hypenated String. So
a bean type of FooBar will be converted to the element name "foo-bar".
The name mapper can be configured to convert to upper case and to
use a different separator via the separator
and
upperCase
properties, so that FooBar can be converted
to FOO_BAR if needed, by calling the constructor
new HyphenatedNameMapper(true, "_")
.
Constructor Summary | |
---|---|
HyphenatedNameMapper()
Construct a hyphenated name mapper that converts the name to lower case and uses the default separator. |
|
HyphenatedNameMapper(boolean upperCase)
Construct a hyphenated name mapper with default separator. |
|
HyphenatedNameMapper(boolean upperCase,
java.lang.String separator)
Construct a hyphenated name mapper. |
Method Summary | |
---|---|
protected char |
convertChar(char ch)
Performs type conversion on the given character based on whether upper or lower case conversions are being used |
java.lang.String |
getSeparator()
This separator will be inserted between the words in the bean name. |
boolean |
isUpperCase()
Should the bean name be converted to upper case? |
java.lang.String |
mapTypeToElementName(java.lang.String typeName)
The words within the bean name are deduced assuming the first-letter-capital (for example camel's hump) naming convention. |
void |
setSeparator(java.lang.String separator)
Sets the separator used to seperate words, which defaults to '-' |
void |
setUpperCase(boolean upperCase)
Sets whether upper or lower case conversions should be performed, which defaults to false for lower case. |
java.lang.String |
toString()
Outputs brief description. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HyphenatedNameMapper()
public HyphenatedNameMapper(boolean upperCase)
upperCase
- should the type name be converted (entirely) to upper casepublic HyphenatedNameMapper(boolean upperCase, java.lang.String separator)
upperCase
- should the type name be converted (entirely) to upper caseseparator
- use this string to separate the words in the name returned.
The words in the bean name are deduced by relying on the standard camel's hump
property naming convention.Method Detail |
---|
public java.lang.String mapTypeToElementName(java.lang.String typeName)
The words within the bean name are deduced assuming the
first-letter-capital (for example camel's hump) naming convention. For
example, the words in FooBar
are foo
and bar
.
Next convert all letter in the bean name to either upper case or lower case
based on the isUpperCase()
property value.
Then the getSeparator()
property value is inserted so that it separates
each word.
mapTypeToElementName
in interface NameMapper
typeName
- The name string to convert. If a JavaBean
class name, should included only the last part of the name
rather than the fully qualified name (e.g. FooBar rather than
org.example.FooBar).
public java.lang.String getSeparator()
public void setSeparator(java.lang.String separator)
separator
- the string inserted to separate wordspublic boolean isUpperCase()
Should the bean name be converted to upper case?
Otherwise, it will be converted to lower case.
public void setUpperCase(boolean upperCase)
upperCase
- whether the name is to be converted to upper caseprotected char convertChar(char ch)
ch
- the character to be converted
isUpperCase()
otherwise to lower casepublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |