Java Doc for ScriptableObject.java in  » Scripting » rhino » org » mozilla » javascript » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » rhino » org.mozilla.javascript 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.mozilla.javascript.ScriptableObject

All known Subclasses:   org.mozilla.javascript.IdScriptableObject,  org.mozilla.javascript.tools.shell.Environment,  org.mozilla.javascript.NativeJavaPackage,
ScriptableObject
abstract public class ScriptableObject implements Scriptable,Serializable,DebuggableObject,ConstProperties(Code)
This is the default implementation of the Scriptable interface. This class provides convenient default behavior that makes it easier to define host objects.

Various properties and methods of JavaScript objects can be conveniently defined using methods of ScriptableObject.

Classes extending ScriptableObject must define the getClassName method.
See Also:   org.mozilla.javascript.Scriptable
author:
   Norris Boyd



Field Summary
final public static  intCONST
    
final public static  intDONTENUM
     Property attribute indicating property is not enumerated.
final public static  intEMPTY
     The empty property attribute.
final public static  intPERMANENT
     Property attribute indicating property cannot be deleted.
final public static  intREADONLY
     Property attribute indicating assignment to this property is ignored.
final public static  intUNINITIALIZED_CONST
     Property attribute indicating that this is a const property that has not been assigned yet.

Constructor Summary
public  ScriptableObject()
    
public  ScriptableObject(Scriptable scope, Scriptable prototype)
    

Method Summary
 voidaddLazilyInitializedValue(String name, int index, LazilyLoadedCtor init, int attributes)
    
final public  ObjectassociateValue(Object key, Object value)
     Associate arbitrary application-specific value with this object.
public  booleanavoidObjectDetection()
     Emulate the SpiderMonkey (and Firefox) feature of allowing custom objects to avoid detection by normal "object detection" code patterns.
static  BaseFunctionbuildClassCtor(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance)
    
public static  ObjectcallMethod(Scriptable obj, String methodName, Object[] args)
     Call a method of an object.
public static  ObjectcallMethod(Context cx, Scriptable obj, String methodName, Object[] args)
     Call a method of an object.
static  voidcheckValidAttributes(int attributes)
    
public static  voiddefineClass(Scriptable scope, Class clazz)
     Defines JavaScript objects from a Java class that implements Scriptable. If the given class has a method
 static void init(Context cx, Scriptable scope, boolean sealed);
or its compatibility form
 static void init(Scriptable scope);
then it is invoked and no further initialization is done.

However, if no such a method is found, then the class's constructors and methods are used to initialize a class in the following manner.

First, the zero-parameter constructor of the class is called to create the prototype.

public static  voiddefineClass(Scriptable scope, Class clazz, boolean sealed)
     Defines JavaScript objects from a Java class, optionally allowing sealing. Similar to defineClass(Scriptable scope, Class clazz) except that sealing is allowed.
public static  StringdefineClass(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance)
     Defines JavaScript objects from a Java class, optionally allowing sealing and mapping of Java inheritance to JavaScript prototype-based inheritance. Similar to defineClass(Scriptable scope, Class clazz) except that sealing and inheritance mapping are allowed.
public  voiddefineConst(String name, Scriptable start)
    
public static  voiddefineConstProperty(Scriptable destination, String propertyName)
     Utility method to add properties to arbitrary Scriptable object.
public  voiddefineFunctionProperties(String[] names, Class clazz, int attributes)
     Search for names in a class, adding the resulting methods as properties.

Uses reflection to find the methods of the given names.

public  voiddefineProperty(String propertyName, Object value, int attributes)
     Define a JavaScript property.
public static  voiddefineProperty(Scriptable destination, String propertyName, Object value, int attributes)
     Utility method to add properties to arbitrary Scriptable object.
public  voiddefineProperty(String propertyName, Class clazz, int attributes)
     Define a JavaScript property with getter and setter side effects. If the setter is not found, the attribute READONLY is added to the given attributes.
public  voiddefineProperty(String propertyName, Object delegateTo, Method getter, Method setter, int attributes)
     Define a JavaScript property. Use this method only if you wish to define getters and setters for a given property in a ScriptableObject.
public  voiddelete(String name)
     Removes a named property from the object.
public  voiddelete(int index)
     Removes the indexed property from the object.
public static  booleandeleteProperty(Scriptable obj, String name)
     Removes the property from an object or its prototype chain.

Searches for a property with name in obj or its prototype chain.

public static  booleandeleteProperty(Scriptable obj, int index)
     Removes the property from an object or its prototype chain.

Searches for a property with index in obj or its prototype chain.

protected  ObjectequivalentValues(Object value)
     Custom == operator.
public  Objectget(String name, Scriptable start)
     Returns the value of the named property or NOT_FOUND.
public  Objectget(int index, Scriptable start)
     Returns the value of the indexed property or NOT_FOUND.
