01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.betwixt.strategy;
18:
19: /**
20: * <p>A default implementation of the name mapper.
21: * This mapper simply returns the unmodified type name.</p>
22: *
23: * <p>For example, <code>PropertyName</code> would be converted to <code>PropertyName</code>.
24: *
25: * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
26: * @version $Revision: 438373 $
27: */
28: public class DefaultNameMapper implements NameMapper {
29:
30: /** Used to convert bad character in the name */
31: private static final BadCharacterReplacingNMapper badCharacterReplacementNMapper = new BadCharacterReplacingNMapper(
32: new PlainMapper());
33:
34: /** Base implementation chained by bad character replacement mapper */
35: private static final class PlainMapper implements NameMapper {
36: /**
37: * This implementation returns the parameter passed in without modification.
38: *
39: * @param typeName the string to convert
40: * @return the typeName parameter without modification
41: */
42: public String mapTypeToElementName(String typeName) {
43: return typeName;
44: }
45: }
46:
47: /**
48: * This implementation returns the parameter passed after
49: * deleting any characters which the XML specification does not allow
50: * in element names.
51: *
52: * @param typeName the string to convert
53: * @return the typeName parameter without modification
54: */
55: public String mapTypeToElementName(String typeName) {
56: return badCharacterReplacementNMapper
57: .mapTypeToElementName(typeName);
58: }
59: }
|