View Javadoc

1   package delight.nashornsandbox.internal;
2   
3   import java.util.HashSet;
4   import java.util.Set;
5   import jdk.nashorn.api.scripting.ClassFilter;
6   
7   @SuppressWarnings("all")
8   public class SandboxClassFilter implements ClassFilter {
9     private final Set<String> allowed;
10    
11    @Override
12    public boolean exposeToScripts(final String className) {
13      return this.allowed.contains(className);
14    }
15    
16    public void add(final String className) {
17      this.allowed.add(className);
18    }
19    
20    public void remove(final String className) {
21      this.allowed.remove(className);
22    }
23    
24    public void clear() {
25      this.allowed.clear();
26    }
27    
28    public boolean contains(final String className) {
29      return this.allowed.contains(className);
30    }
31    
32    public SandboxClassFilter() {
33      HashSet<String> _hashSet = new HashSet<String>();
34      this.allowed = _hashSet;
35    }
36  }