1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.betwixt.strategy;
17
18 /***
19 * <p>A default implementation of the name mapper.
20 * This mapper simply returns the unmodified type name.</p>
21 *
22 * <p>For example, <code>PropertyName</code> would be converted to <code>PropertyName</code>.
23 *
24 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
25 * @version $Revision: 1.7 $
26 */
27 public class DefaultNameMapper implements NameMapper {
28
29 /*** Used to convert bad character in the name */
30 private static final BadCharacterReplacingNMapper badCharacterReplacementNMapper
31 = new BadCharacterReplacingNMapper( new PlainMapper() );
32
33 /*** Base implementation chained by bad character replacement mapper */
34 private static final class PlainMapper implements NameMapper {
35 /***
36 * This implementation returns the parameter passed in without modification.
37 *
38 * @param typeName the string to convert
39 * @return the typeName parameter without modification
40 */
41 public String mapTypeToElementName( String typeName ) {
42 return typeName ;
43 }
44 }
45
46 /***
47 * This implementation returns the parameter passed after
48 * deleting any characters which the XML specification does not allow
49 * in element names.
50 *
51 * @param typeName the string to convert
52 * @return the typeName parameter without modification
53 */
54 public String mapTypeToElementName( String typeName ) {
55 return badCharacterReplacementNMapper.mapTypeToElementName( typeName );
56 }
57 }