public  Object[]getAllIds()
     Returns an array of ids for the properties of the object.

All properties, even those with attribute DONTENUM, are listed.

final public  ObjectgetAssociatedValue(Object key)
     Get arbitrary application-specific value associated with this object.
final public  intgetAttributes(String name, Scriptable start)
    
final public  intgetAttributes(int index, Scriptable start)
    
public  intgetAttributes(String name)
     Get the attributes of a named property.
public  intgetAttributes(int index)
     Get the attributes of an indexed property.
abstract public  StringgetClassName()
     Return the name of the class.
public static  ScriptablegetClassPrototype(Scriptable scope, String className)
     Get the prototype for the named class. For example, getClassPrototype(s, "Date") will first walk up the parent chain to find the outermost scope, then will search that scope for the Date constructor, and then will return Date.prototype.
public  ObjectgetDefaultValue(Class typeHint)
     Implements the [[DefaultValue]] internal method.

Note that the toPrimitive conversion is a no-op for every type other than Object, for which [[DefaultValue]] is called.

public static  ObjectgetDefaultValue(Scriptable object, Class typeHint)
    
public static  ScriptablegetFunctionPrototype(Scriptable scope)
     Get the Function.prototype property.
public  ObjectgetGetterOrSetter(String name, int index, boolean isSetter)
     Get the getter or setter for a given property.
public  Object[]getIds()
     Returns an array of ids for the properties of the object.

Any properties with the attribute DONTENUM are not listed.

 Object[]getIds(boolean getAll)
    
public static  ScriptablegetObjectPrototype(Scriptable scope)
     Get the Object.prototype property.
public  ScriptablegetParentScope()
     Returns the parent (enclosing) scope of the object.
public static  ObjectgetProperty(Scriptable obj, String name)
     Gets a named property from an object or any object in its prototype chain.
public static  ObjectgetProperty(Scriptable obj, int index)
     Gets an indexed property from an object or any object in its prototype chain.

Searches the prototype chain for a property with integral index index.

public static  Object[]getPropertyIds(Scriptable obj)
     Returns an array of all ids from an object and its prototypes.
public  ScriptablegetPrototype()
     Returns the prototype of the object.
public static  ScriptablegetTopLevelScope(Scriptable obj)
     Get the global scope.
public static  ObjectgetTopScopeValue(Scriptable scope, Object key)
     Get arbitrary application-specific value associated with the top scope of the given scope.
public  booleanhas(String name, Scriptable start)
     Returns true if the named property is defined.
public  booleanhas(int index, Scriptable start)
     Returns true if the property index is defined.
public  booleanhasInstance(Scriptable instance)
     Implements the instanceof operator.
public static  booleanhasProperty(Scriptable obj, String name)
     Returns whether a named property is defined in an object or any object in its prototype chain.
public static  booleanhasProperty(Scriptable obj, int index)
     Returns whether an indexed property is defined in an object or any object in its prototype chain.
public  booleanisConst(String name)
     Returns true if the named property is defined as a const on this object.
protected  booleanisGetterOrSetter(String name, int index, boolean setter)
    
final public  booleanisSealed()
     Return true if this object is sealed.
public  voidput(String name, Scriptable start, Object value)
     Sets the value of the named property, creating it if need be. If the property was created using defineProperty, the appropriate setter method is called.
public  voidput(int index, Scriptable start, Object value)
     Sets the value of the indexed property, creating it if need be.
public  voidputConst(String name, Scriptable start, Object value)
     Sets the value of the named const property, creating it if need be. If the property was created using defineProperty, the appropriate setter method is called.
public static  voidputConstProperty(Scriptable obj, String name, Object value)
     Puts a named property in an object or in an object in its prototype chain.

Searches for the named property in the prototype chain.

public static  voidputProperty(Scriptable obj, String name, Object value)
     Puts a named property in an object or in an object in its prototype chain.

Searches for the named property in the prototype chain.

public static  voidputProperty(Scriptable obj, int index, Object value)
     Puts an indexed property in an object or in an object in its prototype chain.

Searches for the indexed property in the prototype chain.

public static  voidredefineProperty(Scriptable obj, String name, boolean isConst)
     If hasProperty(obj, name) would return true, then if the property that was found is compatible with the new property, this method just returns. If the property is not compatible, then an exception is thrown. A property redefinition is incompatible if the first definition was a const declaration or if this one is.
public synchronized  voidsealObject()
     Seal this object. A sealed object may not have properties added or removed.
final public  voidsetAttributes(String name, Scriptable start, int attributes)
    
public  voidsetAttributes(int index, Scriptable start, int attributes)
    
public  voidsetAttributes(String name, int attributes)
     Set the attributes of a named property. The property is specified by name as defined for has.

The possible attributes are READONLY, DONTENUM, and PERMANENT.

