org.apache.commons.betwixt.strategy
Class HyphenatedNameMapper

java.lang.Object
  |
  +--org.apache.commons.betwixt.strategy.HyphenatedNameMapper
All Implemented Interfaces:
NameMapper

public class HyphenatedNameMapper
extends java.lang.Object
implements NameMapper

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, "_").

Version:
$Revision: 1.2 $
Author:
Jason van Zyl
, James Strachan

Constructor Summary
HyphenatedNameMapper()
           
HyphenatedNameMapper(boolean upperCase)
           
HyphenatedNameMapper(boolean upperCase, java.lang.String separator)
           
 
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()
           
 boolean isUpperCase()
           
 java.lang.String mapTypeToElementName(java.lang.String typeName)
           
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HyphenatedNameMapper

public HyphenatedNameMapper()

HyphenatedNameMapper

public HyphenatedNameMapper(boolean upperCase)

HyphenatedNameMapper

public HyphenatedNameMapper(boolean upperCase,
                            java.lang.String separator)
Method Detail

mapTypeToElementName

public java.lang.String mapTypeToElementName(java.lang.String typeName)
Specified by:
mapTypeToElementName in interface NameMapper
Returns:
the element name for the given bean type name

getSeparator

public java.lang.String getSeparator()
Returns:
the separator used to seperate words, which defaults to '-'

setSeparator

public void setSeparator(java.lang.String separator)
Sets the separator used to seperate words, which defaults to '-'


isUpperCase

public boolean isUpperCase()
Returns:
whether upper or lower case conversions should be performed, which defaults to false for lower case

setUpperCase

public void setUpperCase(boolean upperCase)
Sets whether upper or lower case conversions should be performed, which defaults to false for lower case


convertChar

protected char convertChar(char ch)
Performs type conversion on the given character based on whether upper or lower case conversions are being used



Copyright © 2002-2002 Apache Software Foundation. All Rights Reserved.