author | lagergren |
Thu, 10 Oct 2013 16:16:20 +0200 | |
changeset 20933 | 89748612fd1d |
parent 19889 | 63af9358d0dc |
child 21450 | 419e5d51f319 |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
17751
15a93d511eb7
8009141: Avoid netscape.javascript.JSObject in nashorn code
sundar
parents:
16151
diff
changeset
|
26 |
package jdk.nashorn.api.scripting; |
16147 | 27 |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
28 |
import java.util.Collection; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
29 |
import java.util.Collections; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
30 |
import java.util.Set; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
31 |
|
16147 | 32 |
/** |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
33 |
* This is the base class for nashorn ScriptObjectMirror class. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
34 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
35 |
* This class can also be subclassed by an arbitrary Java class. Nashorn will |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
36 |
* treat objects of such classes just like nashorn script objects. Usual nashorn |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
37 |
* operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
38 |
* to appropriate method call of this class. |
16147 | 39 |
*/ |
40 |
public abstract class JSObject { |
|
41 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
42 |
* Call this object as a JavaScript function. This is equivalent to |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
43 |
* 'func.apply(thiz, args)' in JavaScript. |
16147 | 44 |
* |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
45 |
* @param thiz 'this' object to be passed to the function |
16147 | 46 |
* @param args arguments to method |
47 |
* @return result of call |
|
48 |
*/ |
|
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
49 |
public Object call(final Object thiz, final Object... args) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
50 |
throw new UnsupportedOperationException("call"); |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
51 |
} |
18614 | 52 |
|
53 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
54 |
* Call this 'constructor' JavaScript function to create a new object. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
55 |
* This is equivalent to 'new func(arg1, arg2...)' in JavaScript. |
18614 | 56 |
* |
57 |
* @param args arguments to method |
|
58 |
* @return result of constructor call |
|
59 |
*/ |
|
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
60 |
public Object newObject(final Object... args) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
61 |
throw new UnsupportedOperationException("newObject"); |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
62 |
} |
16147 | 63 |
|
64 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
65 |
* Evaluate a JavaScript expression. |
16147 | 66 |
* |
67 |
* @param s JavaScript expression to evaluate |
|
68 |
* @return evaluation result |
|
69 |
*/ |
|
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
70 |
public Object eval(final String s) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
71 |
throw new UnsupportedOperationException("eval"); |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
72 |
} |
16147 | 73 |
|
74 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
75 |
* Call a JavaScript function member of this object. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
76 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
77 |
* @param name name of the member function to call |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
78 |
* @param args arguments to be passed to the member function |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
79 |
* @return result of call |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
80 |
*/ |
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
81 |
public Object callMember(final String name, final Object... args) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
82 |
throw new UnsupportedOperationException("call"); |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
83 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
84 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
85 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
86 |
* Retrieves a named member of this JavaScript object. |
16147 | 87 |
* |
88 |
* @param name of member |
|
89 |
* @return member |
|
90 |
*/ |
|
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
91 |
public Object getMember(final String name) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
92 |
return null; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
93 |
} |
16147 | 94 |
|
95 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
96 |
* Retrieves an indexed member of this JavaScript object. |
16147 | 97 |
* |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
98 |
* @param index index slot to retrieve |
16147 | 99 |
* @return member |
100 |
*/ |
|
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
101 |
public Object getSlot(final int index) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
102 |
return null; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
103 |
} |
16147 | 104 |
|
105 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
106 |
* Does this object have a named member? |
16147 | 107 |
* |
108 |
* @param name name of member |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
109 |
* @return true if this object has a member of the given name |
16147 | 110 |
*/ |
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
111 |
public boolean hasMember(final String name) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
112 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
113 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
114 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
115 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
116 |
* Does this object have a indexed property? |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
117 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
118 |
* @param slot index to check |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
119 |
* @return true if this object has a slot |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
120 |
*/ |
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
121 |
public boolean hasSlot(final int slot) { |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
122 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
123 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
124 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
125 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
126 |
* Remove a named member from this JavaScript object |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
127 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
128 |
* @param name name of the member |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
129 |
*/ |
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
130 |
public void removeMember(final String name) { |
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
131 |
//empty |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
132 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
133 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
134 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
135 |
* Set a named member in this JavaScript object |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
136 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
137 |
* @param name name of the member |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
138 |
* @param value value of the member |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
139 |
*/ |
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
140 |
public void setMember(final String name, final Object value) { |
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
141 |
//empty |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
142 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
143 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
144 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
145 |
* Set an indexed member in this JavaScript object |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
146 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
147 |
* @param index index of the member slot |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
148 |
* @param value value of the member |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
149 |
*/ |
20933
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
150 |
public void setSlot(final int index, final Object value) { |
89748612fd1d
8026250: Logging nullpointer bugfix and javadoc warnings
lagergren
parents:
19889
diff
changeset
|
151 |
//empty |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
152 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
153 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
154 |
// property and value iteration |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
155 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
156 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
157 |
* Returns the set of all property names of this object. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
158 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
159 |
* @return set of property names |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
160 |
*/ |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
161 |
@SuppressWarnings("unchecked") |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
162 |
public Set<String> keySet() { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
163 |
return Collections.EMPTY_SET; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
164 |
} |
16147 | 165 |
|
166 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
167 |
* Returns the set of all property values of this object. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
168 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
169 |
* @return set of property values. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
170 |
*/ |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
171 |
@SuppressWarnings("unchecked") |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
172 |
public Collection<Object> values() { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
173 |
return Collections.EMPTY_SET; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
174 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
175 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
176 |
// JavaScript instanceof check |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
177 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
178 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
179 |
* Checking whether the given object is an instance of 'this' object. |
16147 | 180 |
* |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
181 |
* @param instance instace to check |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
182 |
* @return true if the given 'instance' is an instance of this 'function' object |
16147 | 183 |
*/ |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
184 |
public boolean isInstance(final Object instance) { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
185 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
186 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
187 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
188 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
189 |
* Checking whether this object is an instance of the given 'clazz' object. |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
190 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
191 |
* @param clazz clazz to check |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
192 |
* @return true if this object is an instance of the given 'clazz' |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
193 |
*/ |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
194 |
public boolean isInstanceOf(final Object clazz) { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
195 |
if (clazz instanceof JSObject) { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
196 |
return ((JSObject)clazz).isInstance(this); |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
197 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
198 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
199 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
200 |
} |
16147 | 201 |
|
202 |
/** |
|
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
203 |
* ECMA [[Class]] property |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
204 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
205 |
* @return ECMA [[Class]] property value of this object |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
206 |
*/ |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
207 |
public String getClassName() { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
208 |
return getClass().getName(); |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
209 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
210 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
211 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
212 |
* Is this a function object? |
16147 | 213 |
* |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
214 |
* @return if this mirror wraps a ECMAScript function instance |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
215 |
*/ |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
216 |
public boolean isFunction() { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
217 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
218 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
219 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
220 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
221 |
* Is this a 'use strict' function object? |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
222 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
223 |
* @return true if this mirror represents a ECMAScript 'use strict' function |
16147 | 224 |
*/ |
19889
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
225 |
public boolean isStrictFunction() { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
226 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
227 |
} |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
228 |
|
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
229 |
/** |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
230 |
* Is this an array object? |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
231 |
* |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
232 |
* @return if this mirror wraps a ECMAScript array object |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
233 |
*/ |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
234 |
public boolean isArray() { |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
235 |
return false; |
63af9358d0dc
8024615: Refactor ScriptObjectMirror and JSObject to support external JSObject implementations
sundar
parents:
18614
diff
changeset
|
236 |
} |
16147 | 237 |
} |