1 16 package org.directwebremoting.proxy; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.Iterator ; 21 import java.util.List ; 22 23 import org.directwebremoting.ScriptBuffer; 24 import org.directwebremoting.ScriptSession; 25 26 32 public class ScriptProxy 33 { 34 37 public ScriptProxy() 38 { 39 } 40 41 45 public ScriptProxy(ScriptSession scriptSession) 46 { 47 scriptSessions.add(scriptSession); 48 } 49 50 54 public ScriptProxy(Collection scriptSessions) 55 { 56 this.scriptSessions.addAll(scriptSessions); 57 } 58 59 62 public void addScriptSession(ScriptSession scriptSession) 63 { 64 scriptSessions.add(scriptSession); 65 } 66 67 70 public void addScriptSessions(Collection addScriptSessions) 71 { 72 scriptSessions.addAll(addScriptSessions); 73 } 74 75 79 public void addFunctionCall(String funcName) 80 { 81 ScriptBuffer script = new ScriptBuffer(); 82 script.appendScript(funcName) 83 .appendScript("();"); 84 addScript(script); 85 } 86 87 92 public void addFunctionCall(String funcName, Object param1) 93 { 94 ScriptBuffer script = new ScriptBuffer(); 95 script.appendScript(funcName) 96 .appendScript("(") 97 .appendData(param1) 98 .appendScript(");"); 99 addScript(script); 100 } 101 102 108 public void addFunctionCall(String funcName, Object param1, Object param2) 109 { 110 ScriptBuffer script = new ScriptBuffer(); 111 script.appendScript(funcName) 112 .appendScript("(") 113 .appendData(param1) 114 .appendScript(",") 115 .appendData(param2) 116 .appendScript(");"); 117 addScript(script); 118 } 119 120 127 public void addFunctionCall(String funcName, Object param1, Object param2, Object param3) 128 { 129 ScriptBuffer script = new ScriptBuffer(); 130 script.appendScript(funcName) 131 .appendScript("(") 132 .appendData(param1) 133 .appendScript(",") 134 .appendData(param2) 135 .appendScript(",") 136 .appendData(param3) 137 .appendScript(");"); 138 addScript(script); 139 } 140 141 149 public void addFunctionCall(String funcName, Object param1, Object param2, Object param3, Object param4) 150 { 151 ScriptBuffer script = new ScriptBuffer(); 152 script.appendScript(funcName) 153 .appendScript("(") 154 .appendData(param1) 155 .appendScript(",") 156 .appendData(param2) 157 .appendScript(",") 158 .appendData(param3) 159 .appendScript(",") 160 .appendData(param4) 161 .appendScript(");"); 162 addScript(script); 163 } 164 165 174 public void addFunctionCall(String funcName, Object param1, Object param2, Object param3, Object param4, Object param5) 175 { 176 ScriptBuffer script = new ScriptBuffer(); 177 script.appendScript(funcName) 178 .appendScript("(") 179 .appendData(param1) 180 .appendScript(",") 181 .appendData(param2) 182 .appendScript(",") 183 .appendData(param3) 184 .appendScript(",") 185 .appendData(param4) 186 .appendScript(",") 187 .appendData(param5) 188 .appendScript(");"); 189 addScript(script); 190 } 191 192 196 public void addScript(ScriptBuffer script) 197 { 198 for (Iterator it = scriptSessions.iterator(); it.hasNext();) 199 { 200 ScriptSession scriptSession = (ScriptSession) it.next(); 201 scriptSession.addScript(script); 202 } 203 } 204 205 208 private final List scriptSessions = new ArrayList (); 209 } 210 | Popular Tags |