001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: /*
037: * AlertBean.java
038: */
039: package com.sun.jbi.jsf.bean;
040:
041: import com.sun.jbi.jsf.util.JBILogger;
042:
043: /**
044: * Holds alert type (for icon display), summary, details, and display state.
045: *
046: * @author Sun Microsystems Inc.
047: */
048: public class AlertBean {
049:
050: /**
051: * Tracks display of an alert
052: */
053: public static final int ALERT_COUNT_NONE = 0;
054:
055: /**
056: * Represents emptied details
057: */
058: public static final String ALERT_DETAIL_NONE = "";
059: // not I18n
060:
061: /**
062: * Represents emptied summary
063: */
064: public static final String ALERT_SUMMARY_NONE = "";
065: // not I18n
066:
067: /**
068: * <code>error</code> icon alert display
069: */
070: public static final String ALERT_TYPE_ERROR = "error";
071: // not I18n
072:
073: /**
074: * <code>info</code> icon alert display
075: */
076: public static final String ALERT_TYPE_INFO = "info";
077: // not I18n
078:
079: /**
080: * an uninitialized alert type
081: */
082: public static final String ALERT_TYPE_NONE = "";
083: // not I18n
084:
085: /**
086: * <code>warning</code> icon alert display
087: */
088: public static final String ALERT_TYPE_WARNING = "warning";
089:
090: // not I18n
091:
092: /**
093: * Gets the count to determine if the alert needs to be, or already has
094: * been, displayed.
095: *
096: * @return zero if there is no need to display the alert
097: */
098: public int getAlertCount() {
099: if (JBILogger.isLoggableFiner()) {
100: JBILogger.logFiner(CN, MN_GET_ALERT_COUNT, "mAlertCount="
101: + mAlertCount);
102: }
103: return mAlertCount;
104: }
105:
106: /**
107: * Gets alert details
108: *
109: * @return the I18n details to display in an alert
110: */
111: public String getAlertDetail() {
112: if (JBILogger.isLoggableFiner()) {
113: JBILogger.logFiner(CN, MN_GET_ALERT_DETAIL, "mAlertDetail="
114: + mAlertDetail);
115: }
116: return mAlertDetail;
117: }
118:
119: /**
120: * Gets alert summary
121: *
122: * @return the I18n summary to display in an alert
123: */
124: public String getAlertSummary() {
125: if (JBILogger.isLoggableFiner()) {
126: JBILogger.logFiner(CN, MN_GET_ALERT_SUMMARY,
127: "mAlertSummary=" + mAlertSummary);
128: }
129: return mAlertSummary;
130: }
131:
132: /**
133: * Gets alert type
134: *
135: * @return the type of alert icon to display, one of: <code>info</code>,
136: * <code>warning</code>, <code>error</code> (defaults to <code>error</code>
137: * if no alert type was set.
138: */
139: public String getAlertType() {
140: if (ALERT_TYPE_NONE.equals(mAlertType)) {
141: mAlertType = ALERT_TYPE_ERROR;
142: }
143:
144: if (JBILogger.isLoggableFiner()) {
145: JBILogger.logFiner(CN, MN_GET_ALERT_TYPE, "mAlertType="
146: + mAlertType);
147: }
148:
149: return mAlertType;
150: }
151:
152: /**
153: * Sets the count
154: *
155: * @param anAlertCount the new count, nonzero if the alert is to be
156: * displayed, and zero when the alert has been displayed.
157: */
158: public void setAlertCount(int anAlertCount) {
159: mAlertCount = anAlertCount;
160: if (JBILogger.isLoggableFiner()) {
161: JBILogger.logFiner(CN, MN_SET_ALERT_COUNT, "mAlertCount="
162: + mAlertCount);
163: }
164: }
165:
166: /**
167: * Sets the details
168: *
169: * @param aAlertDetail an I18n details message string
170: */
171: public void setAlertDetail(String aAlertDetail) {
172: if (JBILogger.isLoggableFiner()) {
173: JBILogger.logFiner(CN, MN_SET_ALERT_DETAIL, "mAlertDetail="
174: + mAlertDetail);
175: }
176: mAlertDetail = aAlertDetail;
177: }
178:
179: /**
180: * Sets summary
181: *
182: * @param aAlertSummary the I18n summary message string
183: */
184: public void setAlertSummary(String aAlertSummary) {
185: if (JBILogger.isLoggableFiner()) {
186: JBILogger.logFiner(CN, MN_SET_ALERT_SUMMARY,
187: "mAlertSummary=" + mAlertSummary);
188: }
189: mAlertSummary = aAlertSummary;
190: }
191:
192: /**
193: * Sets the type of icon to display
194: *
195: * @param aAlertType an icon type, one of: <code>info</code>, <code>warning</code>
196: * , or <code>error</code>. If not set, the icon defaults to <code>error</code>
197: * .
198: */
199: public void setAlertType(String aAlertType) {
200: if (JBILogger.isLoggableFiner()) {
201: JBILogger.logFiner(CN, MN_SET_ALERT_TYPE, "mAlertType="
202: + mAlertType);
203: }
204: mAlertType = aAlertType;
205: }
206:
207: private static final String CN = AlertBean.class.getName();
208: private static final String MN_GET_ALERT_COUNT = "getAlertCount()";
209: private static final String MN_GET_ALERT_DETAIL = "getAlertDetail()";
210: private static final String MN_GET_ALERT_SUMMARY = "getAlertSummary()";
211: private static final String MN_GET_ALERT_TYPE = "getAlertType()";
212: private static final String MN_SET_ALERT_COUNT = "setAlertCount()";
213: private static final String MN_SET_ALERT_DETAIL = "setAlertDetail()";
214: private static final String MN_SET_ALERT_SUMMARY = "setAlertSummary()";
215: private static final String MN_SET_ALERT_TYPE = "setAlertType()";
216:
217: private int mAlertCount = ALERT_COUNT_NONE;
218: private String mAlertDetail = ALERT_DETAIL_NONE;
219: private String mAlertSummary = ALERT_SUMMARY_NONE;
220: private String mAlertType = ALERT_TYPE_NONE;
221: }
|