001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.type.scope;
020
021import java.util.List;
022
023import lucee.runtime.PageContext;
024import lucee.runtime.exp.PageException;
025import lucee.runtime.type.Collection;
026import lucee.runtime.type.Query;
027import lucee.runtime.type.Struct;
028import lucee.runtime.util.QueryStack;
029
030/**
031 * interface of the cope undefined
032 */
033public interface Undefined extends Scope {
034
035        public static final int MODE_NO_LOCAL_AND_ARGUMENTS=0;
036        public static final int MODE_LOCAL_OR_ARGUMENTS_ONLY_WHEN_EXISTS=1;
037        public static final int MODE_LOCAL_OR_ARGUMENTS_ALWAYS=2;
038        
039
040    /**
041     * @return returns the current local scope defined in the undefined scope
042     */
043    public abstract Local localScope();
044    
045    public Argument argumentsScope();
046    
047    public Variables variablesScope();
048
049    /**
050     * sets mode of scope
051     * @param mode new mode
052     * @return old mode
053     */
054    public abstract int setMode(int mode);
055    
056    public boolean getLocalAlways();
057    
058
059    /**
060     * sets the functions scopes 
061     * @param local local scope
062     * @param argument argument scope
063     */
064    public abstract void setFunctionScopes(Local local, Argument argument);
065
066    /**
067     * @return returns actuell collection stack
068     */
069    public abstract QueryStack getQueryStack();
070
071    /**
072     * sets a individual query stack to the undefined scope
073     * @param qryStack Query stack
074     */
075    public abstract void setQueryStack(QueryStack qryStack);
076
077    /**
078     * add a collection to the undefined scope
079     * @param qry  Query to add to undefined scope
080     */
081    public abstract void addQuery(Query qry);
082
083    /**
084     * remove a collection from the undefined scope
085     */
086    public abstract void removeQuery();
087
088    /**
089     * return value matching key, if value is from Query return a QueryColumn
090     * @param key
091     * @return return matched value
092     * @throws PageException
093     * @deprecated use instead <code>{@link #getCollection(lucee.runtime.type.Collection.Key)}</code>
094         */
095    public abstract Object getCollection(String key) throws PageException;
096
097
098        public List<String> getScopeNames();
099        
100    /**
101     * return value matching key, if value is from Query return a QueryColumn
102     * @param key
103     * @return return matched value
104     * @throws PageException
105     */
106    public abstract Object getCollection(Collection.Key key) throws PageException;
107
108    /**
109     * gets a key from all cascaded scopes, but not from variables scope 
110     * @param key key to get
111     * @return matching value or null
112     * @deprecated use instead <code>{@link #getCascading(lucee.runtime.type.Collection.Key)}</code>
113         */
114    public abstract Object getCascading(String key);
115
116    /**
117     * gets a key from all cascaded scopes, but not from variables scope 
118     * @param key key to get
119     * @return matching value or null
120     */
121    public abstract Object getCascading(Collection.Key key);
122
123    /**
124     * change the variable scope
125     * @param scope
126     */
127    public abstract void setVariableScope(Variables scope);
128
129        /**
130         * @return if check for arguments and local scope values
131         */
132        public boolean getCheckArguments();
133        
134        public Struct getScope(Collection.Key key);
135        
136        public boolean setAllowImplicidQueryCall(boolean allowImplicidQueryCall);
137        
138        public void reinitialize(PageContext pc) ;
139}