public  voidsetAttributes(int index, int attributes)
     Set the attributes of an indexed property.
public  voidsetGetterOrSetter(String name, int index, Callable getterOrSeter, boolean isSetter)
     XXX: write docs.
public  voidsetParentScope(Scriptable m)
     Sets the parent (enclosing) scope of the object.
public  voidsetPrototype(Scriptable m)
     Sets the prototype of the object.

Field Detail
CONST
final public static int CONST(Code)



DONTENUM
final public static int DONTENUM(Code)
Property attribute indicating property is not enumerated. Only enumerated properties will be returned by getIds().
See Also:   org.mozilla.javascript.ScriptableObject.getIds
See Also:   org.mozilla.javascript.ScriptableObject.getAttributes(String)
See Also:   org.mozilla.javascript.ScriptableObject.setAttributes(Stringint)



EMPTY
final public static int EMPTY(Code)
The empty property attribute. Used by getAttributes() and setAttributes().
See Also:   org.mozilla.javascript.ScriptableObject.getAttributes(String)
See Also:   org.mozilla.javascript.ScriptableObject.setAttributes(Stringint)



PERMANENT
final public static int PERMANENT(Code)
Property attribute indicating property cannot be deleted.
See Also:   org.mozilla.javascript.ScriptableObject.delete(String)
See Also:   org.mozilla.javascript.ScriptableObject.getAttributes(String)
See Also:   org.mozilla.javascript.ScriptableObject.setAttributes(Stringint)



READONLY
final public static int READONLY(Code)
Property attribute indicating assignment to this property is ignored.
See Also:   org.mozilla.javascript.ScriptableObject.put(StringScriptableObject)
See Also:   org.mozilla.javascript.ScriptableObject.getAttributes(String)
See Also:   org.mozilla.javascript.ScriptableObject.setAttributes(Stringint)



UNINITIALIZED_CONST
final public static int UNINITIALIZED_CONST(Code)
Property attribute indicating that this is a const property that has not been assigned yet. The first 'const' assignment to the property will clear this bit.




Constructor Detail
ScriptableObject
public ScriptableObject()(Code)



ScriptableObject
public ScriptableObject(Scriptable scope, Scriptable prototype)(Code)




Method Detail
addLazilyInitializedValue
void addLazilyInitializedValue(String name, int index, LazilyLoadedCtor init, int attributes)(Code)



associateValue
final public Object associateValue(Object key, Object value)(Code)
Associate arbitrary application-specific value with this object. Value can only be associated with the given object and key only once. The method ignores any subsequent attempts to change the already associated value.

The associated values are not serialized.
Parameters:
  key - key object to select particular value.
Parameters:
  value - the value to associate the passed value if the method is called first time for thegiven key or old value for any subsequent calls.
See Also:   ScriptableObject.getAssociatedValue(Object key)




avoidObjectDetection
public boolean avoidObjectDetection()(Code)
Emulate the SpiderMonkey (and Firefox) feature of allowing custom objects to avoid detection by normal "object detection" code patterns. This is used to implement document.all. See https://bugzilla.mozilla.org/show_bug.cgi?id=412247. This is an analog to JOF_DETECTING from SpiderMonkey; see https://bugzilla.mozilla.org/show_bug.cgi?id=248549. Other than this special case, embeddings should return false. true if this object should avoid object detection
since:
   1.7R1



buildClassCtor
static BaseFunction buildClassCtor(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)



callMethod
public static Object callMethod(Scriptable obj, String methodName, Object[] args)(Code)
Call a method of an object.
Parameters:
  obj - the JavaScript object
Parameters:
  methodName - the name of the function property
Parameters:
  args - the arguments for the call
See Also:   Context.getCurrentContext



callMethod
public static Object callMethod(Context cx, Scriptable obj, String methodName, Object[] args)(Code)
Call a method of an object.
Parameters:
  cx - the Context object associated with the current thread.
Parameters:
  obj - the JavaScript object
Parameters:
  methodName - the name of the function property
Parameters:
  args - the arguments for the call



checkValidAttributes
static void checkValidAttributes(int attributes)(Code)



defineClass
public static void defineClass(Scriptable scope, Class clazz) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)
Defines JavaScript objects from a Java class that implements Scriptable. If the given class has a method
 static void init(Context cx, Scriptable scope, boolean sealed);
or its compatibility form
 static void init(Scriptable scope);
then it is invoked and no further initialization is done.

However, if no such a method is found, then the class's constructors and methods are used to initialize a class in the following manner.

First, the zero-parameter constructor of the class is called to create the prototype. If no such constructor exists, a EvaluatorException is thrown.

