01: /*
02: * AllLowerCaseFormatter.java
03: *
04: * Copyright (C) 2005 Anupam Sengupta (anupamsg@users.sourceforge.net)
05: *
06: * This program is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU General Public License
08: * as published by the Free Software Foundation; either version 2
09: * 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 implements CSVFieldFormatter {
37:
38: /**
39: * Constructor for AllLowerCaseFormatter.
40: */
41: public AllLowerCaseFormatter() {
42: super ();
43: }
44:
45: /**
46: * Formats the value and transforms the result to all lower case.
47: *
48: * @param value the value to be transformed
49: * @return the lower case transformed value
50: * @see CSVFieldFormatter#format(String)
51: */
52: public String format(final String value) {
53:
54: if (value == null) {
55: return null;
56: }
57: return value.toLowerCase().trim();
58: }
59:
60: }
|