Debian Codegraph @

rhino/src/org/mozilla/javascript/ClassShutter.java

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 // API class
8
9 package org.mozilla.javascript;
10
11 /**
12 Embeddings that wish to filter Java classes that are visible to scripts
13 through the LiveConnect, should implement this interface.
14
15 @see Context#setClassShutter(ClassShutter)
16 @since 1.5 Release 4
17 @author Norris Boyd
18 */
19
20 public interface ClassShutter {
21
22 /**
23 * Return true iff the Java class with the given name should be exposed
24 * to scripts.
25 * <p>
26 * An embedding may filter which Java classes are exposed through
27 * LiveConnect to JavaScript scripts.
28 * <p>
29 * Due to the fact that there is no package reflection in Java,
30 * this method will also be called with package names. There
31 * is no way for Rhino to tell if "Packages.a.b" is a package name
32 * or a class that doesn't exist. What Rhino does is attempt
33 * to load each segment of "Packages.a.b.c": It first attempts to
34 * load class "a", then attempts to load class "a.b", then
35 * finally attempts to load class "a.b.c". On a Rhino installation
36 * without any ClassShutter set, and without any of the
37 * above classes, the expression "Packages.a.b.c" will result in
38 * a [JavaPackage a.b.c] and not an error.
39 * <p>
40 * With ClassShutter supplied, Rhino will first call
41 * visibleToScripts before attempting to look up the class name. If
42 * visibleToScripts returns false, the class name lookup is not
43 * performed and subsequent Rhino execution assumes the class is
44 * not present. So for "java.lang.System.out.println" the lookup
45 * of "java.lang.System" is skipped and thus Rhino assumes that
46 * "java.lang.System" doesn't exist. So then for "java.lang.System.out",
47 * Rhino attempts to load the class "java.lang.System.out" because
48 * it assumes that "java.lang.System" is a package name.
49 * <p>
50 * @param fullClassName the full name of the class (including the package
51 * name, with '.' as a delimiter). For example the
52 * standard string class is "java.lang.String"
53 * @return whether or not to reveal this class to scripts
54 */
55 public boolean visibleToScripts(String fullClassName);
56 }