1 23 24 package com.sun.enterprise.tools.guiframework.event.descriptors; 25 26 import com.iplanet.jato.RequestContext; 27 28 import com.sun.enterprise.tools.guiframework.FrameworkDescriptor; 29 import com.sun.enterprise.tools.guiframework.exception.FrameworkException; 30 import com.sun.enterprise.tools.guiframework.util.PermissionChecker; 31 import com.sun.enterprise.tools.guiframework.util.Util; 32 import com.sun.enterprise.tools.guiframework.view.descriptors.ViewDescriptor; 33 34 import java.lang.reflect.Method ; 35 import java.util.EventObject ; 36 import java.util.HashMap ; 37 import java.util.Map ; 38 39 40 46 public class UseHandlerDescriptor implements FrameworkDescriptor { 47 48 53 public UseHandlerDescriptor(FrameworkDescriptor parent, HandlerDescriptor handlerDesc) { 54 setParent(parent); 55 setHandlerDescriptor(handlerDesc); 56 } 57 58 59 64 public FrameworkDescriptor getParent() { 65 return _parent; 66 } 67 68 69 72 public HandlerDescriptor getHandlerDescriptor() { 73 return _handler; 74 } 75 76 77 82 protected void setParent(FrameworkDescriptor parent) { 83 if (parent == null) { 84 throw new FrameworkException("You must provide a the " + 85 "FrameworkDescriptor which contains this " + 86 "UseHandlerDescriptor!"); 87 } 88 _parent = parent; 89 } 90 91 92 95 protected void setHandlerDescriptor(HandlerDescriptor handler) { 96 _handler = handler; 97 } 98 99 100 103 public String getIfCheck() { 104 return _ifCheck; 105 } 106 107 108 111 public void setIfCheck(String ifCheck) { 112 _ifCheck = ifCheck; 113 } 114 115 116 128 public boolean hasPermission(ViewDescriptor vd) { 129 String ifCheck = getIfCheck(); 131 if ((ifCheck == null) || (ifCheck.trim().length() == 0)) { 132 return true; 134 } 135 136 return new PermissionChecker(ifCheck, vd).hasPermission(); 138 } 139 140 141 144 public void setInputValue(String name, Object value) { 145 _inputs.put(name, value); 146 } 147 148 149 152 public Object getInputValue(String name) { 153 return _inputs.get(name); 154 } 155 156 157 160 public void setOutputMapping(String name, String targetKey, String targetType) { 161 if ((name == null) || (name.length() == 0)) { 162 throw new FrameworkException("Name is required!"); 163 } 164 if (targetKey != null) { 165 targetKey = targetKey.trim(); 166 if (targetKey.length() == 0) { 167 targetKey = null; 168 } 169 } 170 if (targetType != null) { 171 targetType = targetType.trim(); 172 if (targetType.length() == 0) { 173 targetType = null; 174 } 175 } 176 String outputDesc[] = new String [2]; 177 outputDesc[0] = targetKey; 178 outputDesc[1] = targetType; 179 _outputs.put(name, outputDesc); 180 } 181 182 183 186 public Object getOutputTargetKey(String name) { 187 return ((String [])_outputs.get(name))[0]; 188 } 189 190 191 194 public Object getOutputTargetType(String name) { 195 return ((String [])_outputs.get(name))[1]; 196 } 197 198 199 202 public String [] getOutputMapping(String name) { 203 return (String [])_outputs.get(name); 204 } 205 206 207 private FrameworkDescriptor _parent = null; 208 private String _ifCheck = null; 209 private HandlerDescriptor _handler = null; 210 private Map _inputs = new HashMap (); 211 private Map _outputs = new HashMap (); 212 } 213 | Popular Tags |