001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    
020    package org.apache.geronimo.gshell.command;
021    
022    import java.util.Iterator;
023    
024    /**
025     * Provides command instances with nested namespace for storing context.
026     *
027     * @version $Rev: 574416 $ $Date: 2007-09-10 17:49:15 -0700 (Mon, 10 Sep 2007) $
028     */
029    public interface Variables
030    {
031        void set(String name, Object value) throws ImmutableVariableException;
032    
033        void set(String name, Object value, boolean mutable) throws ImmutableVariableException;
034    
035        Object get(String name);
036    
037        Object get(String name, Object _default);
038    
039        boolean isMutable(String name);
040    
041        boolean isCloaked(String name);
042    
043        void unset(String name) throws ImmutableVariableException;
044        
045        boolean contains(String name);
046        
047        Iterator<String> names();
048    
049        Variables parent();
050    
051        //
052        // Exceptions
053        //
054    
055        class ImmutableVariableException
056            extends RuntimeException
057        {
058            ///CLOVER:OFF
059            
060            public ImmutableVariableException(final String name) {
061                super("Variable is immutable: " + name);
062            }
063        }
064    }