001    package railo.runtime.type.scope;
002    
003    import java.util.Iterator;
004    
005    import railo.runtime.PageContext;
006    import railo.runtime.dump.DumpData;
007    import railo.runtime.dump.DumpProperties;
008    import railo.runtime.exp.ExpressionException;
009    import railo.runtime.exp.PageException;
010    import railo.runtime.exp.PageRuntimeException;
011    import railo.runtime.type.Collection;
012    import railo.runtime.type.Scope;
013    import railo.runtime.type.dt.DateTime;
014    import railo.runtime.type.util.StructSupport;
015    
016    /**
017     * 
018     */
019    public final class LocalNotSupportedScope extends StructSupport implements Scope,LocalPro {
020            
021            private static final long serialVersionUID = 6670210379924188569L;
022            
023            private static LocalNotSupportedScope instance=new LocalNotSupportedScope();
024            private boolean bind;
025            
026            private LocalNotSupportedScope(){}
027            
028            public static LocalNotSupportedScope getInstance() {
029                    return instance;
030            }
031            
032            /**
033             * @see railo.runtime.type.Collection#size()
034             */
035            public int size() {
036                    return 0;
037            }
038            /**
039             * @see railo.runtime.type.Collection#keysAsString()
040             */
041            public String[] keysAsString() {
042                    return null;
043            }
044            
045            /**
046             * @see railo.runtime.type.Collection#keys()
047             */
048            public Collection.Key[] keys() {
049                    return null;
050            }
051            
052            /**
053             *
054             * @see railo.runtime.type.Collection#removeEL(railo.runtime.type.Collection.Key)
055             */
056            public Object removeEL(Key key) {
057                    // TODO Auto-generated method stub
058                    return null;
059            }
060            
061            /**
062             * @see railo.runtime.type.Collection#remove(java.lang.String)
063             */
064            public Object remove(String key) throws ExpressionException {
065                throw new ExpressionException("Unsupported Context for Local Scope","Can't invoke key "+key+", Local Scope can only invoked inside a Function");
066            }
067            
068            /**
069             *
070             * @see railo.runtime.type.Collection#remove(railo.runtime.type.Collection.Key)
071             */
072            public Object remove(Key key) throws PageException {
073                    return remove(key.getString());
074            }
075            
076            /**
077             * @see railo.runtime.type.Collection#clear()
078             */
079            public void clear() {
080            }
081            /**
082             * @see railo.runtime.type.Collection#get(java.lang.String)
083             */
084            public Object get(Collection.Key key) throws ExpressionException {
085                    throw new ExpressionException("Unsupported Context for Local Scope","Can't invoke key "+key.getString()+", Local Scope can only invoked inside a Function");
086            }
087    
088            /**
089             *
090             * @see railo.runtime.type.Collection#get(railo.runtime.type.Collection.Key, java.lang.Object)
091             */
092            public Object get(Collection.Key key, Object defaultValue) {
093                    return defaultValue;
094            }
095    
096            /**
097             * @see railo.runtime.type.Collection#set(java.lang.String, java.lang.Object)
098             */
099            public Object set(Key key, Object value) throws ExpressionException {
100                    throw new ExpressionException("Unsupported Context for Local Scope","Can't invoke key "+key.getString()+", Local Scope can only invoked inside a Function");
101            }
102            
103        /**
104         * @see railo.runtime.type.Collection#setEL(railo.runtime.type.Collection.Key, java.lang.Object)
105         */
106        public Object setEL(Collection.Key key, Object value) {
107                    return null;
108            }
109            
110            /**
111             * @see railo.runtime.type.Collection#keyIterator()
112             */
113            public Iterator keyIterator() {
114                    return null;
115            }
116    
117            /**
118             * @see railo.runtime.type.Scope#isInitalized()
119             */
120            public boolean isInitalized() {
121                    return false;
122            }
123            /**
124             * @see railo.runtime.type.Scope#initialize(railo.runtime.PageContext)
125             */
126            public void initialize(PageContext pc) {
127            }
128            /**
129             * @see railo.runtime.type.Scope#release()
130             */
131            public void release() {
132            }
133            
134            /**
135             * @see railo.runtime.dump.Dumpable#toDumpData(railo.runtime.PageContext, int)
136             */
137            public DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp) {
138                    throw new PageRuntimeException(new ExpressionException("Unsupported Context for Local Scope"));
139            }
140            
141            /**
142             * @see railo.runtime.type.Collection#duplicate(boolean)
143             */
144            public Collection duplicate(boolean deepCopy) {
145                return new LocalNotSupportedScope();
146            }
147            
148    
149            /**
150             * @see railo.runtime.type.Collection#containsKey(railo.runtime.type.Collection.Key)
151             */
152            public boolean containsKey(Collection.Key key) {
153                    return false;
154            }
155    
156            /**
157             * @see java.util.Map#containsValue(java.lang.Object)
158             */
159            public boolean containsValue(Object value) {
160                    return false;
161            }
162    
163            /**
164             * @see java.util.Map#values()
165             */
166            public java.util.Collection values() {
167                    return null;
168            }
169            
170        /**
171         * @see railo.runtime.op.Castable#castToString()
172         */
173        public String castToString() throws ExpressionException {
174            throw new ExpressionException("Unsupported Context for Local Scope");
175        }
176        
177            /**
178             * @see railo.runtime.type.util.StructSupport#castToString(java.lang.String)
179             */
180            public String castToString(String defaultValue) {
181                    return defaultValue;
182            }
183    
184    
185        /**
186         * @see railo.runtime.op.Castable#castToBooleanValue()
187         */
188        public boolean castToBooleanValue() throws ExpressionException {
189            throw new ExpressionException("Unsupported Context for Local Scope");
190        }
191        
192        /**
193         * @see railo.runtime.op.Castable#castToBoolean(java.lang.Boolean)
194         */
195        public Boolean castToBoolean(Boolean defaultValue) {
196            return defaultValue;
197        }
198    
199    
200        /**
201         * @see railo.runtime.op.Castable#castToDoubleValue()
202         */
203        public double castToDoubleValue() throws ExpressionException {
204            throw new ExpressionException("Unsupported Context for Local Scope");
205        }
206        
207        /**
208         * @see railo.runtime.op.Castable#castToDoubleValue(double)
209         */
210        public double castToDoubleValue(double defaultValue) {
211            return defaultValue;
212        }
213    
214    
215        /**
216         * @see railo.runtime.op.Castable#castToDateTime()
217         */
218        public DateTime castToDateTime() throws ExpressionException {
219            throw new ExpressionException("Unsupported Context for Local Scope");
220        }
221        
222        /**
223         * @see railo.runtime.op.Castable#castToDateTime(railo.runtime.type.dt.DateTime)
224         */
225        public DateTime castToDateTime(DateTime defaultValue) {
226            return defaultValue;
227        }
228        
229        public int getType() {
230            return SCOPE_LOCAL;
231        }
232        public String getTypeAsString() {
233            return "local";
234        }
235            public int compareTo(String str) throws PageException {
236            throw new ExpressionException("Unsupported Context for Local Scope");
237            }
238            public int compareTo(boolean b) throws PageException {
239            throw new ExpressionException("Unsupported Context for Local Scope");
240            }
241            public int compareTo(double d) throws PageException {
242            throw new ExpressionException("Unsupported Context for Local Scope");
243            }
244            public int compareTo(DateTime dt) throws PageException {
245            throw new ExpressionException("Unsupported Context for Local Scope");
246            }
247            /**
248             * @see railo.runtime.type.scope.LocalPro#isBind()
249             */
250            public boolean isBind() {
251                    return bind;
252            }
253    
254            /**
255             * @see railo.runtime.type.scope.LocalPro#setBind(boolean)
256             */
257            public void setBind(boolean bind) {
258                    this.bind=bind;
259            }
260    }