Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/tripi/asp/JavaReferenceMapNode.java


1   /**
2    * ArrowHead ASP Server 
3    * This is a source file for the ArrowHead ASP Server - an 100% Java
4    * VBScript interpreter and ASP server.
5    *
6    * For more information, see http://www.tripi.com/arrowhead
7    *
8    * Copyright (C) 2002  Terence Haddock
9    *
10   * This program is free software; you can redistribute it and/or modify
11   * it under the terms of the GNU General Public License as published by
12   * the Free Software Foundation; either version 2 of the License, or
13   * (at your option) any later version.
14   *
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Public License for more details.
19   *
20   * You should have received a copy of the GNU General Public License
21   * along with this program; if not, write to the Free Software
22   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23   *
24   */
25  package com.tripi.asp;
26  
27  import java.util.Enumeration;
28  import org.apache.log4j.Category;
29  
30  /**
31   * JavaReferenceMapNode class is a sub-class of JavaObjectNode specifically
32   * for java objects which implement both the SimpleMap interface as well
33   * as the SimpleReference interface.
34   *
35   * @author Terence Haddock
36   * @version 0.9
37   */
38  public class JavaReferenceMapNode extends JavaObjectNode implements SimpleMap, SimpleReference
39  {
40      /** Debugging object */
41      static private Category DBG =
42          Category.getInstance(JavaReferenceMapNode.class);
43  
44      /** Contained object as a SimpleMap interface object */
45      SimpleMap mapObj;
46      
47      /** Contained object as a SimpleReference interface object */
48      SimpleReference refObj;
49  
50      /**
51       * Constructor.
52       * @param obj SimpleMap/SimpleReference object
53       */
54      public JavaReferenceMapNode(Object obj)
55      {
56          super(obj);
57          this.mapObj = (SimpleMap)obj;
58          this.refObj = (SimpleReference)obj;
59      }
60  
61      /**
62       * Sets the value of this object.
63       * @param value new value of this object.
64       * @throws AspException if an error occurs
65       * @see SimpleReference#setValue(Object)
66       */
67      public void setValue(Object value) throws AspException
68      {
69          refObj.setValue(value);
70      }
71  
72      /**
73       * Obtains the value of this object.
74       * @return value of this object.
75       * @throws AspException if an error occurs
76       * @see SimpleReference#getValue()
77       */
78      public Object getValue() throws AspException
79      {
80          return refObj.getValue();
81      }
82  
83      /**
84       * Obtains the value of an object contained within this map.
85       * @param key Key of object to obtain
86       * @return value of the object referenced by the key
87       * @throws AspException if an error occurs
88       * @see SimpleMap#get(Object)
89       */
90      public Object get(Object key) throws AspException
91      {
92          return Types.coerceToNode(mapObj.get(key));
93      }
94  
95      /**
96       * Stores a value into this map.
97       * @param key Key of object to store
98       * @param value Value of object to store
99       * @throws AspException if an error occurs
100      * @see SimpleMap#put(Object,Object)
101      */
102     public void put(Object key, Object value) throws AspException
103     {
104         mapObj.put(key, value);
105     }
106 
107     /**
108      * Obtains the list of keys of this map.
109      * @return list of keys stored in this map.
110      * @throws AspException if an error occurs
111      * @see SimpleMap#getKeys
112      */
113     public Enumeration getKeys() throws AspException
114     {
115         return mapObj.getKeys();
116     }
117 }