001    /*
002     * AllLowerCaseFormatter.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
026     * lower-case and returns the lower-case version.
027     * <p/>
028     * The declarative name of this formatter is <code>allLowerCase</code>.
029     *
030     * @author Anupam Sengupta
031     * @version $Revision: 1.2 $
032     * @csv.formatter-mapping name="allLowerCase"
033     * @see AllUpperCaseFormatter
034     * @since 1.5
035     */
036    final class AllLowerCaseFormatter
037            implements CSVFieldFormatter {
038    
039        /**
040         * Constructor for AllLowerCaseFormatter.
041         */
042        public AllLowerCaseFormatter() {
043            super();
044        }
045    
046        /**
047         * Formats the value and transforms the result to all lower case.
048         *
049         * @param value the value to be transformed
050         * @return the lower 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.toLowerCase().trim();
059        }
060    
061    }