Debian Codegraph @

rhino/src/org/mozilla/javascript/ConstProperties.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 public interface ConstProperties {
12 /**
13 * Sets a named const property in this object.
14 * <p>
15 * The property is specified by a string name
16 * as defined for <code>Scriptable.get</code>.
17 * <p>
18 * The possible values that may be passed in are as defined for
19 * <code>Scriptable.get</code>. A class that implements this method may choose
20 * to ignore calls to set certain properties, in which case those
21 * properties are effectively read-only.<p>
22 * For properties defined in a prototype chain,
23 * use <code>putProperty</code> in ScriptableObject. <p>
24 * Note that if a property <i>a</i> is defined in the prototype <i>p</i>
25 * of an object <i>o</i>, then evaluating <code>o.a = 23</code> will cause
26 * <code>set</code> to be called on the prototype <i>p</i> with
27 * <i>o</i> as the <i>start</i> parameter.
28 * To preserve JavaScript semantics, it is the Scriptable
29 * object's responsibility to modify <i>o</i>. <p>
30 * This design allows properties to be defined in prototypes and implemented
31 * in terms of getters and setters of Java values without consuming slots
32 * in each instance.<p>
33 * <p>
34 * The values that may be set are limited to the following:
35 * <UL>
36 * <LI>java.lang.Boolean objects</LI>
37 * <LI>java.lang.String objects</LI>
38 * <LI>java.lang.Number objects</LI>
39 * <LI>org.mozilla.javascript.Scriptable objects</LI>
40 * <LI>null</LI>
41 * <LI>The value returned by Context.getUndefinedValue()</LI>
42 * </UL><p>
43 * Arbitrary Java objects may be wrapped in a Scriptable by first calling
44 * <code>Context.toObject</code>. This allows the property of a JavaScript
45 * object to contain an arbitrary Java object as a value.<p>
46 * Note that <code>has</code> will be called by the runtime first before
47 * <code>set</code> is called to determine in which object the
48 * property is defined.
49 * Note that this method is not expected to traverse the prototype chain,
50 * which is different from the ECMA [[Put]] operation.
51 * @param name the name of the property
52 * @param start the object whose property is being set
53 * @param value value to set the property to
54 * @see org.mozilla.javascript.Scriptable#has(String, Scriptable)
55 * @see org.mozilla.javascript.Scriptable#get(String, Scriptable)
56 * @see org.mozilla.javascript.ScriptableObject#putProperty(Scriptable, String, Object)
57 * @see org.mozilla.javascript.Context#toObject(Object, Scriptable)
58 */
59 public void putConst(String name, Scriptable start, Object value);
60
61 /**
62 * Reserves a definition spot for a const. This will set up a definition
63 * of the const property, but set its value to undefined. The semantics of
64 * the start parameter is the same as for putConst.
65 * @param name The name of the property.
66 * @param start The object whose property is being reserved.
67 */
68 public void defineConst(String name, Scriptable start);
69
70 /**
71 * Returns true if the named property is defined as a const on this object.
72 * @param name
73 * @return true if the named property is defined as a const, false
74 * otherwise.
75 */
76 public boolean isConst(String name);
77 }