001    /**
002     * 
003     */
004    package railo.runtime.type.scope;
005    
006    import java.io.UnsupportedEncodingException;
007    import java.util.Iterator;
008    
009    import javax.servlet.ServletInputStream;
010    
011    import org.apache.commons.fileupload.disk.DiskFileItem;
012    
013    import railo.runtime.PageContext;
014    import railo.runtime.dump.DumpData;
015    import railo.runtime.dump.DumpProperties;
016    import railo.runtime.exp.PageException;
017    import railo.runtime.type.Collection;
018    import railo.runtime.type.dt.DateTime;
019    import railo.runtime.type.scope.FormImpl.Item;
020    import railo.runtime.type.util.StructSupport;
021    
022    /**
023     * 
024     */
025    public final class UrlFormImpl extends StructSupport implements URLForm,FormUpload {
026    
027            private FormImpl form;
028            private URLImpl url;
029            private boolean isInit;
030    
031            public UrlFormImpl(FormImpl form, URLImpl url) {
032                    this.form=form;
033                    this.url=url;
034            }
035            
036            /**
037             * @see railo.runtime.type.Scope#initialize(railo.runtime.PageContext)
038             */
039            public void initialize(PageContext pc) {
040                    if(isInit) return;
041                    isInit=true;
042                    form.initialize(pc);
043                    url.initialize(pc);
044                    //print.ln(">>>"+List.arrayToList(url.keys(),","));
045                    form.addRaw(url.getRaw());
046                    
047                    /*String[] keys = url.keys();
048                    for(int i=0;i<keys.length;i++) {
049                            form.setEL(keys[i], url.get(keys[i],null));
050                    }*/
051            }
052            /**
053             *
054             * @see railo.runtime.type.Scope#release()
055             */
056            public void release() {
057                    isInit=false;
058                    form.release();
059                    url.release();
060            }
061    
062    
063            /* *
064             * @see railo.runtime.type.scope.URLForm#getForm()
065             * /
066            public Form getForm() {
067                    return form;
068            }*/
069    
070            /* *
071             *
072             * @see railo.runtime.type.scope.URLForm#getURL()
073             * /
074            public URL getURL() {
075                    return url;
076            }*/
077    
078            /**
079             *
080             * @see railo.runtime.type.scope.URL#getEncoding()
081             */
082            public String getEncoding() {
083                    return form.getEncoding();
084            }
085    
086            /**
087             *
088             * @see railo.runtime.type.scope.URL#setEncoding(java.lang.String)
089             */
090            public void setEncoding(String encoding)throws UnsupportedEncodingException {
091                    form.setEncoding(encoding);
092            }
093    
094            /**
095             *
096             * @see railo.runtime.type.Scope#getType()
097             */
098            public int getType() {
099                    return form.getType();
100            }
101    
102            /**
103             *
104             * @see railo.runtime.type.Scope#getTypeAsString()
105             */
106            public String getTypeAsString() {
107                    return form.getTypeAsString();
108            }
109    
110            /**
111             *
112             * @see railo.runtime.type.Scope#isInitalized()
113             */
114            public boolean isInitalized() {
115                    return isInit;
116            }
117    
118            /**
119             *
120             * @see railo.runtime.type.Collection#clear()
121             */
122            public void clear() {
123                    form.clear();
124                    url.clear();
125            }
126    
127            /**
128             * @see railo.runtime.type.Collection#containsKey(railo.runtime.type.Collection.Key)
129             */
130            public boolean containsKey(Collection.Key key) {
131                    return form.containsKey(key);
132            }
133    
134            /**
135             *
136             * @see railo.runtime.type.Collection#get(railo.runtime.type.Collection.Key)
137             */
138            public Object get(Collection.Key key) throws PageException {
139                    return form.get(key);
140            }
141    
142            /**
143             *
144             * @see railo.runtime.type.Collection#get(railo.runtime.type.Collection.Key, java.lang.Object)
145             */
146            public Object get(Collection.Key key, Object defaultValue) {
147                    return form.get(key, defaultValue);
148            }
149    
150            /**
151             *
152             * @see railo.runtime.type.Collection#keyIterator()
153             */
154            public Iterator keyIterator() {
155                    return form.keyIterator();
156            }
157    
158            /**
159             *
160             * @see railo.runtime.type.Collection#keysAsString()
161             */
162            public String[] keysAsString() {
163                    return form.keysAsString();
164            }
165    
166            /**
167             * @see railo.runtime.type.Collection#keys()
168             */
169            public Collection.Key[] keys() {
170                    return form.keys();
171            }
172    
173            /**
174             *
175             * @see railo.runtime.type.Collection#remove(railo.runtime.type.Collection.Key)
176             */
177            public Object remove(Collection.Key key) throws PageException {
178                    return form.remove(key);
179            }
180    
181            /**
182             *
183             * @see railo.runtime.type.Collection#removeEL(railo.runtime.type.Collection.Key)
184             */
185            public Object removeEL(Collection.Key key) {
186                    return form.removeEL(key);
187            }
188    
189            /**
190             * @see railo.runtime.type.Collection#set(railo.runtime.type.Collection.Key, java.lang.Object)
191             */
192            public Object set(Collection.Key key, Object value) throws PageException {
193                    return form.set(key, value);
194            }
195    
196            /**
197             * @see railo.runtime.type.Collection#setEL(railo.runtime.type.Collection.Key, java.lang.Object)
198             */
199            public Object setEL(Collection.Key key, Object value) {
200                    return form.setEL(key, value);
201            }
202    
203            /**
204             *
205             * @see railo.runtime.type.Collection#size()
206             */
207            public int size() {
208                    return form.size();
209            }
210    
211            /**
212             * @see railo.runtime.dump.Dumpable#toDumpData(railo.runtime.PageContext, int)
213             */
214            public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
215                    return form.toDumpData(pageContext, maxlevel,dp);
216            }
217    
218            /**
219             * @see railo.runtime.op.Castable#castToBooleanValue()
220             */
221            public boolean castToBooleanValue() throws PageException {
222                    return form.castToBooleanValue();
223            }
224        
225        /**
226         * @see railo.runtime.op.Castable#castToBoolean(java.lang.Boolean)
227         */
228        public Boolean castToBoolean(Boolean defaultValue) {
229            return form.castToBoolean(defaultValue);
230        }
231    
232            /**
233             *
234             * @see railo.runtime.op.Castable#castToDateTime()
235             */
236            public DateTime castToDateTime() throws PageException {
237                    return form.castToDateTime();
238            }
239        
240        /**
241         * @see railo.runtime.op.Castable#castToDateTime(railo.runtime.type.dt.DateTime)
242         */
243        public DateTime castToDateTime(DateTime defaultValue) {
244            return form.castToDateTime(defaultValue);
245        }
246    
247            /**
248             *
249             * @see railo.runtime.op.Castable#castToDoubleValue()
250             */
251            public double castToDoubleValue() throws PageException {
252                    return form.castToDoubleValue();
253            }
254        
255        /**
256         * @see railo.runtime.op.Castable#castToDoubleValue(double)
257         */
258        public double castToDoubleValue(double defaultValue) {
259            return form.castToDoubleValue(defaultValue);
260        }
261    
262            /**
263             *
264             * @see railo.runtime.op.Castable#castToString()
265             */
266            public String castToString() throws PageException {
267                    return form.castToString();
268            }
269            
270            /**
271             * @see railo.runtime.type.util.StructSupport#castToString(java.lang.String)
272             */
273            public String castToString(String defaultValue) {
274                    return form.castToString(defaultValue);
275            }
276    
277    
278            /**
279             * @throws PageException 
280             * @see railo.runtime.op.Castable#compare(boolean)
281             */
282            public int compareTo(boolean b) throws PageException {
283                    return form.compareTo(b);
284            }
285    
286            /**
287             * @see railo.runtime.op.Castable#compareTo(railo.runtime.type.dt.DateTime)
288             */
289            public int compareTo(DateTime dt) throws PageException {
290                    return form.compareTo(dt);
291            }
292    
293            /**
294             * @see railo.runtime.op.Castable#compareTo(double)
295             */
296            public int compareTo(double d) throws PageException {
297                    return form.compareTo(d);
298            }
299    
300            /**
301             * @see railo.runtime.op.Castable#compareTo(java.lang.String)
302             */
303            public int compareTo(String str) throws PageException {
304                    return form.compareTo(str);
305            }
306    
307            /**
308             *
309             * @see railo.runtime.type.scope.Form#getFileUpload(java.lang.String)
310             */
311            public DiskFileItem getFileUpload(String key) {
312                    return form.getFileUpload(key);
313            }
314    
315            /**
316             *
317             * @see railo.runtime.type.scope.Form#getInitException()
318             */
319            public PageException getInitException() {
320                    return form.getInitException();
321            }
322    
323            /**
324             * @see railo.runtime.type.Collection#duplicate(boolean)
325             */
326            public Collection duplicate(boolean deepCopy) {
327                    return form.duplicate(deepCopy);
328            }
329            
330    
331    
332            /**
333             * @see railo.runtime.type.scope.URL#setScriptProtecting(boolean)
334             */
335            public void setScriptProtecting(boolean b) {
336                    form.setScriptProtecting(b);
337            }
338    
339            /**
340             * @see java.util.Map#containsValue(java.lang.Object)
341             */
342            public boolean containsValue(Object value) {
343                    return form.containsValue(value);
344            }
345    
346            /**
347             * @see java.util.Map#values()
348             */
349            public java.util.Collection values() {
350                    return form.values();
351            }
352    
353            public Item getUploadResource(String key) {
354                    return form.getUploadResource(key);
355            }
356    
357            public Item[] getFileItems() {
358                    return form.getFileItems();
359            }
360    
361            public ServletInputStream getInputStream() {
362                    return form.getInputStream();
363            }
364    }