Next, all methods are scanned for special prefixes that indicate that they have special meaning for defining JavaScript objects. These special prefixes are

  • jsFunction_ for a JavaScript function
  • jsStaticFunction_ for a JavaScript function that is a property of the constructor
  • jsGet_ for a getter of a JavaScript property
  • jsSet_ for a setter of a JavaScript property
  • jsConstructor for a JavaScript function that is the constructor

If the method's name begins with "jsFunction_", a JavaScript function is created with a name formed from the rest of the Java method name following "jsFunction_". So a Java method named "jsFunction_foo" will define a JavaScript method "foo". Calling this JavaScript function will cause the Java method to be called. The parameters of the method must be of number and types as defined by the FunctionObject class. The JavaScript function is then added as a property of the prototype.

If the method's name begins with "jsStaticFunction_", it is handled similarly except that the resulting JavaScript function is added as a property of the constructor object. The Java method must be static. If the method's name begins with "jsGet_" or "jsSet_", the method is considered to define a property. Accesses to the defined property will result in calls to these getter and setter methods. If no setter is defined, the property is defined as READONLY.

If the method's name is "jsConstructor", the method is considered to define the body of the constructor. Only one method of this name may be defined. If no method is found that can serve as constructor, a Java constructor will be selected to serve as the JavaScript constructor in the following manner. If the class has only one Java constructor, that constructor is used to define the JavaScript constructor. If the the class has two constructors, one must be the zero-argument constructor (otherwise an EvaluatorException would have already been thrown when the prototype was to be created). In this case the Java constructor with one or more parameters will be used to define the JavaScript constructor. If the class has three or more constructors, an EvaluatorException will be thrown.

Finally, if there is a method

 static void finishInit(Scriptable scope, FunctionObject constructor,
 Scriptable prototype)
it will be called to finish any initialization. The scope argument will be passed, along with the newly created constructor and the newly created prototype.


Parameters:
  scope - The scope in which to define the constructor.
Parameters:
  clazz - The Java class to use to define the JavaScript objectsand properties.
exception:
  IllegalAccessException - if access is not availableto a reflected class member
exception:
  InstantiationException - if unable to instantiatethe named class
exception:
  InvocationTargetException - if an exception is thrownduring execution of methods of the named class
See Also:   org.mozilla.javascript.Function
See Also:   org.mozilla.javascript.FunctionObject
See Also:   org.mozilla.javascript.ScriptableObject.READONLY
See Also:   org.mozilla.javascript.ScriptableObject.defineProperty(StringClassint)




defineClass
public static void defineClass(Scriptable scope, Class clazz, boolean sealed) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)
Defines JavaScript objects from a Java class, optionally allowing sealing. Similar to defineClass(Scriptable scope, Class clazz) except that sealing is allowed. An object that is sealed cannot have properties added or removed. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version.
Parameters:
  scope - The scope in which to define the constructor.
Parameters:
  clazz - The Java class to use to define the JavaScript objectsand properties. The class must implement Scriptable.
Parameters:
  sealed - Whether or not to create sealed standard objects thatcannot be modified.
exception:
  IllegalAccessException - if access is not availableto a reflected class member
exception:
  InstantiationException - if unable to instantiatethe named class
exception:
  InvocationTargetException - if an exception is thrownduring execution of methods of the named class
since:
   1.4R3



defineClass
public static String defineClass(Scriptable scope, Class clazz, boolean sealed, boolean mapInheritance) throws IllegalAccessException, InstantiationException, InvocationTargetException(Code)
Defines JavaScript objects from a Java class, optionally allowing sealing and mapping of Java inheritance to JavaScript prototype-based inheritance. Similar to defineClass(Scriptable scope, Class clazz) except that sealing and inheritance mapping are allowed. An object that is sealed cannot have properties added or removed. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version.
Parameters:
  scope - The scope in which to define the constructor.
Parameters:
  clazz - The Java class to use to define the JavaScript objectsand properties. The class must implement Scriptable.
Parameters:
  sealed - Whether or not to create sealed standard objects thatcannot be modified.
Parameters:
  mapInheritance - Whether or not to map Java inheritance toJavaScript prototype-based inheritance. the class name for the prototype of the specified class
exception:
  IllegalAccessException - if access is not availableto a reflected class member
exception:
  InstantiationException - if unable to instantiatethe named class
exception:
  InvocationTargetException - if an exception is thrownduring execution of methods of the named class
since:
   1.6R2



defineConst
public void defineConst(String name, Scriptable start)(Code)



defineConstProperty
public static void defineConstProperty(Scriptable destination, String propertyName)(Code)
Utility method to add properties to arbitrary Scriptable object. If destination is instance of ScriptableObject, calls defineProperty there, otherwise calls put in destination ignoring attributes



defineFunctionProperties
public void defineFunctionProperties(String[] names, Class clazz, int attributes)(Code)
Search for names in a class, adding the resulting methods as properties.

