1 53 54 55 package org.exoplatform.services.wsrp.utils; 56 57 import javax.portlet.PortletMode; 58 59 public class Modes implements java.io.Serializable { 60 private java.lang.String _value_; 61 private static java.util.HashMap _table_ = new java.util.HashMap (); 62 63 protected Modes(java.lang.String value) { 65 _value_ = value; 66 _table_.put(_value_, this); 67 } 68 69 public static final java.lang.String _view = "wsrp:view"; 71 public static final java.lang.String _edit = "wsrp:edit"; 72 public static final java.lang.String _help = "wsrp:help"; 73 public static final java.lang.String _preview = "wsrp:preview"; 74 public static final Modes view = new Modes(_view); 75 public static final Modes edit = new Modes(_edit); 76 public static final Modes help = new Modes(_help); 77 public static final Modes preview = new Modes(_preview); 78 79 public java.lang.String getValue() { 80 return _value_; 81 } 82 83 90 public static Modes fromValue(java.lang.String value) { 91 return (Modes) _table_.get(value); 92 } 93 94 101 public static Modes fromString(java.lang.String value) { 102 return fromValue(value); 103 } 104 105 public boolean equals(java.lang.Object obj) { 106 return (obj == this); 107 } 108 109 public int hashCode() { 110 return toString().hashCode(); 111 } 112 113 public java.lang.String toString() { 114 return _value_; 115 } 116 117 public java.lang.Object readResolve() throws java.io.ObjectStreamException { 118 return fromValue(_value_); 119 } 120 121 128 public static PortletMode getJsrPortletModeFromWsrpMode(Modes wsrpMode) { 129 if (wsrpMode == null) { 130 return PortletMode.VIEW; 131 } else if (wsrpMode.equals(Modes.edit)) { 132 return PortletMode.EDIT; 133 } else if (wsrpMode.equals(Modes.help)) { 134 return PortletMode.HELP; 135 } else if (wsrpMode.equals(Modes.view)) { 136 return PortletMode.VIEW; 137 } 138 139 return PortletMode.VIEW; 140 } 141 142 151 public static Modes getWsrpModeFromJsrPortletMode(PortletMode portletMode) { 152 if (portletMode == null) { 153 throw new IllegalArgumentException ("Portlet mode must not be null."); 154 } 155 if (portletMode.equals(PortletMode.EDIT)) { 156 return Modes.edit; 157 } else if (portletMode.equals(PortletMode.HELP)) { 158 return Modes.help; 159 } else if (portletMode.equals(PortletMode.VIEW)) { 160 return Modes.view; 161 } 162 return Modes.view; 163 } 164 } 165 | Popular Tags |