1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.pluto.portlet.admin.bean;
17
18 /***
19 * Typesafe enum (pre-JDK 1.5) that represents a Portlet Message Type
20 *
21 * @author Craig Doremus
22 *
23 */
24 public class PortletMessageType {
25
26 public static PortletMessageType INFO = new PortletMessageType("info", "portlet-msg-info");
27 public static PortletMessageType ERROR = new PortletMessageType("error", "portlet-msg-error");
28 public static PortletMessageType STATUS = new PortletMessageType("status", "portlet-msg-status");
29 public static PortletMessageType ALERT = new PortletMessageType("alert", "portlet-msg-alert");
30 public static PortletMessageType SUCCESS = new PortletMessageType("success", "portlet-msg-success");
31
32 public String name;
33 public String CssClass;
34
35 /***
36 *
37 */
38 private PortletMessageType(String name, String cssClass) {
39 this.name = name;
40 this.CssClass = cssClass;
41 }
42
43 public static PortletMessageType getTypeByName(String testName) {
44 if (testName.equalsIgnoreCase("info")){
45 return INFO;
46 } else if (testName.equalsIgnoreCase("error")){
47 return ERROR;
48 } else if (testName.equalsIgnoreCase("status")){
49 return STATUS;
50 } else if (testName.equalsIgnoreCase("alert")){
51 return ALERT;
52 } else if (testName.equalsIgnoreCase("success")){
53 return SUCCESS;
54 } else {
55 throw new IllegalArgumentException("PortletMessageType with name '" + testName + "' does not exist.");
56 }
57 }
58
59 public String toString(){
60 return name;
61 }
62
63 public static boolean equals(PortletMessageType msgType, String testName) {
64 if (msgType == getTypeByName(testName)) {
65 return true;
66 }
67 return false;
68 }
69
70 public boolean equals(Object obj) {
71 if (obj instanceof PortletMessageType) {
72 PortletMessageType comp = (PortletMessageType)obj;
73 return name.equals(comp.name);
74 }
75 return false;
76 }
77 }