1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host;
16
17 import org.htmlunit.corejs.javascript.Context;
18 import org.htmlunit.corejs.javascript.NativeFunction;
19 import org.htmlunit.corejs.javascript.Scriptable;
20 import org.htmlunit.xpath.xml.utils.PrefixResolver;
21
22
23
24
25
26
27 public class NativeFunctionPrefixResolver implements PrefixResolver {
28
29 private final NativeFunction resolverFn_;
30 private final Scriptable scope_;
31
32
33
34
35
36
37
38 public NativeFunctionPrefixResolver(final NativeFunction resolverFn, final Scriptable scope) {
39 resolverFn_ = resolverFn;
40 scope_ = scope;
41 }
42
43
44
45
46 @Override
47 public String getNamespaceForPrefix(final String prefix) {
48 final Object result = Context.call(null, resolverFn_, scope_, null, new Object[]{prefix});
49 return result == null ? null : result.toString();
50 }
51
52
53
54
55 @Override
56 public String getNamespaceForPrefix(final String prefix, final org.w3c.dom.Node node) {
57 throw new UnsupportedOperationException();
58 }
59
60
61
62
63 @Override
64 public boolean handlesNullPrefixes() {
65 return false;
66 }
67 }