View Javadoc

1   package org.apache.velocity.context;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.    
20   */
21  
22  /**
23   *  Interface describing the application data context.  This set of
24   *  routines is used by the application to set and remove 'named' data
25   *  object to pass them to the template engine to use when rendering
26   *  a template.
27   *
28   *  This is the same set of methods supported by the original Context
29   *  class
30   *
31   *  @see org.apache.velocity.context.AbstractContext
32   *  @see org.apache.velocity.VelocityContext
33   *
34   *  @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
35   *  @author <a href="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
36   *  @version $Id: Context.java 463298 2006-10-12 16:10:32Z henning $
37   */
38  public interface Context
39  {
40      /**
41       * Adds a name/value pair to the context.
42       *
43       * @param key   The name to key the provided value with.
44       * @param value The corresponding value.
45       * @return The old object or null if there was no old object.
46       */
47      Object put(String key, Object value);
48  
49      /**
50       * Gets the value corresponding to the provided key from the context.
51       *
52       * @param key The name of the desired value.
53       * @return    The value corresponding to the provided key.
54       */
55      Object get(String key);
56  
57      /**
58       * Indicates whether the specified key is in the context.
59       *
60       * @param key The key to look for.
61       * @return    Whether the key is in the context.
62       */
63      boolean containsKey(Object key);
64  
65      /**
66       * Get all the keys for the values in the context.
67       * @return All the keys for the values in the context.
68       */
69      Object[] getKeys();
70  
71      /**
72       * Removes the value associated with the specified key from the context.
73       *
74       * @param key The name of the value to remove.
75       * @return    The value that the key was mapped to, or <code>null</code>
76       *            if unmapped.
77       */
78      Object remove(Object key);
79  }