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