Uses reflection to find the methods of the given names. Then FunctionObjects are constructed from the methods found, and are added to this object as properties with the given names.
Parameters:
  names - the names of the Methods to add as function properties
Parameters:
  clazz - the class to search for the Methods
Parameters:
  attributes - the attributes of the new properties
See Also:   org.mozilla.javascript.FunctionObject




defineProperty
public void defineProperty(String propertyName, Object value, int attributes)(Code)
Define a JavaScript property. Creates the property with an initial value and sets its attributes.
Parameters:
  propertyName - the name of the property to define.
Parameters:
  value - the initial value of the property
Parameters:
  attributes - the attributes of the JavaScript property
See Also:   org.mozilla.javascript.Scriptable.put(StringScriptableObject)



defineProperty
public static void defineProperty(Scriptable destination, String propertyName, Object value, int attributes)(Code)
Utility method to add properties to arbitrary Scriptable object. If destination is instance of ScriptableObject, calls defineProperty there, otherwise calls put in destination ignoring attributes



defineProperty
public void defineProperty(String propertyName, Class clazz, int attributes)(Code)
Define a JavaScript property with getter and setter side effects. If the setter is not found, the attribute READONLY is added to the given attributes.

The getter must be a method with zero parameters, and the setter, if found, must be a method with one parameter.


Parameters:
  propertyName - the name of the property to define. This namealso affects the name of the setter and getterto search for. If the propertyId is "foo", thenclazz will be searched for "getFoo"and "setFoo" methods.
Parameters:
  clazz - the Java class to search for the getter and setter
Parameters:
  attributes - the attributes of the JavaScript property
See Also:   org.mozilla.javascript.Scriptable.put(StringScriptableObject)




defineProperty
public void defineProperty(String propertyName, Object delegateTo, Method getter, Method setter, int attributes)(Code)
Define a JavaScript property. Use this method only if you wish to define getters and setters for a given property in a ScriptableObject. To create a property without special getter or setter side effects, use defineProperty(String,int). If setter is null, the attribute READONLY is added to the given attributes.

Several forms of getters or setters are allowed. In all cases the type of the value parameter can be any one of the following types: Object, String, boolean, Scriptable, byte, short, int, long, float, or double. The runtime will perform appropriate conversions based upon the type of the parameter (see description in FunctionObject). The first forms are nonstatic methods of the class referred to by 'this':

 Object getFoo();
 void setFoo(SomeType value);
Next are static methods that may be of any class; the object whose property is being accessed is passed in as an extra argument:
 static Object getFoo(Scriptable obj);
 static void setFoo(Scriptable obj, SomeType value);
Finally, it is possible to delegate to another object entirely using the delegateTo parameter. In this case the methods are nonstatic methods of the class delegated to, and the object whose property is being accessed is passed in as an extra argument:
 Object getFoo(Scriptable obj);
 void setFoo(Scriptable obj, SomeType value);

Parameters:
  propertyName - the name of the property to define.
Parameters:
  delegateTo - an object to call the getter and setter methods on,or null, depending on the form used above.
Parameters:
  getter - the method to invoke to get the value of the property
Parameters:
  setter - the method to invoke to set the value of the property
Parameters:
  attributes - the attributes of the JavaScript property



delete
public void delete(String name)(Code)
Removes a named property from the object. If the property is not found, or it has the PERMANENT attribute, no action is taken.
Parameters:
  name - the name of the property



delete
public void delete(int index)(Code)
Removes the indexed property from the object. If the property is not found, or it has the PERMANENT attribute, no action is taken.
Parameters:
  index - the numeric index for the property



deleteProperty
public static boolean deleteProperty(Scriptable obj, String name)(Code)
Removes the property from an object or its prototype chain.

Searches for a property with name in obj or its prototype chain. If it is found, the object's delete method is called.
Parameters:
  obj - a JavaScript object
Parameters:
  name - a property name true if the property doesn't exist or was successfully removed
since:
   1.5R2




deleteProperty
public static boolean deleteProperty(Scriptable obj, int index)(Code)
Removes the property from an object or its prototype chain.

Searches for a property with index in obj or its prototype chain. If it is found, the object's delete method is called.
Parameters:
  obj - a JavaScript object
Parameters:
  index - a property index true if the property doesn't exist or was successfully removed
since:
   1.5R2




equivalentValues
protected Object equivalentValues(Object value)(Code)
Custom == operator. Must return Scriptable.NOT_FOUND if this object does not have custom equality operator for the given value, Boolean.TRUE if this object is equivalent to value, Boolean.FALSE if this object is not equivalent to value.

The default implementation returns Boolean.TRUE if this == value or Scriptable.NOT_FOUND otherwise. It indicates that by default custom equality is available only if value is this in which case true is returned.




get
public Object get(String name, Scriptable start)(Code)
Returns the value of the named property or NOT_FOUND. If the property was created using defineProperty, the appropriate getter method is called.
Parameters:
  name - the name of the property
