001    /**
002     * 
003     */
004    package railo.runtime;
005    
006    import java.util.Iterator;
007    import java.util.Map;
008    import java.util.Set;
009    
010    import railo.commons.lang.types.RefBoolean;
011    import railo.runtime.component.DataMember;
012    import railo.runtime.component.Member;
013    import railo.runtime.component.MemberSupport;
014    import railo.runtime.component.Property;
015    import railo.runtime.dump.DumpData;
016    import railo.runtime.dump.DumpProperties;
017    import railo.runtime.exp.PageException;
018    import railo.runtime.type.Collection;
019    import railo.runtime.type.KeyImpl;
020    import railo.runtime.type.Sizeable;
021    import railo.runtime.type.Struct;
022    import railo.runtime.type.StructImpl;
023    import railo.runtime.type.dt.DateTime;
024    import railo.runtime.type.util.StructUtil;
025    
026    /**
027     * 
028     */
029    public class SuperComponent extends MemberSupport implements ComponentPro, Member,Sizeable {
030            
031            private ComponentImpl comp;
032    
033            private SuperComponent(ComponentImpl comp) {
034                    super(Component.ACCESS_PRIVATE);
035                    this.comp=comp;
036            }
037            
038    
039            public static Member superMember(ComponentImpl comp) {
040                    if(comp==null) return new DataMember(Component.ACCESS_PRIVATE,new StructImpl());
041            return new SuperComponent(comp);
042            }
043            public static Collection superInstance(ComponentImpl comp) {
044                    if(comp==null) return new StructImpl();
045            return new SuperComponent(comp);
046            }
047    
048            /**
049             * @see railo.runtime.component.Member#getValue()
050             */
051            public Object getValue() {
052                    return this;
053            }
054            /**
055             *
056             * @see railo.runtime.ComponentImpl#call(railo.runtime.PageContext, java.lang.String, java.lang.Object[])
057             */
058            public Object call(PageContext pc, String name, Object[] args) throws PageException {
059                    return comp._call(pc, getAccess(), KeyImpl.init(name), null, args,true);
060            }
061    
062            /**
063             *
064             * @see railo.runtime.ComponentImpl#call(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object[])
065             */
066            public Object call(PageContext pc, Key name, Object[] args) throws PageException {
067                    return comp._call(pc, getAccess(), name, null, args,true);
068            }
069    
070            /**
071             *
072             * @see railo.runtime.ComponentImpl#callWithNamedValues(railo.runtime.PageContext, java.lang.String, railo.runtime.type.Struct)
073             */
074            public Object callWithNamedValues(PageContext pc, String name, Struct args) throws PageException {
075                    return comp._call(pc, getAccess(), KeyImpl.init(name), args,null,true);
076            }
077    
078            /**
079             *
080             * @see railo.runtime.ComponentImpl#callWithNamedValues(railo.runtime.PageContext, railo.runtime.type.Collection.Key, railo.runtime.type.Struct)
081             */
082            public Object callWithNamedValues(PageContext pc, Key methodName, Struct args) throws PageException {
083                    return comp._call(pc, getAccess(), methodName, args,null,true);
084            }
085            
086            /**
087             *
088             * @see railo.runtime.ComponentImpl#castToBooleanValue()
089             */
090            public boolean castToBooleanValue() throws PageException {
091                    return comp.castToBooleanValue(true);
092            }
093        
094        /**
095         * @see railo.runtime.op.Castable#castToBoolean(java.lang.Boolean)
096         */
097        public Boolean castToBoolean(Boolean defaultValue) {
098            return comp.castToBoolean(true,defaultValue);
099        }
100    
101            /**
102             *
103             * @see railo.runtime.ComponentImpl#castToDateTime()
104             */
105            public DateTime castToDateTime() throws PageException {
106                    return comp.castToDateTime(true);
107            }
108        
109        /**
110         * @see railo.runtime.op.Castable#castToDateTime(railo.runtime.type.dt.DateTime)
111         */
112        public DateTime castToDateTime(DateTime defaultValue) {
113            return comp.castToDateTime(true,defaultValue);
114        }
115    
116            /**
117             *
118             * @see railo.runtime.ComponentImpl#castToDoubleValue()
119             */
120            public double castToDoubleValue() throws PageException {
121                    return comp.castToDoubleValue(true);
122            }
123        
124        /**
125         * @see railo.runtime.op.Castable#castToDoubleValue(double)
126         */
127        public double castToDoubleValue(double defaultValue) {
128            return comp.castToDoubleValue(true,defaultValue);
129        }
130    
131            /**
132             *
133             * @see railo.runtime.ComponentImpl#castToString()
134             */
135            public String castToString() throws PageException {
136                    return comp.castToString(true);
137            }
138    
139            /**
140             * @see railo.runtime.op.Castable#castToString(java.lang.String)
141             */
142            public String castToString(String defaultValue) {
143                    return comp.castToString(true,defaultValue);
144            }
145    
146            /**
147             *
148             * @see railo.runtime.ComponentImpl#clear()
149             */
150            public void clear() {
151                    comp.clear();
152            }
153    
154            /**
155             *
156             * @see railo.runtime.Component#clone()
157             */
158            public Object clone() {
159                    return duplicate(true);
160            }
161    
162            /**
163             *
164             * @see railo.runtime.ComponentImpl#compareTo(boolean)
165             */
166            public int compareTo(boolean b) throws PageException {
167                    return comp.compareTo(b);
168            }
169    
170            /**
171             *
172             * @see railo.runtime.ComponentImpl#compareTo(railo.runtime.type.dt.DateTime)
173             */
174            public int compareTo(DateTime dt) throws PageException {
175                    return comp.compareTo(dt);
176            }
177    
178            /**
179             *
180             * @see railo.runtime.ComponentImpl#compareTo(double)
181             */
182            public int compareTo(double d) throws PageException {
183                    return comp.compareTo(d);
184            }
185    
186            /**
187             *
188             * @see railo.runtime.ComponentImpl#compareTo(java.lang.String)
189             */
190            public int compareTo(String str) throws PageException {
191                    return comp.compareTo(str);
192            }
193    
194            /**
195             *
196             * @see railo.runtime.ComponentImpl#containsKey(java.lang.String)
197             */
198            public boolean containsKey(String name) {
199                    return comp.contains(getAccess(),(name));
200            }
201    
202            /**
203             *
204             * @see railo.runtime.ComponentImpl#containsKey(railo.runtime.type.Collection.Key)
205             */
206            public boolean containsKey(Key key) {
207                    return comp.contains(getAccess(),key.getLowerString());
208            }
209    
210            /**
211             *
212             * @see railo.runtime.ComponentImpl#duplicate(boolean)
213             */
214            public synchronized Collection duplicate(boolean deepCopy) {
215                    return new SuperComponent((ComponentImpl) comp.duplicate(deepCopy));
216            }
217    
218            /**
219             *
220             * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, railo.runtime.type.Collection.Key)
221             */
222            public Object get(PageContext pc, Key key) throws PageException {
223                    return get(key);
224            }
225    
226            /**
227             *
228             * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object)
229             */
230            public Object get(PageContext pc, Key key, Object defaultValue) {
231                    return get(key, defaultValue);
232            }
233            
234    
235            /**
236             *
237             * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, java.lang.String)
238             */
239            public Object get(PageContext pc, String name) throws PageException {
240                    return get(KeyImpl.init(name));
241            }
242    
243            /**
244             *
245             * @see railo.runtime.ComponentImpl#get(railo.runtime.PageContext, java.lang.String, java.lang.Object)
246             */
247            public Object get(PageContext pc, String name, Object defaultValue) {
248                    return get(KeyImpl.init(name),defaultValue);
249            }
250    
251            /**
252             *
253             * @see railo.runtime.ComponentImpl#get(java.lang.String)
254             */
255            public Object get(String name) throws PageException {
256                    return get(KeyImpl.init(name));
257            }
258    
259            /**
260             *
261             * @see railo.runtime.ComponentImpl#get(java.lang.String, java.lang.Object)
262             */
263            public Object get(String name, Object defaultValue) {
264                    return get(KeyImpl.init(name), defaultValue);
265            }
266    
267            /**
268             *
269             * @see railo.runtime.ComponentImpl#get(railo.runtime.type.Collection.Key)
270             */
271            public Object get(Key key) throws PageException {
272                    Member member=comp.getMember(getAccess(),key,true,true);
273            if(member!=null) return member.getValue();
274            return comp.get(getAccess(), key);
275            }
276    
277            /**
278             *
279             * @see railo.runtime.ComponentImpl#get(railo.runtime.type.Collection.Key, java.lang.Object)
280             */
281            public Object get(Key key, Object defaultValue) {
282                    Member member=getMember(getAccess(),key,true,true);
283            if(member!=null) return member.getValue();
284                    return comp.get(getAccess(), key, defaultValue);
285            }
286    
287            /**
288             *
289             * @see railo.runtime.ComponentImpl#getAbsName()
290             */
291            public String getAbsName() {
292                    return comp.getAbsName();
293            }
294        
295        /**
296         * @see railo.runtime.ComponentPro#getBaseAbsName()
297         */
298        public String getBaseAbsName() {
299            return comp.getBaseAbsName();
300        }
301        
302        public boolean isBasePeristent() {
303                    return comp.isPersistent();
304            }
305    
306            /**
307             *
308             * @see railo.runtime.ComponentImpl#getCallName()
309             */
310            public String getCallName() {
311                    return comp.getCallName();
312            }
313    
314            /**
315             *
316             * @see railo.runtime.ComponentImpl#getDisplayName()
317             */
318            public String getDisplayName() {
319                    return comp.getDisplayName();
320            }
321    
322            /**
323             *
324             * @see railo.runtime.ComponentImpl#getExtends()
325             */
326            public String getExtends() {
327                    return comp.getExtends();
328            }
329    
330            /**
331             *
332             * @see railo.runtime.ComponentImpl#getHint()
333             */
334            public String getHint() {
335                    return comp.getHint();
336            }
337    
338            /**
339             *
340             * @see railo.runtime.ComponentImpl#getJavaAccessClass(railo.commons.lang.types.RefBoolean)
341             */
342            public Class getJavaAccessClass(RefBoolean isNew) throws PageException {
343                    return comp.getJavaAccessClass(isNew);
344            }
345    
346            /**
347             *
348             * @see railo.runtime.ComponentImpl#getMetaData(railo.runtime.PageContext)
349             */
350            public synchronized Struct getMetaData(PageContext pc) throws PageException {
351                    return comp.getMetaData(pc);
352            }
353    
354            /**
355             *
356             * @see railo.runtime.ComponentImpl#getName()
357             */
358            public String getName() {
359                    return comp.getName();
360            }
361    
362            /**
363             *
364             * @see railo.runtime.ComponentImpl#getOutput()
365             */
366            public boolean getOutput() {
367                    return comp.getOutput();
368            }
369    
370            /**
371             *
372             * @see railo.runtime.ComponentImpl#instanceOf(java.lang.String)
373             */
374            public boolean instanceOf(String type) {
375                    return comp.top.instanceOf(type);
376            }
377    
378            /**
379             *
380             * @see railo.runtime.ComponentImpl#isInitalized()
381             */
382            public boolean isInitalized() {
383                    return comp.top.isInitalized();
384            }
385    
386            /**
387             *
388             * @see railo.runtime.ComponentImpl#isValidAccess(int)
389             */
390            public boolean isValidAccess(int access) {
391                    return comp.isValidAccess(access);
392            }
393    
394            /**
395             *
396             * @see railo.runtime.ComponentImpl#iterator()
397             */
398            public Iterator iterator() {
399                    return comp.iterator();
400            }
401    
402            /**
403             *
404             * @see railo.runtime.ComponentImpl#keyIterator()
405             */
406            public Iterator keyIterator() {
407                    return comp.keyIterator();
408            }
409    
410            /**
411             *
412             * @see railo.runtime.ComponentImpl#keys()
413             */
414            public Key[] keys() {
415                    return comp.keys(getAccess());
416            }
417    
418            /**
419             *
420             * @see railo.runtime.ComponentImpl#keysAsString()
421             */
422            public String[] keysAsString() {
423                    return comp.keysAsString(getAccess());
424            }
425    
426            /**
427             *
428             * @see railo.runtime.ComponentImpl#remove(railo.runtime.type.Collection.Key)
429             */
430            public Object remove(Key key) throws PageException {
431                    return comp.remove(key);
432            }
433    
434    
435            /**
436             *
437             * @see railo.runtime.ComponentImpl#removeEL(railo.runtime.type.Collection.Key)
438             */
439            public Object removeEL(Key key) {
440                    return comp.removeEL(key);
441            }
442    
443            /**
444             *
445             * @see railo.runtime.ComponentImpl#set(railo.runtime.PageContext, java.lang.String, java.lang.Object)
446             */
447            public Object set(PageContext pc, String name, Object value) throws PageException {
448                    return comp.set(pc, name, value);
449            }
450    
451            /**
452             *
453             * @see railo.runtime.ComponentImpl#set(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object)
454             */
455            public Object set(PageContext pc, Key key, Object value) throws PageException {
456                    return comp.set(pc, key, value);
457            }
458    
459            /**
460             *
461             * @see railo.runtime.ComponentImpl#set(java.lang.String, java.lang.Object)
462             */
463            public Object set(String name, Object value) throws PageException {
464                    return comp.set(name, value);
465            }
466    
467            /**
468             *
469             * @see railo.runtime.ComponentImpl#set(railo.runtime.type.Collection.Key, java.lang.Object)
470             */
471            public Object set(Key key, Object value) throws PageException {
472                    return comp.set(key, value);
473            }
474    
475            /**
476             *
477             * @see railo.runtime.ComponentImpl#setEL(railo.runtime.PageContext, java.lang.String, java.lang.Object)
478             */
479            public Object setEL(PageContext pc, String name, Object value) {
480                    return comp.setEL(pc, name, value);
481            }
482    
483            /**
484             *
485             * @see railo.runtime.ComponentImpl#setEL(railo.runtime.PageContext, railo.runtime.type.Collection.Key, java.lang.Object)
486             */
487            public Object setEL(PageContext pc, Key name, Object value) {
488                    return comp.setEL(pc, name, value);
489            }
490    
491            /**
492             *
493             * @see railo.runtime.ComponentImpl#setEL(java.lang.String, java.lang.Object)
494             */
495            public Object setEL(String name, Object value) {
496                    return comp.setEL(name, value);
497            }
498    
499            /**
500             *
501             * @see railo.runtime.ComponentImpl#setEL(railo.runtime.type.Collection.Key, java.lang.Object)
502             */
503            public Object setEL(Key key, Object value) {
504                    return comp.setEL(key, value);
505            }
506    
507            /**
508             *
509             * @see railo.runtime.ComponentImpl#size()
510             */
511            public int size() {
512                    return comp.size(getAccess());
513            }
514    
515            /**
516             *
517             * @see railo.runtime.ComponentImpl#toDumpData(railo.runtime.PageContext, int)
518             */
519            public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
520                    return comp.top.toDumpData(pageContext, maxlevel,dp);
521            }
522    
523    
524            public Page getPage() {
525                    return comp.getPage();
526            }
527            
528            /**
529             * @see railo.runtime.ComponentPro#getPageSource()
530             */
531            public PageSource getPageSource() {
532                    return comp.getPageSource();
533            }
534    
535    
536            /**
537             * @see java.util.Map#containsKey(java.lang.Object)
538             */
539            public boolean containsKey(Object key) {
540                    return containsKey(KeyImpl.toKey(key,null));
541            }
542    
543    
544            /**
545             * @see java.util.Map#entrySet()
546             */
547            public Set entrySet() {
548                    return StructUtil.entrySet(this);
549            }
550    
551    
552            /**
553             * @see java.util.Map#get(java.lang.Object)
554             */
555            public Object get(Object key) {
556                    return get(KeyImpl.toKey(key,null), null);
557            }
558    
559    
560            /**
561             * @see java.util.Map#isEmpty()
562             */
563            public boolean isEmpty() {
564                    return size()==0;
565            }
566    
567            /**
568             * @see java.util.Map#keySet()
569             */
570            public Set keySet() {
571                    return StructUtil.keySet(this);
572            }
573    
574    
575            /**
576             * @see java.util.Map#put(K, V)
577             */
578            public Object put(Object key, Object value) {
579                    return setEL(KeyImpl.toKey(key,null), value);
580            }
581    
582            /**
583             * @see java.util.Map#putAll(java.util.Map)
584             */
585            public void putAll(Map map) {
586                    StructUtil.putAll(this, map);
587            }
588    
589            /**
590             * @see java.util.Map#remove(java.lang.Object)
591             */
592            public Object remove(Object key) {
593                    return removeEL(KeyImpl.toKey(key,null));
594            }
595    
596            /**
597             * @see java.util.Map#values()
598             */
599            public java.util.Collection values() {
600                    return StructUtil.values(this);
601            }
602    
603            /**
604             * @see java.util.Map#containsValue(java.lang.Object)
605             */
606            public boolean containsValue(Object value) {
607                    return values().contains(value);
608            }
609    
610    
611            public Iterator valueIterator() {
612                    return comp.valueIterator();
613            }
614    
615            /**
616             * @see railo.runtime.ComponentPro#getProperties()
617             */
618            public Property[] getProperties(boolean onlyPeristent) {
619                    return comp.getProperties(onlyPeristent);
620            }
621    
622            /**
623             * @see railo.runtime.ComponentPro#getComponentScope()
624             */
625            public ComponentScope getComponentScope() {
626                    return comp.getComponentScope();
627            }
628    
629            /**
630             * @see railo.runtime.ComponentPro#contains(railo.runtime.PageContext, railo.runtime.type.Collection.Key)
631             */
632            public boolean contains(PageContext pc, Key key) {
633                    return comp.contains(getAccess(),key);
634            }
635    
636            /**
637             * @see railo.runtime.ComponentPro#getMember(int, railo.runtime.type.Collection.Key, boolean, boolean)
638             */
639            public Member getMember(int access, Key key, boolean dataMember,boolean superAccess) {
640                    return comp.getMember(access, key, dataMember, superAccess);
641            }
642    
643            /**
644             * @see railo.runtime.ComponentPro#setProperty(railo.runtime.component.Property)
645             */
646            public void setProperty(Property property) throws PageException {
647                    comp.setProperty(property);
648            }
649    
650    
651            /**
652             * @see railo.runtime.type.Sizeable#sizeOf()
653             */
654            public long sizeOf() {
655                    return StructUtil.sizeOf(this);
656            }
657    
658    
659            public boolean equalTo(String type) {
660                    return comp.top.equalTo(type);
661            }
662    
663            /**
664             * @see railo.runtime.ComponentPro#getWSDLFile()
665             */
666            public String getWSDLFile() {
667                    return comp.getWSDLFile();
668            }
669            
670    }