001    package railo.runtime.interpreter.ref.var;
002    
003    import railo.runtime.PageContext;
004    import railo.runtime.exp.PageException;
005    import railo.runtime.interpreter.VariableInterpreter;
006    import railo.runtime.interpreter.ref.Ref;
007    import railo.runtime.interpreter.ref.RefSupport;
008    import railo.runtime.interpreter.ref.Set;
009    import railo.runtime.interpreter.ref.literal.LString;
010    
011    /**
012     * 
013     */
014    public final class Scope extends RefSupport implements Set {
015            
016            private int scope;
017    
018            /**
019         * contructor of the class
020             * @param pc
021             * @param scope
022             */
023            public Scope(int scope) {
024                    this.scope=scope;
025            }
026            
027            @Override
028            public Object getValue(PageContext pc) throws PageException {
029                    return VariableInterpreter.scope(pc, scope, false);
030            }
031    
032            @Override
033        public String getTypeName() {
034                    return "scope";
035            }
036    
037            @Override
038            public Object touchValue(PageContext pc) throws PageException {
039            return VariableInterpreter.scope(pc, scope, true);
040        }
041    
042        @Override
043        public Object setValue(PageContext pc,Object obj) throws PageException {
044            return pc.undefinedScope().set(getKeyAsString(pc),obj);
045        }
046    
047        /**
048         * @return scope
049         */
050        public int getScope() {
051            return scope;
052        }
053    
054        @Override
055        public Ref getParent(PageContext pc) throws PageException {
056            return null;
057        }
058        
059        @Override
060        public Ref getKey(PageContext pc) throws PageException {
061            return new LString(getKeyAsString(pc));
062        }
063    
064        @Override
065        public String getKeyAsString(PageContext pc) throws PageException {
066            //return ScopeFactory.toStringScope(scope,null);
067            return VariableInterpreter.scopeInt2String(scope);
068        }
069    }