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 018 package org.apache.commons.betwixt.strategy; 019 020 /** 021 * A beanmapper which converts a type to start with an uppercase. 022 * So eg elementName should return ElementName 023 * 024 * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a> 025 * @version $Id: CapitalizeNameMapper.java 471234 2006-11-04 17:28:08Z rdonkin $ 026 */ 027 public class CapitalizeNameMapper implements NameMapper { 028 029 /** 030 * Capitalize first letter of type name. 031 * 032 * @param typeName the string to convert 033 * @return <code>typeName</code> after first letter has been converted to upper case 034 */ 035 public String mapTypeToElementName(String typeName) { 036 if (typeName == null || typeName.length() ==0) { 037 return typeName; 038 } 039 StringBuffer sb = new StringBuffer(typeName); 040 char upperChar = Character.toUpperCase(typeName.charAt(0)); 041 sb.delete(0,1); 042 sb.insert(0, upperChar); 043 return sb.toString(); 044 } 045 046 /** 047 * Outputs a brief description. 048 * @since 0.8 049 */ 050 public String toString() { 051 return "Capitalize Type Name Mapper"; 052 } 053 } 054