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