1 16 package org.apache.pluto.portlet.admin.bean; 17 18 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 = null; 33 public String CssClass = null; 34 35 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 } else { 67 return false; 68 } 69 } 70 71 public boolean equals(Object obj) { 72 if (obj instanceof PortletMessageType) { 73 PortletMessageType comp = (PortletMessageType)obj; 74 return name.equals(comp.name); 75 } else { 76 return false; 77 } 78 } 79 } 80 | Popular Tags |