001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.betwixt.strategy;
018
019 /**
020 * <p>A default implementation of the name mapper.
021 * This mapper simply returns the unmodified type name.</p>
022 *
023 * <p>For example, <code>PropertyName</code> would be converted to <code>PropertyName</code>.
024 *
025 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
026 * @version $Revision: 438373 $
027 */
028 public class DefaultNameMapper implements NameMapper {
029
030 /** Used to convert bad character in the name */
031 private static final BadCharacterReplacingNMapper badCharacterReplacementNMapper
032 = new BadCharacterReplacingNMapper( new PlainMapper() );
033
034 /** Base implementation chained by bad character replacement mapper */
035 private static final class PlainMapper implements NameMapper {
036 /**
037 * This implementation returns the parameter passed in without modification.
038 *
039 * @param typeName the string to convert
040 * @return the typeName parameter without modification
041 */
042 public String mapTypeToElementName( String typeName ) {
043 return typeName ;
044 }
045 }
046
047 /**
048 * This implementation returns the parameter passed after
049 * deleting any characters which the XML specification does not allow
050 * in element names.
051 *
052 * @param typeName the string to convert
053 * @return the typeName parameter without modification
054 */
055 public String mapTypeToElementName( String typeName ) {
056 return badCharacterReplacementNMapper.mapTypeToElementName( typeName );
057 }
058 }