001    /*
002     * AllUpperCaseFormatter.java
003     * 
004     * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net) 
005     * 
006     * This program is free software; you can redistribute it and/or 
007     * modify it under the terms of the GNU General Public License 
008     * as published by the Free Software Foundation; either version 2 
009     * of the License, or (at your option) any later version. 
010     * 
011     * This program is distributed in the hope that it will be useful, 
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of 
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
014     * GNU General Public License for more details. 
015     * 
016     * You should have received a copy of the GNU General Public License
017     * along with this program; if not, write to the Free Software 
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
019     *
020     * Version: $Revision: 1.2 $
021     */
022    package net.sf.anupam.csv.formatters;
023    
024    /**
025     * A {@link CSVFieldFormatter Formatter} which transforms the input into all upper case and returns the
026     * upper case version.
027     * <p/>
028     * The declarative name of this formatter is <code>allUpperCase</code>.
029     *
030     * @author Anupam Sengupta
031     * @version $Revision: 1.2 $
032     * @csv.formatter-mapping name="allUpperCase"
033     * @see AllLowerCaseFormatter
034     * @since 1.5
035     */
036    final class AllUpperCaseFormatter
037            implements CSVFieldFormatter {
038    
039        /**
040         * Constructor for AllUpperCaseFormatter.
041         */
042        public AllUpperCaseFormatter() {
043            super();
044        }
045    
046        /**
047         * Formats the value and transforms the result to all UPPER case.
048         *
049         * @param value the value to be transformed
050         * @return the UPPER case transformed value
051         * @see CSVFieldFormatter#format(String)
052         */
053        public String format(final String value) {
054    
055            if (value == null) {
056                return null;
057            }
058            return value.toUpperCase().trim();
059        }
060    
061    }