KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > script > rhino > RhinoClassShutter


1 /*
2
3    Copyright 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 package org.apache.batik.script.rhino;
19
20 import org.mozilla.javascript.ClassShutter;
21
22 /**
23  * One line Class Desc
24  *
25  * Complete Class Desc
26  *
27  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
28  * @version $Id: RhinoClassShutter.java,v 1.3 2005/03/27 08:58:35 cam Exp $
29  */

30 public class RhinoClassShutter implements ClassShutter {
31     
32     public RhinoClassShutter() {
33         // I suspect that we might want to initialize this
34
// from a resource file.
35
// test();
36
}
37
38     /*
39     public void test() {
40         test("org.mozilla.javascript.Context");
41         test("org.mozilla.javascript");
42         test("org.apache.batik.dom.SVGOMDocument");
43         test("org.apache.batik.script.rhino.RhinoInterpreter");
44         test("org.apache.batik.apps.svgbrowser.JSVGViewerFrame");
45         test("org.apache.batik.bridge.BridgeContext");
46         test("org.apache.batik.bridge.BaseScriptingEnvironment");
47         test("org.apache.batik.bridge.ScriptingEnvironment");
48     }
49     public void test(String cls) {
50         System.err.println("Test '" + cls + "': " +
51                            visibleToScripts(cls));
52     }
53     */

54
55     public boolean visibleToScripts(String JavaDoc fullClassName) {
56         // Don't let them mess with script engine's internals.
57
if (fullClassName.startsWith("org.mozilla.javascript"))
58             return false;
59
60         if (fullClassName.startsWith("org.apache.batik.")) {
61             // Just get packge within batik.
62
String JavaDoc batikPkg = fullClassName.substring(17);
63
64             // Don't let them mess with Batik script internals.
65
if (batikPkg.startsWith("script"))
66                 return false;
67
68             // Don't let them get global structures.
69
if (batikPkg.startsWith("apps"))
70                 return false;
71
72             // Don't let them get Scripting stuff from bridge.
73
if (batikPkg.startsWith("bridge.")) {
74                 
75                 if (batikPkg.indexOf(".BaseScriptingEnvironment")!=-1)
76                     return false;
77                 if (batikPkg.indexOf(".ScriptingEnvironment")!=-1)
78                     return false;
79             }
80         }
81
82         return true;
83     }
84     
85 };
86
Popular Tags