Parameters:
  start - the object in which the lookup began the value of the property (may be null), or NOT_FOUND



get
public Object get(int index, Scriptable start)(Code)
Returns the value of the indexed property or NOT_FOUND.
Parameters:
  index - the numeric index for the property
Parameters:
  start - the object in which the lookup began the value of the property (may be null), or NOT_FOUND



getAllIds
public Object[] getAllIds()(Code)
Returns an array of ids for the properties of the object.

All properties, even those with attribute DONTENUM, are listed.

an array of java.lang.Objects with an entry for everylisted property. Properties accessed via an integer index willhave a correspondingInteger entry in the returned array. Properties accessed bya String will have a String entry in the returned array.




getAssociatedValue
final public Object getAssociatedValue(Object key)(Code)
Get arbitrary application-specific value associated with this object.
Parameters:
  key - key object to select particular value.
See Also:   ScriptableObject.associateValue(Object key,Object value)



getAttributes
final public int getAttributes(String name, Scriptable start)(Code)
ScriptableObject.getAttributes(String name)



getAttributes
final public int getAttributes(int index, Scriptable start)(Code)
ScriptableObject.getAttributes(int index)



getAttributes
public int getAttributes(String name)(Code)
Get the attributes of a named property. The property is specified by name as defined for has.


Parameters:
  name - the identifier for the property the bitset of attributes
exception:
  EvaluatorException - if the named property is not found
See Also:   org.mozilla.javascript.ScriptableObject.has(StringScriptable)
See Also:   org.mozilla.javascript.ScriptableObject.READONLY
See Also:   org.mozilla.javascript.ScriptableObject.DONTENUM
See Also:   org.mozilla.javascript.ScriptableObject.PERMANENT
See Also:   org.mozilla.javascript.ScriptableObject.EMPTY




getAttributes
public int getAttributes(int index)(Code)
Get the attributes of an indexed property.
Parameters:
  index - the numeric index for the property
exception:
  EvaluatorException - if the named property is not foundis not found the bitset of attributes
See Also:   org.mozilla.javascript.ScriptableObject.has(StringScriptable)
See Also:   org.mozilla.javascript.ScriptableObject.READONLY
See Also:   org.mozilla.javascript.ScriptableObject.DONTENUM
See Also:   org.mozilla.javascript.ScriptableObject.PERMANENT
See Also:   org.mozilla.javascript.ScriptableObject.EMPTY



getClassName
abstract public String getClassName()(Code)
Return the name of the class. This is typically the same name as the constructor. Classes extending ScriptableObject must implement this abstract method.



getClassPrototype
public static Scriptable getClassPrototype(Scriptable scope, String className)(Code)
Get the prototype for the named class. For example, getClassPrototype(s, "Date") will first walk up the parent chain to find the outermost scope, then will search that scope for the Date constructor, and then will return Date.prototype. If any of the lookups fail, or the prototype is not a JavaScript object, then null will be returned.
Parameters:
  scope - an object in the scope chain
Parameters:
  className - the name of the constructor the prototype for the named class, or null if itcannot be found.



getDefaultValue
public Object getDefaultValue(Class typeHint)(Code)
Implements the [[DefaultValue]] internal method.

Note that the toPrimitive conversion is a no-op for every type other than Object, for which [[DefaultValue]] is called. See ECMA 9.1.

A hint of null means "no hint".
Parameters:
  typeHint - the type hint the default value for the objectSee ECMA 8.6.2.6.




getDefaultValue
public static Object getDefaultValue(Scriptable object, Class typeHint)(Code)



getFunctionPrototype
public static Scriptable getFunctionPrototype(Scriptable scope)(Code)
Get the Function.prototype property. See ECMA 15.3.4.



getGetterOrSetter
public Object getGetterOrSetter(String name, int index, boolean isSetter)(Code)
Get the getter or setter for a given property. Used by __lookupGetter__ and __lookupSetter__.
Parameters:
  name - Name of the object. If nonnull, index must be 0.
Parameters:
  index - Index of the object. If nonzero, name must be null.
Parameters:
  isSetter - If true, return the setter, otherwise return the getter.
exception:
  IllegalArgumentException - if both name and index are nonnulland nonzero respectively. Null if the property does not exist. Otherwise returns either the getter or the setter for the property, depending on the value of isSetter (may be undefined if unset).



getIds
public Object[] getIds()(Code)
Returns an array of ids for the properties of the object.

Any properties with the attribute DONTENUM are not listed.

an array of java.lang.Objects with an entry for everylisted property. Properties accessed via an integer index willhave a correspondingInteger entry in the returned array. Properties accessed bya String will have a String entry in the returned array.




getIds
Object[] getIds(boolean getAll)(Code)



