Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
DefaultNameMapper |
|
| 1.0;1 |
1 | /* |
|
2 | * Copyright 2001-2004 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
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: 155402 $ |
|
26 | */ |
|
27 | 3898 | public class DefaultNameMapper implements NameMapper { |
28 | ||
29 | /** Used to convert bad character in the name */ |
|
30 | 786 | private static final BadCharacterReplacingNMapper badCharacterReplacementNMapper |
31 | 786 | = new BadCharacterReplacingNMapper( new PlainMapper() ); |
32 | ||
33 | /** Base implementation chained by bad character replacement mapper */ |
|
34 | 786 | 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 | 15754 | 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 | 15754 | return badCharacterReplacementNMapper.mapTypeToElementName( typeName ); |
56 | } |
|
57 | } |