KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > TreeMapContext


1
2 /*
3  * Copyright 2000,2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import java.util.TreeMap JavaDoc;
19 import java.io.Serializable JavaDoc;
20 import org.apache.velocity.context.AbstractContext;
21 import org.apache.velocity.context.Context;
22
23 /**
24  * Example context impl that uses a TreeMap
25  *
26  * Not much point other than to show how easy it is.
27  *
28  * This is unsupported, example code.
29  *
30  * @author <a HREF="mailto:geirm@optonline.net">Geir Magnusson Jr.</a>
31  * @version $Id: TreeMapContext.java,v 1.1.14.1 2004/03/04 00:18:29 geirm Exp $
32  */

33
34 public class TreeMapContext extends AbstractContext
35 {
36     private TreeMap JavaDoc context = new TreeMap JavaDoc();
37
38     public TreeMapContext()
39     {
40         super();
41     }
42
43     public TreeMapContext( Context inner )
44     {
45         super( inner );
46     }
47
48     public Object JavaDoc internalGet( String JavaDoc key )
49     {
50         return context.get( key );
51     }
52
53     public Object JavaDoc internalPut( String JavaDoc key, Object JavaDoc value )
54     {
55         return context.put( key, value );
56     }
57
58     public boolean internalContainsKey(Object JavaDoc key)
59     {
60         return context.containsKey( key );
61     }
62
63     public Object JavaDoc[] internalGetKeys()
64     {
65         return context.keySet().toArray();
66     }
67
68     public Object JavaDoc internalRemove(Object JavaDoc key)
69     {
70         return context.remove( key );
71     }
72 }
73
74
Popular Tags