KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > anupam > csv > formatters > AllLowerCaseFormatter


1 /*
2  * AllLowerCaseFormatter.java
3  *
4  * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * Version: $Revision: 1.2 $
21  */

22 package net.sf.anupam.csv.formatters;
23
24 /**
25  * A {@link CSVFieldFormatter Formatter} which transforms the input into all
26  * lower-case and returns the lower-case version.
27  * <p/>
28  * The declarative name of this formatter is <code>allLowerCase</code>.
29  *
30  * @author Anupam Sengupta
31  * @version $Revision: 1.2 $
32  * @csv.formatter-mapping name="allLowerCase"
33  * @see AllUpperCaseFormatter
34  * @since 1.5
35  */

36 final class AllLowerCaseFormatter
37         implements CSVFieldFormatter {
38
39     /**
40      * Constructor for AllLowerCaseFormatter.
41      */

42     public AllLowerCaseFormatter() {
43         super();
44     }
45
46     /**
47      * Formats the value and transforms the result to all lower case.
48      *
49      * @param value the value to be transformed
50      * @return the lower case transformed value
51      * @see CSVFieldFormatter#format(String)
52      */

53     public String JavaDoc format(final String JavaDoc value) {
54
55         if (value == null) {
56             return null;
57         }
58         return value.toLowerCase().trim();
59     }
60
61 }
62
Popular Tags