001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * ---------------------------------------------------------
005: * ivata masks may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * ---------------------------------------------------------
030: * $Log: CaseFormat.java,v $
031: * Revision 1.3 2005/10/11 18:54:06 colinmacleod
032: * Fixed some checkstyle and javadoc issues.
033: *
034: * Revision 1.2 2005/10/03 10:17:25 colinmacleod
035: * Fixed some style and javadoc issues.
036: *
037: * Revision 1.1 2005/04/11 14:44:46 colinmacleod
038: * First version.
039: *
040: * ---------------------------------------------------------
041: */
042: package com.ivata.mask.web.format;
043:
044: import org.apache.log4j.Logger;
045:
046: /**
047: * Convert a string to upper or lower case.
048: *
049: * @since ivata masks 0.6 (2005-03-15)
050: * @author Colin MacLeod
051: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
052: * @version $Revision: 1.3 $
053: */
054:
055: public class CaseFormat implements HTMLFormat {
056: /**
057: * Logger for this class.
058: */
059: private static final Logger logger = Logger
060: .getLogger(CaseFormat.class);
061:
062: /**
063: * <copyDoc>Refer to {@link #isLower}.</copyDoc>
064: */
065: private boolean lower = true;
066:
067: /**
068: * Converts the given text to either upper or lower (default) case,
069: * depending on the setting of {@link #isLower lower}.
070: *
071: * @param textParam text to be converted.
072: * @return text with all characters converted to either upper or lower case.
073: */
074: public String format(final String textParam) {
075: if (lower) {
076: return textParam.toLowerCase();
077: } else {
078: return textParam.toUpperCase();
079: }
080: }
081:
082: /**
083: * If <code>true</code>, then <code>format</code> will convert to lower
084: * case.
085: * @return Returns <code>true</code>, if <code>format</code> should convert
086: * to lower case, otherwise <code>false</code>.
087: */
088: public boolean isLower() {
089: return lower;
090: }
091:
092: /**
093: * <copyDoc>Refer to {@link #isLower}.</copyDoc>
094: * @param lowerParam <copyDoc>Refer to {@link #isLower}.</copyDoc>
095: */
096: public void setLower(final boolean lowerParam) {
097: if (logger.isDebugEnabled()) {
098: logger.debug("Setting lower. Before '" + lower
099: + "', after '" + lowerParam + "'");
100: }
101: lower = lowerParam;
102: }
103: }
|