getObjectPrototype
public static Scriptable getObjectPrototype(Scriptable scope)(Code)
Get the Object.prototype property. See ECMA 15.2.4.



getParentScope
public Scriptable getParentScope()(Code)
Returns the parent (enclosing) scope of the object.



getProperty
public static Object getProperty(Scriptable obj, String name)(Code)
Gets a named property from an object or any object in its prototype chain.

Searches the prototype chain for a property named name.


Parameters:
  obj - a JavaScript object
Parameters:
  name - a property name the value of a property with name name found inobj or any object in its prototype chain, orScriptable.NOT_FOUND if not found
since:
   1.5R2




getProperty
public static Object getProperty(Scriptable obj, int index)(Code)
Gets an indexed property from an object or any object in its prototype chain.

Searches the prototype chain for a property with integral index index. Note that if you wish to look for properties with numerical but non-integral indicies, you should use getProperty(Scriptable,String) with the string value of the index.


Parameters:
  obj - a JavaScript object
Parameters:
  index - an integral index the value of a property with index index found inobj or any object in its prototype chain, orScriptable.NOT_FOUND if not found
since:
   1.5R2




getPropertyIds
public static Object[] getPropertyIds(Scriptable obj)(Code)
Returns an array of all ids from an object and its prototypes.


Parameters:
  obj - a JavaScript object an array of all ids from all object in the prototype chain.If a given id occurs multiple times in the prototype chain,it will occur only once in this list.
since:
   1.5R2




getPrototype
public Scriptable getPrototype()(Code)
Returns the prototype of the object.



getTopLevelScope
public static Scriptable getTopLevelScope(Scriptable obj)(Code)
Get the global scope.

Walks the parent scope chain to find an object with a null parent scope (the global object).
Parameters:
  obj - a JavaScript object the corresponding global scope




getTopScopeValue
public static Object getTopScopeValue(Scriptable scope, Object key)(Code)
Get arbitrary application-specific value associated with the top scope of the given scope. The method first calls ScriptableObject.getTopLevelScope(Scriptable scope) and then searches the prototype chain of the top scope for the first object containing the associated value with the given key.
Parameters:
  scope - the starting scope.
Parameters:
  key - key object to select particular value.
See Also:   ScriptableObject.getAssociatedValue(Object key)



has
public boolean has(String name, Scriptable start)(Code)
Returns true if the named property is defined.
Parameters:
  name - the name of the property
Parameters:
  start - the object in which the lookup began true if and only if the property was found in the object



has
public boolean has(int index, Scriptable start)(Code)
Returns true if the property index is defined.
Parameters:
  index - the numeric index for the property
Parameters:
  start - the object in which the lookup began true if and only if the property was found in the object



hasInstance
public boolean hasInstance(Scriptable instance)(Code)
Implements the instanceof operator.

This operator has been proposed to ECMA.
Parameters:
  instance - The value that appeared on the LHS of the instanceofoperator true if "this" appears in value's prototype chain




hasProperty
public static boolean hasProperty(Scriptable obj, String name)(Code)
Returns whether a named property is defined in an object or any object in its prototype chain.

Searches the prototype chain for a property named name.


Parameters:
  obj - a JavaScript object
Parameters:
  name - a property name the true if property was found
since:
   1.5R2




hasProperty
public static boolean hasProperty(Scriptable obj, int index)(Code)
Returns whether an indexed property is defined in an object or any object in its prototype chain.

Searches the prototype chain for a property with index index.


Parameters:
  obj - a JavaScript object
Parameters:
  index - a property index the true if property was found
since:
   1.5R2




isConst
public boolean isConst(String name)(Code)
Returns true if the named property is defined as a const on this object.
Parameters:
  name - true if the named property is defined as a const, falseotherwise.



isGetterOrSetter
protected boolean isGetterOrSetter(String name, int index, boolean setter)(Code)
Returns whether a property is a getter or a setter
Parameters:
  name - property name
Parameters:
  index - property index
Parameters:
  setter - true to check for a setter, false for a getter whether the property is a getter or a setter



isSealed
final public boolean isSealed()(Code)
Return true if this object is sealed. It is an error to attempt to add or remove properties to a sealed object. true if sealed, false otherwise.
since:
   1.4R3



put
public void put(String name, Scriptable start, Object value)(Code)
Sets the value of the named property, creating it if need be. If the property was created using defineProperty, the appropriate setter method is called.

If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object.
Parameters:
  name - the name of the property
Parameters:
  start - the object whose property is being set
Parameters:
  value - value to set the property to




put
public void put(int index, Scriptable start, Object value)(Code)
Sets the value of the indexed property, creating it if need be.
Parameters:
  index - the numeric index for the property
Parameters:
  start - the object whose property is being set
Parameters:
  value - value to set the property to



putConst
public void putConst(String name, Scriptable start, Object value)(Code)
Sets the value of the named const property, creating it if need be. If the property was created using defineProperty, the appropriate setter method is called.

