1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.betwixt.strategy;
17
18 import java.beans.Introspector;
19
20 /***
21 * <p>A name mapper which converts types to a decapitalized String.</p>
22 *
23 * <p>This conversion decapitalizes in the standard java beans way
24 * (as per <code>java.beans.Introspector</code>).
25 * This means that the first letter only will be decapitalized except
26 * for the case where the first and second characters are both upper case.
27 * When both are upper case, then the name will be left alown.</p>
28 *
29 * <p>So a bean type of <code>Foo</code> will be converted to the element name <code>"foo"</code.
30 * <code>FooBar</code> will be converted to <code>"fooBar"</code>.
31 * But <code>URL</code> will remain as <code>"URL"</code>.</p>
32 *
33 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
34 * @version $Revision: 1.6 $
35 */
36 public class DecapitalizeNameMapper implements NameMapper {
37
38 /***
39 * Decapitalize first letter unless both are upper case.
40 * (As per standard java beans behaviour.)
41 *
42 * @param typeName the string to convert
43 * @return decapitalized name as per <code>java.beans.Introspector</code>
44 */
45 public String mapTypeToElementName(String typeName) {
46 return Introspector.decapitalize( typeName );
47 }
48 }