KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > extensions > ExtensionHandlerJava


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

16 /*
17  * $Id: ExtensionHandlerJava.java,v 1.6 2004/02/11 05:26:23 minchau Exp $
18  */

19 package org.apache.xalan.extensions;
20
21 import java.util.Hashtable JavaDoc;
22
23 /**
24  * Abstract base class handling the java language extensions for XPath.
25  * This base class provides cache management shared by all of the
26  * various java extension handlers.
27  *
28  * @xsl.usage internal
29  */

30 public abstract class ExtensionHandlerJava extends ExtensionHandler
31 {
32
33   /** Extension class name */
34   protected String JavaDoc m_className = "";
35
36   /** Table of cached methods */
37   private Hashtable JavaDoc m_cachedMethods = new Hashtable JavaDoc();
38
39   /**
40    * Construct a new extension handler given all the information
41    * needed.
42    *
43    * @param namespaceUri the extension namespace URI that I'm implementing
44    * @param funcNames string containing list of functions of extension NS
45    * @param lang language of code implementing the extension
46    * @param srcURL value of src attribute (if any) - treated as a URL
47    * or a classname depending on the value of lang. If
48    * srcURL is not null, then scriptSrc is ignored.
49    * @param scriptSrc the actual script code (if any)
50    * @param scriptLang the scripting language
51    * @param className the extension class name
52    */

53   protected ExtensionHandlerJava(String JavaDoc namespaceUri, String JavaDoc scriptLang,
54                                  String JavaDoc className)
55   {
56
57     super(namespaceUri, scriptLang);
58
59     m_className = className;
60   }
61
62   /**
63    * Look up the entry in the method cache.
64    * @param methodKey A key that uniquely identifies this invocation in
65    * the stylesheet.
66    * @param objType A Class object or instance object representing the type
67    * @param methodArgs An array of the XObject arguments to be used for
68    * function mangling.
69    *
70    * @return The given method from the method cache
71    */

72   public Object JavaDoc getFromCache(Object JavaDoc methodKey, Object JavaDoc objType,
73                              Object JavaDoc[] methodArgs)
74   {
75
76     // Eventually, we want to insert code to mangle the methodKey with methodArgs
77
return m_cachedMethods.get(methodKey);
78   }
79
80   /**
81    * Add a new entry into the method cache.
82    * @param methodKey A key that uniquely identifies this invocation in
83    * the stylesheet.
84    * @param objType A Class object or instance object representing the type
85    * @param methodArgs An array of the XObject arguments to be used for
86    * function mangling.
87    * @param methodObj A Class object or instance object representing the method
88    *
89    * @return The cached method object
90    */

91   public Object JavaDoc putToCache(Object JavaDoc methodKey, Object JavaDoc objType,
92                            Object JavaDoc[] methodArgs, Object JavaDoc methodObj)
93   {
94
95     // Eventually, we want to insert code to mangle the methodKey with methodArgs
96
return m_cachedMethods.put(methodKey, methodObj);
97   }
98 }
99
Popular Tags