If the property's attributes include READONLY, no action is taken. This method will actually set the property in the start object.
Parameters:
  name - the name of the property
Parameters:
  start - the object whose property is being set
Parameters:
  value - value to set the property to




putConstProperty
public static void putConstProperty(Scriptable obj, String name, Object value)(Code)
Puts a named property in an object or in an object in its prototype chain.

Searches for the named property in the prototype chain. If it is found, the value of the property in obj is changed through a call to Scriptable.put(StringScriptableObject) on the prototype passing obj as the start argument. This allows the prototype to veto the property setting in case the prototype defines the property with [[ReadOnly]] attribute. If the property is not found, it is added in obj.
Parameters:
  obj - a JavaScript object
Parameters:
  name - a property name
Parameters:
  value - any JavaScript value accepted by Scriptable.put
since:
   1.5R2




putProperty
public static void putProperty(Scriptable obj, String name, Object value)(Code)
Puts a named property in an object or in an object in its prototype chain.

Searches for the named property in the prototype chain. If it is found, the value of the property in obj is changed through a call to Scriptable.put(StringScriptableObject) on the prototype passing obj as the start argument. This allows the prototype to veto the property setting in case the prototype defines the property with [[ReadOnly]] attribute. If the property is not found, it is added in obj.
Parameters:
  obj - a JavaScript object
Parameters:
  name - a property name
Parameters:
  value - any JavaScript value accepted by Scriptable.put
since:
   1.5R2




putProperty
public static void putProperty(Scriptable obj, int index, Object value)(Code)
Puts an indexed property in an object or in an object in its prototype chain.

Searches for the indexed property in the prototype chain. If it is found, the value of the property in obj is changed through a call to Scriptable.put(intScriptableObject) on the prototype passing obj as the start argument. This allows the prototype to veto the property setting in case the prototype defines the property with [[ReadOnly]] attribute. If the property is not found, it is added in obj.
Parameters:
  obj - a JavaScript object
Parameters:
  index - a property index
Parameters:
  value - any JavaScript value accepted by Scriptable.put
since:
   1.5R2




redefineProperty
public static void redefineProperty(Scriptable obj, String name, boolean isConst)(Code)
If hasProperty(obj, name) would return true, then if the property that was found is compatible with the new property, this method just returns. If the property is not compatible, then an exception is thrown. A property redefinition is incompatible if the first definition was a const declaration or if this one is. They are compatible only if neither was const.



sealObject
public synchronized void sealObject()(Code)
Seal this object. A sealed object may not have properties added or removed. Once an object is sealed it may not be unsealed.
since:
   1.4R3



setAttributes
final public void setAttributes(String name, Scriptable start, int attributes)(Code)
ScriptableObject.setAttributes(String name,int attributes)



setAttributes
public void setAttributes(int index, Scriptable start, int attributes)(Code)
ScriptableObject.setAttributes(int index,int attributes)



setAttributes
public void setAttributes(String name, int attributes)(Code)
Set the attributes of a named property. The property is specified by name as defined for has.

The possible attributes are READONLY, DONTENUM, and PERMANENT. Combinations of attributes are expressed by the bitwise OR of attributes. EMPTY is the state of no attributes set. Any unused bits are reserved for future use.
Parameters:
  name - the name of the property
Parameters:
  attributes - the bitset of attributes
exception:
  EvaluatorException - if the named property is not found
See Also:   org.mozilla.javascript.Scriptable.has(StringScriptable)
See Also:   org.mozilla.javascript.ScriptableObject.READONLY
See Also:   org.mozilla.javascript.ScriptableObject.DONTENUM
See Also:   org.mozilla.javascript.ScriptableObject.PERMANENT
See Also:   org.mozilla.javascript.ScriptableObject.EMPTY




setAttributes
public void setAttributes(int index, int attributes)(Code)
Set the attributes of an indexed property.
Parameters:
  index - the numeric index for the property
Parameters:
  attributes - the bitset of attributes
exception:
  EvaluatorException - if the named property is not found
See Also:   org.mozilla.javascript.Scriptable.has(StringScriptable)
See Also:   org.mozilla.javascript.ScriptableObject.READONLY
See Also:   org.mozilla.javascript.ScriptableObject.DONTENUM
See Also:   org.mozilla.javascript.ScriptableObject.PERMANENT
See Also:   org.mozilla.javascript.ScriptableObject.EMPTY



setGetterOrSetter
public void setGetterOrSetter(String name, int index, Callable getterOrSeter, boolean isSetter)(Code)
XXX: write docs.



setParentScope
public void setParentScope(Scriptable m)(Code)
Sets the parent (enclosing) scope of the object.



setPrototype
public void setPrototype(Scriptable m)(Code)
Sets the prototype of the object.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.