Java Doc for Context.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.Context

Context
public class Context (Code)
This class represents the runtime context of an executing script. Before executing a script, an instance of Context must be created and associated with the thread that will be executing the script. The Context will be used to store information about the executing of the script such as the call stack. Contexts are associated with the current thread using the Context.call(ContextAction) or Context.enter() methods.

Different forms of script execution are supported. Scripts may be evaluated from the source directly, or first compiled and then later executed. Interactive execution is also supported.

Some aspects of script execution, such as type conversions and object creation, may be accessed directly through methods of Context.
See Also:   Scriptable
author:
   Norris Boyd
author:
   Brendan Eich



Field Summary
final public static  intFEATURE_DYNAMIC_SCOPE
     Control if dynamic scope should be used for name access.
final public static  intFEATURE_E4X
     Control if support for E4X(ECMAScript for XML) extension is available.
final public static  intFEATURE_ENHANCED_JAVA_ACCESS
     Enables enhanced access to Java.
final public static  intFEATURE_LOCATION_INFORMATION_IN_ERROR
     When the feature is on Rhino will add a "fileName" and "lineNumber" properties to Error objects automatically.
final public static  intFEATURE_MEMBER_EXPR_AS_FUNCTION_NAME
     Control if member expression as function name extension is available.
final public static  intFEATURE_NON_ECMA_GET_YEAR
     Controls behaviour of Date.prototype.getYear().
final public static  intFEATURE_PARENT_PROTO_PROPERTIES
     Control if properties __proto__ and __parent__ are treated specially. If hasFeature(FEATURE_PARENT_PROTO_PROPERTIES) returns true, treat __parent__ and __proto__ as special properties.

The properties allow to query and set scope and prototype chains for the objects.

final public static  intFEATURE_PARENT_PROTO_PROPRTIES
    
final public static  intFEATURE_RESERVED_KEYWORD_AS_IDENTIFIER
     Control if reserved keywords are treated as identifiers.
final public static  intFEATURE_STRICT_EVAL
     Control if strict eval mode is enabled. When the feature is on Rhino reports runtime errors if non-string argument is passed to the eval function.
final public static  intFEATURE_STRICT_MODE
     Controls whether JS 1.5 'strict mode' is enabled. When the feature is on, Rhino reports more than a dozen different warnings.
final public static  intFEATURE_STRICT_VARS
     Control if strict variable mode is enabled. When the feature is on Rhino reports runtime errors if assignment to a global variable that does not exist is executed.
final public static  intFEATURE_TO_STRING_AS_SOURCE
     Control if toString() should returns the same result as toSource() when applied to objects and arrays. If hasFeature(FEATURE_TO_STRING_AS_SOURCE) returns true, calling toString() on JS objects gives the same result as calling toSource().
final public static  intFEATURE_WARNING_AS_ERROR
     Controls whether a warning should be treated as an error.
final public static  intVERSION_1_0
    
final public static  intVERSION_1_1
    
final public static  intVERSION_1_2
    
final public static  intVERSION_1_3
    
final public static  intVERSION_1_4
    
final public static  intVERSION_1_5
    
final public static  intVERSION_1_6
    
final public static  intVERSION_1_7
    
final public static  intVERSION_DEFAULT
     The default version.
final public static  intVERSION_UNKNOWN
     The unknown version.
 HashtableactivationNames
     This is the list of names of objects forcing the creation of function activation records.
 XMLLibcachedXMLLib
    
 booleancompileFunctionsWithDynamicScopeFlag
    
 NativeCallcurrentActivationCall
    
 Debuggerdebugger
    
final public static  Object[]emptyArgs
     Convenient value to use as zero-length array of objects.
final public static  StringerrorReporterProperty
    
public  booleangenerateObserverCount
    
 intinstructionCount
    
 intinstructionThreshold
    
 ObjectinterpreterSecurityDomain
    
 ObjToIntMapiterating
    
final public static  StringlanguageVersionProperty
    
 ObjectlastInterpreterFrame
    
 ObjArraypreviousInterpreterInvocations
    
 RegExpProxyregExpProxy
    
 intscratchIndex
    
 ScriptablescratchScriptable
    
 longscratchUint32
    
 ScriptabletopCallScope
    
 booleanuseDynamicScope
    
 intversion
    

Constructor Summary
public  Context()
     Create a new Context.
 Context(ContextFactory factory)
    

Method Summary
public  voidaddActivationName(String name)
     Add a name to the list of names forcing the creation of real activation objects for functions.
public static  voidaddContextListener(ContextListener listener)
    
final public  voidaddPropertyChangeListener(PropertyChangeListener l)
    
public static  Objectcall(ContextAction action)
     Call ContextAction.run(Context cx) using the Context instance associated with the current thread. If no Context is associated with the thread, then ContextFactory.getGlobal().makeContext() will be called to construct new Context instance.
public static  Objectcall(ContextFactory factory, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args)
     Call Callable.call(Context cxScriptable scopeScriptable thisObjObject[] args) using the Context instance associated with the current thread. If no Context is associated with the thread, then ContextFactory.makeContext will be called to construct new Context instance.
static  Objectcall(ContextFactory factory, ContextAction action)
     The method implements logic.
public static  voidcheckLanguageVersion(int version)
    
public static  voidcheckOptimizationLevel(int optimizationLevel)
    
final public  FunctioncompileFunction(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain)
     Compile a JavaScript function.

The function source must be a function definition as defined by ECMA (e.g., "function f(a) { return a; }").
Parameters:
  scope - the scope to compile relative to
Parameters:
  source - the function definition source
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script.

final  FunctioncompileFunction(Scriptable scope, String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain)
    
final public  ScriptcompileReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain)
    
final public  ScriptcompileReader(Reader in, String sourceName, int lineno, Object securityDomain)
     Compiles the source in the given reader.

Returns a script that may later be executed. Will consume all the source in the reader.
Parameters:
  in - the input reader
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number for reporting errors
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script.

final public  ScriptcompileString(String source, String sourceName, int lineno, Object securityDomain)
     Compiles the source in the given string.

Returns a script that may later be executed.
Parameters:
  source - the source string
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number for reporting errors
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script.

final  ScriptcompileString(String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain)
    
public  GeneratedClassLoadercreateClassLoader(ClassLoader parent)
     Create class loader for generated classes.
static  EvaluatorcreateInterpreter()
    
final public  StringdecompileFunction(Function fun, int indent)
     Decompile a JavaScript Function.
final public  StringdecompileFunctionBody(Function fun, int indent)
     Decompile the body of a JavaScript Function.
final public  StringdecompileScript(Script script, int indent)
     Decompile the script.
public static  Contextenter()
     Same as calling ContextFactory.enterContext on the global ContextFactory instance.
public static  Contextenter(Context cx)
     Get a Context associated with the current thread, using the given Context if need be.
final static  Contextenter(Context cx, ContextFactory factory)
    
final public  ObjectevaluateReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain)
     Evaluate a reader as JavaScript source. All characters of the reader are consumed.
Parameters:
  scope - the scope to execute in
Parameters:
  in - the Reader to get JavaScript source from
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script.
final public  ObjectevaluateString(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain)
     Evaluate a JavaScript source string. The provided source name and line number are used for error messages and for producing debug information.
Parameters:
  scope - the scope to execute in
Parameters:
  source - the JavaScript source
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script.
public static  voidexit()
     Exit a block of code requiring a Context. Calling exit() will remove the association between the current thread and a Context if the prior call to ContextFactory.enterContext on this thread newly associated a Context with this thread.
final  voidfirePropertyChange(String property, Object oldValue, Object newValue)
    
final public  ClassLoadergetApplicationClassLoader()
    
final  ClassShuttergetClassShutter()
    
static  ContextgetContext()
     Internal method that reports an error for missing calls to enter().
public static  ContextgetCurrentContext()
     Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread.
public static  DebuggableScriptgetDebuggableView(Script script)
     Return DebuggableScript instance if any associated with the script. If callable supports DebuggableScript implementation, the method returns it.
final public  DebuggergetDebugger()
     Return the current debugger.
final public  ObjectgetDebuggerContextData()
     Return the debugger context data associated with current context.
public  XMLLib.FactorygetE4xImplementationFactory()
     Returns an object which specifies an E4X implementation to use within this Context.
final public  Object[]getElements(Scriptable object)
     Get the elements of a JavaScript array.

If the object defines a length property convertible to double number, then the number is converted Uint32 value as defined in Ecma 9.6 and Java array of that size is allocated. The array is initialized with the values obtained by calling get() on object for each value of i in [0,length-1].

final public  ErrorReportergetErrorReporter()
     Get the current error reporter.
final public  ContextFactorygetFactory()
     Return ContextFactory instance used to create this Context.
final public  StringgetImplementationVersion()
     Get the implementation version.
final public  intgetInstructionObserverThreshold()
     Get threshold of executed instructions counter that triggers call to observeInstructionCount().
final public  intgetLanguageVersion()
     Get the current language version.
final public  LocalegetLocale()
     Get the current locale.
final public  intgetMaximumInterpreterStackDepth()
     Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.
final public  intgetOptimizationLevel()
     Get the current optimization level.
 RegExpProxygetRegExpProxy()
    
 SecurityControllergetSecurityController()
    
static  StringgetSourcePositionFromStack(int[] linep)
    
final public  ObjectgetThreadLocal(Object key)
     Get a value corresponding to a key.

Since the Context is associated with a thread it can be used to maintain values that can be later retrieved using the current thread.

Note that the values are maintained with the Context, so if the Context is disassociated from the thread the values cannot be retrieved.

public static  ObjectgetUndefinedValue()
     Get the singleton object that represents the JavaScript Undefined value.
final public  WrapFactorygetWrapFactory()
     Return the current WrapFactory, or null if none is defined.
final public  booleanhasCompileFunctionsWithDynamicScope()
    
public  booleanhasFeature(int featureIndex)
     Controls certain aspects of script semantics. Should be overwritten to alter default behavior.

The default implementation calls ContextFactory.hasFeature(Context cxint featureIndex) that allows to customize Context behavior without introducing Context subclasses.

final public  ScriptableObjectinitStandardObjects()
     Initialize the standard objects.
final public  ScriptableinitStandardObjects(ScriptableObject scope)
     Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.
Parameters:
  scope - the scope to initialize, or null, in which case a newobject will be created to serve as the scope the initialized scope.

public  ScriptableObjectinitStandardObjects(ScriptableObject scope, boolean sealed)
     Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

This form of the method also allows for creating "sealed" standard objects.

final public  booleanisActivationNeeded(String name)
     Check whether the name is in the list of names of objects forcing the creation of activation objects.
final public  booleanisGeneratingDebug()
     Tell whether debug information is being generated.
final public  booleanisGeneratingDebugChanged()
    
final public  booleanisGeneratingSource()
     Tell whether source information is being generated.
final public  booleanisSealed()
     Checks if this is a sealed Context.
public static  booleanisValidLanguageVersion(int version)
    
public static  booleanisValidOptimizationLevel(int optimizationLevel)
    
final  booleanisVersionECMA1()
    
public static  ObjectjavaToJS(Object value, Scriptable scope)
     Convenient method to convert java value to its closest representation in JavaScript.
public static  ObjectjsToJava(Object value, Class desiredType)
     Convert a JavaScript value into the desired type. Uses the semantics defined with LiveConnect3 and throws an Illegal argument exception if the conversion cannot be performed.
Parameters:
  value - the JavaScript value to convert
Parameters:
  desiredType - the Java type to convert to.
final public  ScriptablenewArray(Scriptable scope, int length)
     Create an array with a specified initial length.


Parameters:
  scope - the scope to create the object in
Parameters:
  length - the initial length (JavaScript arrays may haveadditional properties added dynamically).

final public  ScriptablenewArray(Scriptable scope, Object[] elements)
     Create an array with a set of initial elements.
Parameters:
  scope - the scope to create the object in.
Parameters:
  elements - the initial elements.
final public  ScriptablenewObject(Scriptable scope)
     Create a new JavaScript object.
final public  ScriptablenewObject(Scriptable scope, String constructorName)
     Create a new JavaScript object by executing the named constructor.
final public  ScriptablenewObject(Scriptable scope, String constructorName, Object[] args)
     Creates a new JavaScript object by executing the named constructor.
protected  voidobserveInstructionCount(int instructionCount)
     Allow application to monitor counter of executed script instructions in Context subclasses.
static  voidonSealedMutation()
    
final public  voidputThreadLocal(Object key, Object value)
     Put a value that can later be retrieved using a given key.
public  voidremoveActivationName(String name)
     Remove a name from the list of names forcing the creation of real activation objects for functions.
public static  voidremoveContextListener(ContextListener listener)
    
final public  voidremovePropertyChangeListener(PropertyChangeListener l)
    
final public  voidremoveThreadLocal(Object key)
     Remove values from thread-local storage.
public static  voidreportError(String message, String sourceName, int lineno, String lineSource, int lineOffset)
     Report an error using the error reporter for the current thread.
public static  voidreportError(String message)
     Report an error using the error reporter for the current thread.
public static  EvaluatorExceptionreportRuntimeError(String message, String sourceName, int lineno, String lineSource, int lineOffset)
     Report a runtime error using the error reporter for the current thread.
public static  EvaluatorExceptionreportRuntimeError(String message)
     Report a runtime error using the error reporter for the current thread.
static  EvaluatorExceptionreportRuntimeError0(String messageId)
    
static  EvaluatorExceptionreportRuntimeError1(String messageId, Object arg1)
    
static  EvaluatorExceptionreportRuntimeError2(String messageId, Object arg1, Object arg2)
    
static  EvaluatorExceptionreportRuntimeError3(String messageId, Object arg1, Object arg2, Object arg3)
    
static  EvaluatorExceptionreportRuntimeError4(String messageId, Object arg1, Object arg2, Object arg3, Object arg4)
    
public static  voidreportWarning(String message, String sourceName, int lineno, String lineSource, int lineOffset)
     Report a warning using the error reporter for the current thread.
public static  voidreportWarning(String message)
     Report a warning using the error reporter for the current thread.
public static  voidreportWarning(String message, Throwable t)
    
final public  voidseal(Object sealKey)
     Seal this Context object so any attempt to modify any of its properties including calling Context.enter() and Context.exit() methods will throw an exception.

If sealKey is not null, calling Context.unseal(Object sealKey) with the same key unseals the object.

final public  voidsetApplicationClassLoader(ClassLoader loader)
    
public static  voidsetCachingEnabled(boolean cachingEnabled)
    
final public  voidsetClassShutter(ClassShutter shutter)
     Set the LiveConnect access filter for this context.
final public  voidsetCompileFunctionsWithDynamicScope(boolean flag)
    
final public  voidsetDebugger(Debugger debugger, Object contextData)
     Set the associated debugger.
final public  ErrorReportersetErrorReporter(ErrorReporter reporter)
     Change the current error reporter.
public  voidsetGenerateObserverCount(boolean generateObserverCount)
     Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds.
final public  voidsetGeneratingDebug(boolean generatingDebug)
     Specify whether or not debug information should be generated.
final public  voidsetGeneratingSource(boolean generatingSource)
     Specify whether or not source information should be generated.
final public  voidsetInstructionObserverThreshold(int threshold)
     Set threshold of executed instructions counter that triggers call to observeInstructionCount().
public  voidsetLanguageVersion(int version)
     Set the language version.

Setting the language version will affect functions and scripts compiled subsequently.

final public  LocalesetLocale(Locale loc)
     Set the current locale.
final public  voidsetMaximumInterpreterStackDepth(int max)
     Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter.
final public  voidsetOptimizationLevel(int optimizationLevel)
     Set the current optimization level.

The optimization level is expected to be an integer between -1 and 9.

final public  voidsetSecurityController(SecurityController controller)
     Set the security controller for this context.
final public  voidsetWrapFactory(WrapFactory wrapFactory)
     Set a WrapFactory for this Context.
final public  booleanstringIsCompilableUnit(String source)
     Check whether a string is ready to be compiled.

stringIsCompilableUnit is intended to support interactive compilation of javascript.

public static  RuntimeExceptionthrowAsScriptRuntimeEx(Throwable e)
     Rethrow the exception wrapping it as the script runtime exception.
public static  booleantoBoolean(Object value)
     Convert the value to a JavaScript boolean value.
public static  doubletoNumber(Object value)
     Convert the value to a JavaScript Number value.
public static  ScriptabletoObject(Object value, Scriptable scope)
     Convert the value to an JavaScript object value.
public static  ScriptabletoObject(Object value, Scriptable scope, Class staticType)
    
public static  StringtoString(Object value)
     Convert the value to a JavaScript String value.
public static  ObjecttoType(Object value, Class desiredType)
    
final public  voidunseal(Object sealKey)
     Unseal previously sealed Context object.

Field Detail
FEATURE_DYNAMIC_SCOPE
final public static int FEATURE_DYNAMIC_SCOPE(Code)
Control if dynamic scope should be used for name access. If hasFeature(FEATURE_DYNAMIC_SCOPE) returns true, then the name lookup during name resolution will use the top scope of the script or function which is at the top of JS execution stack instead of the top scope of the script or function from the current stack frame if the top scope of the top stack frame contains the top scope of the current stack frame on its prototype chain.

This is useful to define shared scope containing functions that can be called from scripts and functions using private scopes.

By default Context.hasFeature(int) returns false.
since:
   1.6 Release 1




FEATURE_E4X
final public static int FEATURE_E4X(Code)
Control if support for E4X(ECMAScript for XML) extension is available. If hasFeature(FEATURE_E4X) returns true, the XML syntax is available.

By default Context.hasFeature(int) returns true if the current JS version is set to Context.VERSION_DEFAULT or is at least Context.VERSION_1_6 .
since:
   1.6 Release 1




FEATURE_ENHANCED_JAVA_ACCESS
final public static int FEATURE_ENHANCED_JAVA_ACCESS(Code)
Enables enhanced access to Java. Specifically, controls whether private and protected members can be accessed, and whether scripts can catch all Java exceptions.

Note that this feature should only be enabled for trusted scripts.

By default Context.hasFeature(int) returns false.
since:
   1.7 Release 1




FEATURE_LOCATION_INFORMATION_IN_ERROR
final public static int FEATURE_LOCATION_INFORMATION_IN_ERROR(Code)
When the feature is on Rhino will add a "fileName" and "lineNumber" properties to Error objects automatically. When the feature is off, you have to explicitly pass them as the second and third argument to the Error constructor. Note that neither behaviour is fully ECMA 262 compliant (as 262 doesn't specify a three-arg constructor), but keeping the feature off results in Error objects that don't have additional non-ECMA properties when constructed using the ECMA-defined single-arg constructor and is thus desirable if a stricter ECMA compliance is desired, specifically adherence to the point 15.11.5. of the standard.

By default Context.hasFeature(int) returns false.
since:
   1.6 Release 6




FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME
final public static int FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME(Code)
Control if member expression as function name extension is available. If hasFeature(FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME) returns true, allow function memberExpression(args) { body } to be syntax sugar for memberExpression = function(args) { body }, when memberExpression is not a simple identifier. See ECMAScript-262, section 11.2 for definition of memberExpression. By default Context.hasFeature(int) returns false.



FEATURE_NON_ECMA_GET_YEAR
final public static int FEATURE_NON_ECMA_GET_YEAR(Code)
Controls behaviour of Date.prototype.getYear(). If hasFeature(FEATURE_NON_ECMA_GET_YEAR) returns true, Date.prototype.getYear subtructs 1900 only if 1900 <= date < 2000. The default behavior of Context.hasFeature(int) is always to subtruct 1900 as rquired by ECMAScript B.2.4.



FEATURE_PARENT_PROTO_PROPERTIES
final public static int FEATURE_PARENT_PROTO_PROPERTIES(Code)
Control if properties __proto__ and __parent__ are treated specially. If hasFeature(FEATURE_PARENT_PROTO_PROPERTIES) returns true, treat __parent__ and __proto__ as special properties.

The properties allow to query and set scope and prototype chains for the objects. The special meaning of the properties is available only when they are used as the right hand side of the dot operator. For example, while x.__proto__ = y changes the prototype chain of the object x to point to y, x["__proto__"] = y simply assigns a new value to the property __proto__ in x even when the feature is on. By default Context.hasFeature(int) returns true.




FEATURE_PARENT_PROTO_PROPRTIES
final public static int FEATURE_PARENT_PROTO_PROPRTIES(Code)



FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER
final public static int FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER(Code)
Control if reserved keywords are treated as identifiers. If hasFeature(RESERVED_KEYWORD_AS_IDENTIFIER) returns true, treat future reserved keyword (see Ecma-262, section 7.5.3) as ordinary identifiers but warn about this usage. By default Context.hasFeature(int) returns false.



FEATURE_STRICT_EVAL
final public static int FEATURE_STRICT_EVAL(Code)
Control if strict eval mode is enabled. When the feature is on Rhino reports runtime errors if non-string argument is passed to the eval function. When the feature is off eval simply return non-string argument as is without performing any evaluation as required by ECMA 262.

By default Context.hasFeature(int) returns false.
since:
   1.6 Release 1




FEATURE_STRICT_MODE
final public static int FEATURE_STRICT_MODE(Code)
Controls whether JS 1.5 'strict mode' is enabled. When the feature is on, Rhino reports more than a dozen different warnings. When the feature is off, these warnings are not generated. FEATURE_STRICT_MODE implies FEATURE_STRICT_VARS and FEATURE_STRICT_EVAL.

By default Context.hasFeature(int) returns false.
since:
   1.6 Release 6




FEATURE_STRICT_VARS
final public static int FEATURE_STRICT_VARS(Code)
Control if strict variable mode is enabled. When the feature is on Rhino reports runtime errors if assignment to a global variable that does not exist is executed. When the feature is off such assignments creates new variable in the global scope as required by ECMA 262.

By default Context.hasFeature(int) returns false.
since:
   1.6 Release 1




FEATURE_TO_STRING_AS_SOURCE
final public static int FEATURE_TO_STRING_AS_SOURCE(Code)
Control if toString() should returns the same result as toSource() when applied to objects and arrays. If hasFeature(FEATURE_TO_STRING_AS_SOURCE) returns true, calling toString() on JS objects gives the same result as calling toSource(). That is it returns JS source with code to create an object with all enumeratable fields of the original object instead of printing [object result of Scriptable.getClassName ].

By default Context.hasFeature(int) returns true only if the current JS version is set to Context.VERSION_1_2 .




FEATURE_WARNING_AS_ERROR
final public static int FEATURE_WARNING_AS_ERROR(Code)
Controls whether a warning should be treated as an error.
since:
   1.6 Release 6



VERSION_1_0
final public static int VERSION_1_0(Code)
JavaScript 1.0



VERSION_1_1
final public static int VERSION_1_1(Code)
JavaScript 1.1



VERSION_1_2
final public static int VERSION_1_2(Code)
JavaScript 1.2



VERSION_1_3
final public static int VERSION_1_3(Code)
JavaScript 1.3



VERSION_1_4
final public static int VERSION_1_4(Code)
JavaScript 1.4



VERSION_1_5
final public static int VERSION_1_5(Code)
JavaScript 1.5



VERSION_1_6
final public static int VERSION_1_6(Code)
JavaScript 1.6



VERSION_1_7
final public static int VERSION_1_7(Code)
JavaScript 1.7



VERSION_DEFAULT
final public static int VERSION_DEFAULT(Code)
The default version.



VERSION_UNKNOWN
final public static int VERSION_UNKNOWN(Code)
The unknown version.



activationNames
Hashtable activationNames(Code)
This is the list of names of objects forcing the creation of function activation records.



cachedXMLLib
XMLLib cachedXMLLib(Code)



compileFunctionsWithDynamicScopeFlag
boolean compileFunctionsWithDynamicScopeFlag(Code)



currentActivationCall
NativeCall currentActivationCall(Code)



debugger
Debugger debugger(Code)



emptyArgs
final public static Object[] emptyArgs(Code)
Convenient value to use as zero-length array of objects.



errorReporterProperty
final public static String errorReporterProperty(Code)



generateObserverCount
public boolean generateObserverCount(Code)



instructionCount
int instructionCount(Code)



instructionThreshold
int instructionThreshold(Code)



interpreterSecurityDomain
Object interpreterSecurityDomain(Code)



iterating
ObjToIntMap iterating(Code)



languageVersionProperty
final public static String languageVersionProperty(Code)



lastInterpreterFrame
Object lastInterpreterFrame(Code)



previousInterpreterInvocations
ObjArray previousInterpreterInvocations(Code)



regExpProxy
RegExpProxy regExpProxy(Code)



scratchIndex
int scratchIndex(Code)



scratchScriptable
Scriptable scratchScriptable(Code)



scratchUint32
long scratchUint32(Code)



topCallScope
Scriptable topCallScope(Code)



useDynamicScope
boolean useDynamicScope(Code)



version
int version(Code)




Constructor Detail
Context
public Context()(Code)
Create a new Context. Note that the Context must be associated with a thread before it can be used to execute a script. ContextFactory.enterContextFactory.call(ContextAction)



Context
Context(ContextFactory factory)(Code)




Method Detail
addActivationName
public void addActivationName(String name)(Code)
Add a name to the list of names forcing the creation of real activation objects for functions.
Parameters:
  name - the name of the object to add to the list



addContextListener
public static void addContextListener(ContextListener listener)(Code)

See Also:   ContextFactory.addListener(ContextFactory.Listener)
See Also:   ContextFactory.getGlobal



addPropertyChangeListener
final public void addPropertyChangeListener(PropertyChangeListener l)(Code)
Register an object to receive notifications when a bound property has changed
See Also:   java.beans.PropertyChangeEvent
See Also:   Context.removePropertyChangeListener(java.beans.PropertyChangeListener)
Parameters:
  l - the listener



call
public static Object call(ContextAction action)(Code)
Call ContextAction.run(Context cx) using the Context instance associated with the current thread. If no Context is associated with the thread, then ContextFactory.getGlobal().makeContext() will be called to construct new Context instance. The instance will be temporary associated with the thread during call to ContextAction.run(Context) . ContextFactory.call(ContextAction) The result of ContextAction.run(Context).



call
public static Object call(ContextFactory factory, Callable callable, Scriptable scope, Scriptable thisObj, Object[] args)(Code)
Call Callable.call(Context cxScriptable scopeScriptable thisObjObject[] args) using the Context instance associated with the current thread. If no Context is associated with the thread, then ContextFactory.makeContext will be called to construct new Context instance. The instance will be temporary associated with the thread during call to ContextAction.run(Context) .

It is allowed but not advisable to use null for factory argument in which case the global static singleton ContextFactory instance will be used to create new context instances.
See Also:   ContextFactory.call(ContextAction)




call
static Object call(ContextFactory factory, ContextAction action)(Code)
The method implements logic.



checkLanguageVersion
public static void checkLanguageVersion(int version)(Code)



checkOptimizationLevel
public static void checkOptimizationLevel(int optimizationLevel)(Code)



compileFunction
final public Function compileFunction(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain)(Code)
Compile a JavaScript function.

The function source must be a function definition as defined by ECMA (e.g., "function f(a) { return a; }").
Parameters:
  scope - the scope to compile relative to
Parameters:
  source - the function definition source
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script. Forimplementations that don't care about security, this valuemay be null. a Function that may later be called
See Also:   org.mozilla.javascript.Function




compileFunction
final Function compileFunction(Scriptable scope, String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain)(Code)



compileReader
final public Script compileReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException(Code)

See Also:   Context.compileReader(Reader in,String sourceName,int lineno,Object securityDomain)



compileReader
final public Script compileReader(Reader in, String sourceName, int lineno, Object securityDomain) throws IOException(Code)
Compiles the source in the given reader.

Returns a script that may later be executed. Will consume all the source in the reader.
Parameters:
  in - the input reader
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number for reporting errors
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script. Forimplementations that don't care about security, this valuemay be null. a script that may later be executed
exception:
  IOException - if an IOException was generated by the Reader
See Also:   org.mozilla.javascript.Script




compileString
final public Script compileString(String source, String sourceName, int lineno, Object securityDomain)(Code)
Compiles the source in the given string.

Returns a script that may later be executed.
Parameters:
  source - the source string
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number for reporting errors
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script. Forimplementations that don't care about security, this valuemay be null. a script that may later be executed
See Also:   org.mozilla.javascript.Script




compileString
final Script compileString(String source, Evaluator compiler, ErrorReporter compilationErrorReporter, String sourceName, int lineno, Object securityDomain)(Code)



createClassLoader
public GeneratedClassLoader createClassLoader(ClassLoader parent)(Code)
Create class loader for generated classes. The method calls ContextFactory.createClassLoader(ClassLoader) using the result of Context.getFactory() .



createInterpreter
static Evaluator createInterpreter()(Code)



decompileFunction
final public String decompileFunction(Function fun, int indent)(Code)
Decompile a JavaScript Function.

Decompiles a previously compiled JavaScript function object to canonical source.

Returns function body of '[native code]' if no decompilation information is available.
Parameters:
  fun - the JavaScript function to decompile
Parameters:
  indent - the number of spaces to indent the result a string representing the function source




decompileFunctionBody
final public String decompileFunctionBody(Function fun, int indent)(Code)
Decompile the body of a JavaScript Function.

Decompiles the body a previously compiled JavaScript Function object to canonical source, omitting the function header and trailing brace. Returns '[native code]' if no decompilation information is available.
Parameters:
  fun - the JavaScript function to decompile
Parameters:
  indent - the number of spaces to indent the result a string representing the function body source.




decompileScript
final public String decompileScript(Script script, int indent)(Code)
Decompile the script.

The canonical source of the script is returned.
Parameters:
  script - the script to decompile
Parameters:
  indent - the number of spaces to indent the result a string representing the script source




enter
public static Context enter()(Code)
Same as calling ContextFactory.enterContext on the global ContextFactory instance. ContextFactory.enterContextFactory.call(ContextAction) a Context associated with the current thread
See Also:   Context.getCurrentContext()
See Also:   Context.exit()
See Also:   Context.call(ContextAction)



enter
public static Context enter(Context cx)(Code)
Get a Context associated with the current thread, using the given Context if need be.

The same as enter() except that cx is associated with the current thread and returned if the current thread has no associated context and cx is not associated with any other thread.
Parameters:
  cx - a Context to associate with the thread if possible a Context associated with the current threadContextFactory.enterContext(Context)
See Also:   ContextFactory.enterContext(Context)
See Also:   ContextFactory.call(ContextAction)




enter
final static Context enter(Context cx, ContextFactory factory)(Code)



evaluateReader
final public Object evaluateReader(Scriptable scope, Reader in, String sourceName, int lineno, Object securityDomain) throws IOException(Code)
Evaluate a reader as JavaScript source. All characters of the reader are consumed.
Parameters:
  scope - the scope to execute in
Parameters:
  in - the Reader to get JavaScript source from
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script. Forimplementations that don't care about security, this valuemay be null. the result of evaluating the source
exception:
  IOException - if an IOException was generated by the Reader



evaluateString
final public Object evaluateString(Scriptable scope, String source, String sourceName, int lineno, Object securityDomain)(Code)
Evaluate a JavaScript source string. The provided source name and line number are used for error messages and for producing debug information.
Parameters:
  scope - the scope to execute in
Parameters:
  source - the JavaScript source
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  securityDomain - an arbitrary object that specifies securityinformation about the origin or owner of the script. Forimplementations that don't care about security, this valuemay be null. the result of evaluating the string
See Also:   org.mozilla.javascript.SecurityController



exit
public static void exit()(Code)
Exit a block of code requiring a Context. Calling exit() will remove the association between the current thread and a Context if the prior call to ContextFactory.enterContext on this thread newly associated a Context with this thread. Once the current thread no longer has an associated Context, it cannot be used to execute JavaScript until it is again associated with a Context.
See Also:   ContextFactory.enterContext



firePropertyChange
final void firePropertyChange(String property, Object oldValue, Object newValue)(Code)
Notify any registered listeners that a bounded property has changed
See Also:   Context.addPropertyChangeListener(java.beans.PropertyChangeListener)
See Also:   Context.removePropertyChangeListener(java.beans.PropertyChangeListener)
See Also:   java.beans.PropertyChangeListener
See Also:   java.beans.PropertyChangeEvent
Parameters:
  property - the bound property
Parameters:
  oldValue - the old value
Parameters:
  newValue - the new value



getApplicationClassLoader
final public ClassLoader getApplicationClassLoader()(Code)



getClassShutter
final ClassShutter getClassShutter()(Code)



getContext
static Context getContext()(Code)
Internal method that reports an error for missing calls to enter().



getCurrentContext
public static Context getCurrentContext()(Code)
Get the current Context. The current Context is per-thread; this method looks up the Context associated with the current thread.

the Context associated with the current thread, ornull if no context is associated with the currentthread.
See Also:   ContextFactory.enterContext
See Also:   ContextFactory.call(ContextAction)




getDebuggableView
public static DebuggableScript getDebuggableView(Script script)(Code)
Return DebuggableScript instance if any associated with the script. If callable supports DebuggableScript implementation, the method returns it. Otherwise null is returned.



getDebugger
final public Debugger getDebugger()(Code)
Return the current debugger. the debugger, or null if none is attached.



getDebuggerContextData
final public Object getDebuggerContextData()(Code)
Return the debugger context data associated with current context. the debugger data, or null if debugger is not attached



getE4xImplementationFactory
public XMLLib.Factory getE4xImplementationFactory()(Code)
Returns an object which specifies an E4X implementation to use within this Context. Note that the XMLLib.Factory interface should be considered experimental. The default implementation uses the implementation provided by this Context's ContextFactory . An XMLLib.Factory. Should not return null ifContext.FEATURE_E4X is enabled. See Context.hasFeature.



getElements
final public Object[] getElements(Scriptable object)(Code)
Get the elements of a JavaScript array.

If the object defines a length property convertible to double number, then the number is converted Uint32 value as defined in Ecma 9.6 and Java array of that size is allocated. The array is initialized with the values obtained by calling get() on object for each value of i in [0,length-1]. If there is not a defined value for a property the Undefined value is used to initialize the corresponding element in the array. The Java array is then returned. If the object doesn't define a length property or it is not a number, empty array is returned.
Parameters:
  object - the JavaScript array or array-like object a Java array of objects
since:
   1.4 release 2




getErrorReporter
final public ErrorReporter getErrorReporter()(Code)
Get the current error reporter.
See Also:   org.mozilla.javascript.ErrorReporter



getFactory
final public ContextFactory getFactory()(Code)
Return ContextFactory instance used to create this Context.



getImplementationVersion
final public String getImplementationVersion()(Code)
Get the implementation version.

The implementation version is of the form

 "name langVer release relNum date"
 
where name is the name of the product, langVer is the language version, relNum is the release number, and date is the release date for that specific release in the form "yyyy mm dd". a string that encodes the product, language version, releasenumber, and date.



getInstructionObserverThreshold
final public int getInstructionObserverThreshold()(Code)
Get threshold of executed instructions counter that triggers call to observeInstructionCount(). When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, observeInstructionCount() will be called.



getLanguageVersion
final public int getLanguageVersion()(Code)
Get the current language version.

The language version number affects JavaScript semantics as detailed in the overview documentation. an integer that is one of VERSION_1_0, VERSION_1_1, etc.




getLocale
final public Locale getLocale()(Code)
Get the current locale. Returns the default locale if none has been set.
See Also:   java.util.Locale



getMaximumInterpreterStackDepth
final public int getMaximumInterpreterStackDepth()(Code)
Returns the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations. The current maximum interpreter stack depth.



getOptimizationLevel
final public int getOptimizationLevel()(Code)
Get the current optimization level.

The optimization level is expressed as an integer between -1 and 9.
since:
   1.3




getRegExpProxy
RegExpProxy getRegExpProxy()(Code)



getSecurityController
SecurityController getSecurityController()(Code)



getSourcePositionFromStack
static String getSourcePositionFromStack(int[] linep)(Code)



getThreadLocal
final public Object getThreadLocal(Object key)(Code)
Get a value corresponding to a key.

Since the Context is associated with a thread it can be used to maintain values that can be later retrieved using the current thread.

Note that the values are maintained with the Context, so if the Context is disassociated from the thread the values cannot be retrieved. Also, if private data is to be maintained in this manner the key should be a java.lang.Object whose reference is not divulged to untrusted code.
Parameters:
  key - the key used to lookup the value a value previously stored using putThreadLocal.




getUndefinedValue
public static Object getUndefinedValue()(Code)
Get the singleton object that represents the JavaScript Undefined value.



getWrapFactory
final public WrapFactory getWrapFactory()(Code)
Return the current WrapFactory, or null if none is defined.
See Also:   WrapFactory
since:
   1.5 Release 4



hasCompileFunctionsWithDynamicScope
final public boolean hasCompileFunctionsWithDynamicScope()(Code)

See Also:   Context.FEATURE_DYNAMIC_SCOPE
See Also:   Context.hasFeature(int)



hasFeature
public boolean hasFeature(int featureIndex)(Code)
Controls certain aspects of script semantics. Should be overwritten to alter default behavior.

The default implementation calls ContextFactory.hasFeature(Context cxint featureIndex) that allows to customize Context behavior without introducing Context subclasses. ContextFactory documentation gives an example of hasFeature implementation.
Parameters:
  featureIndex - feature index to check true if the featureIndex feature is turned on
See Also:   Context.FEATURE_NON_ECMA_GET_YEAR
See Also:   Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME
See Also:   Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER
See Also:   Context.FEATURE_TO_STRING_AS_SOURCE
See Also:   Context.FEATURE_PARENT_PROTO_PROPRTIES
See Also:   Context.FEATURE_E4X
See Also:   Context.FEATURE_DYNAMIC_SCOPE
See Also:   Context.FEATURE_STRICT_VARS
See Also:   Context.FEATURE_STRICT_EVAL
See Also:   Context.FEATURE_LOCATION_INFORMATION_IN_ERROR
See Also:   Context.FEATURE_STRICT_MODE
See Also:   Context.FEATURE_WARNING_AS_ERROR
See Also:   Context.FEATURE_ENHANCED_JAVA_ACCESS




initStandardObjects
final public ScriptableObject initStandardObjects()(Code)
Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon. the initialized scope




initStandardObjects
final public Scriptable initStandardObjects(ScriptableObject scope)(Code)
Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.
Parameters:
  scope - the scope to initialize, or null, in which case a newobject will be created to serve as the scope the initialized scope. The method returns the value of the scopeargument if it is not null or newly allocated scope object whichis an instance ScriptableObject.




initStandardObjects
public ScriptableObject initStandardObjects(ScriptableObject scope, boolean sealed)(Code)
Initialize the standard objects. Creates instances of the standard objects and their constructors (Object, String, Number, Date, etc.), setting up 'scope' to act as a global object as in ECMA 15.1.

This method must be called to initialize a scope before scripts can be evaluated in that scope.

This method does not affect the Context it is called upon.

This form of the method also allows for creating "sealed" standard objects. An object that is sealed cannot have properties added, changed, or removed. This is useful to create a "superglobal" that can be shared among several top-level objects. Note that sealing is not allowed in the current ECMA/ISO language specification, but is likely for the next version.
Parameters:
  scope - the scope to initialize, or null, in which case a newobject will be created to serve as the scope
Parameters:
  sealed - whether or not to create sealed standard objects thatcannot be modified. the initialized scope. The method returns the value of the scopeargument if it is not null or newly allocated scope object.
since:
   1.4R3




isActivationNeeded
final public boolean isActivationNeeded(String name)(Code)
Check whether the name is in the list of names of objects forcing the creation of activation objects.
Parameters:
  name - the name of the object to test true if an function activation object is needed.



isGeneratingDebug
final public boolean isGeneratingDebug()(Code)
Tell whether debug information is being generated.
since:
   1.3



isGeneratingDebugChanged
final public boolean isGeneratingDebugChanged()(Code)



isGeneratingSource
final public boolean isGeneratingSource()(Code)
Tell whether source information is being generated.
since:
   1.3



isSealed
final public boolean isSealed()(Code)
Checks if this is a sealed Context. A sealed Context instance does not allow to modify any of its properties and will throw an exception on any such attempt.
See Also:   Context.seal(Object sealKey)



isValidLanguageVersion
public static boolean isValidLanguageVersion(int version)(Code)



isValidOptimizationLevel
public static boolean isValidOptimizationLevel(int optimizationLevel)(Code)



isVersionECMA1
final boolean isVersionECMA1()(Code)



javaToJS
public static Object javaToJS(Object value, Scriptable scope)(Code)
Convenient method to convert java value to its closest representation in JavaScript.

If value is an instance of String, Number, Boolean, Function or Scriptable, it is returned as it and will be treated as the corresponding JavaScript type of string, number, boolean, function and object.

Note that for Number instances during any arithmetic operation in JavaScript the engine will always use the result of Number.doubleValue() resulting in a precision loss if the number can not fit into double.

If value is an instance of Character, it will be converted to string of length 1 and its JavaScript type will be string.

The rest of values will be wrapped as LiveConnect objects by calling WrapFactory.wrap(Context cxScriptable scopeObject objClass staticType) as in:

 Context cx = Context.getCurrentContext();
 return cx.getWrapFactory().wrap(cx, scope, value, null);
 

Parameters:
  value - any Java object
Parameters:
  scope - top scope object value suitable to pass to any API that takes JavaScript values.



jsToJava
public static Object jsToJava(Object value, Class desiredType) throws EvaluatorException(Code)
Convert a JavaScript value into the desired type. Uses the semantics defined with LiveConnect3 and throws an Illegal argument exception if the conversion cannot be performed.
Parameters:
  value - the JavaScript value to convert
Parameters:
  desiredType - the Java type to convert to. Primitive Javatypes are represented using the TYPE fields in the correspondingwrapper class in java.lang. the converted value
throws:
  EvaluatorException - if the conversion cannot be performed



newArray
final public Scriptable newArray(Scriptable scope, int length)(Code)
Create an array with a specified initial length.


Parameters:
  scope - the scope to create the object in
Parameters:
  length - the initial length (JavaScript arrays may haveadditional properties added dynamically). the new array object




newArray
final public Scriptable newArray(Scriptable scope, Object[] elements)(Code)
Create an array with a set of initial elements.
Parameters:
  scope - the scope to create the object in.
Parameters:
  elements - the initial elements. Each object in this arraymust be an acceptable JavaScript type and typeof array should be exactly Object[], notSomeObjectSubclass[]. the new array object.



newObject
final public Scriptable newObject(Scriptable scope)(Code)
Create a new JavaScript object. Equivalent to evaluating "new Object()".
Parameters:
  scope - the scope to search for the constructor and to evaluateagainst the new object



newObject
final public Scriptable newObject(Scriptable scope, String constructorName)(Code)
Create a new JavaScript object by executing the named constructor. The call newObject(scope, "Foo") is equivalent to evaluating "new Foo()".
Parameters:
  scope - the scope to search for the constructor and to evaluate against
Parameters:
  constructorName - the name of the constructor to call the new object



newObject
final public Scriptable newObject(Scriptable scope, String constructorName, Object[] args)(Code)
Creates a new JavaScript object by executing the named constructor. Searches scope for the named constructor, calls it with the given arguments, and returns the result.

The code

 Object[] args = { "a", "b" };
 newObject(scope, "Foo", args)
is equivalent to evaluating "new Foo('a', 'b')", assuming that the Foo constructor has been defined in scope.
Parameters:
  scope - The scope to search for the constructor and to evaluateagainst
Parameters:
  constructorName - the name of the constructor to call
Parameters:
  args - the array of arguments for the constructor the new object



observeInstructionCount
protected void observeInstructionCount(int instructionCount)(Code)
Allow application to monitor counter of executed script instructions in Context subclasses. Run-time calls this when instruction counting is enabled and the counter reaches limit set by setInstructionObserverThreshold(). The method is useful to observe long running scripts and if necessary to terminate them.

The instruction counting support is available only for interpreted scripts generated when the optimization level is set to -1.

The default implementation calls ContextFactory.observeInstructionCount(Context cxint instructionCount) that allows to customize Context behavior without introducing Context subclasses.
Parameters:
  instructionCount - amount of script instruction executed sincelast call to observeInstructionCount
throws:
  Error - to terminate the script
See Also:   Context.setOptimizationLevel(int)




onSealedMutation
static void onSealedMutation()(Code)



putThreadLocal
final public void putThreadLocal(Object key, Object value)(Code)
Put a value that can later be retrieved using a given key.


Parameters:
  key - the key used to index the value
Parameters:
  value - the value to save




removeActivationName
public void removeActivationName(String name)(Code)
Remove a name from the list of names forcing the creation of real activation objects for functions.
Parameters:
  name - the name of the object to remove from the list



removeContextListener
public static void removeContextListener(ContextListener listener)(Code)

See Also:   ContextFactory.removeListener(ContextFactory.Listener)
See Also:   ContextFactory.getGlobal



removePropertyChangeListener
final public void removePropertyChangeListener(PropertyChangeListener l)(Code)
Remove an object from the list of objects registered to receive notification of changes to a bounded property
See Also:   java.beans.PropertyChangeEvent
See Also:   Context.addPropertyChangeListener(java.beans.PropertyChangeListener)
Parameters:
  l - the listener



removeThreadLocal
final public void removeThreadLocal(Object key)(Code)
Remove values from thread-local storage.
Parameters:
  key - the key for the entry to remove.
since:
   1.5 release 2



reportError
public static void reportError(String message, String sourceName, int lineno, String lineSource, int lineOffset)(Code)
Report an error using the error reporter for the current thread.
Parameters:
  message - the error message to report
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  lineSource - the text of the line (may be null)
Parameters:
  lineOffset - the offset into lineSource where problem was detected
See Also:   org.mozilla.javascript.ErrorReporter



reportError
public static void reportError(String message)(Code)
Report an error using the error reporter for the current thread.
Parameters:
  message - the error message to report
See Also:   org.mozilla.javascript.ErrorReporter



reportRuntimeError
public static EvaluatorException reportRuntimeError(String message, String sourceName, int lineno, String lineSource, int lineOffset)(Code)
Report a runtime error using the error reporter for the current thread.
Parameters:
  message - the error message to report
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  lineSource - the text of the line (may be null)
Parameters:
  lineOffset - the offset into lineSource where problem was detected a runtime exception that will be thrown to terminate theexecution of the script
See Also:   org.mozilla.javascript.ErrorReporter



reportRuntimeError
public static EvaluatorException reportRuntimeError(String message)(Code)
Report a runtime error using the error reporter for the current thread.
Parameters:
  message - the error message to report
See Also:   org.mozilla.javascript.ErrorReporter



reportRuntimeError0
static EvaluatorException reportRuntimeError0(String messageId)(Code)



reportRuntimeError1
static EvaluatorException reportRuntimeError1(String messageId, Object arg1)(Code)



reportRuntimeError2
static EvaluatorException reportRuntimeError2(String messageId, Object arg1, Object arg2)(Code)



reportRuntimeError3
static EvaluatorException reportRuntimeError3(String messageId, Object arg1, Object arg2, Object arg3)(Code)



reportRuntimeError4
static EvaluatorException reportRuntimeError4(String messageId, Object arg1, Object arg2, Object arg3, Object arg4)(Code)



reportWarning
public static void reportWarning(String message, String sourceName, int lineno, String lineSource, int lineOffset)(Code)
Report a warning using the error reporter for the current thread.
Parameters:
  message - the warning message to report
Parameters:
  sourceName - a string describing the source, such as a filename
Parameters:
  lineno - the starting line number
Parameters:
  lineSource - the text of the line (may be null)
Parameters:
  lineOffset - the offset into lineSource where problem was detected
See Also:   org.mozilla.javascript.ErrorReporter



reportWarning
public static void reportWarning(String message)(Code)
Report a warning using the error reporter for the current thread.
Parameters:
  message - the warning message to report
See Also:   org.mozilla.javascript.ErrorReporter



reportWarning
public static void reportWarning(String message, Throwable t)(Code)



seal
final public void seal(Object sealKey)(Code)
Seal this Context object so any attempt to modify any of its properties including calling Context.enter() and Context.exit() methods will throw an exception.

If sealKey is not null, calling Context.unseal(Object sealKey) with the same key unseals the object. If sealKey is null, unsealing is no longer possible.
See Also:   Context.isSealed()
See Also:   Context.unseal(Object)




setApplicationClassLoader
final public void setApplicationClassLoader(ClassLoader loader)(Code)



setCachingEnabled
public static void setCachingEnabled(boolean cachingEnabled)(Code)

See Also:   ClassCache.get(Scriptable)
See Also:   ClassCache.setCachingEnabled(boolean)



setClassShutter
final public void setClassShutter(ClassShutter shutter)(Code)
Set the LiveConnect access filter for this context.

ClassShutter may only be set if it is currently null. Otherwise a SecurityException is thrown.
Parameters:
  shutter - a ClassShutter object
throws:
  SecurityException - if there is already a ClassShutterobject for this Context




setCompileFunctionsWithDynamicScope
final public void setCompileFunctionsWithDynamicScope(boolean flag)(Code)

See Also:   Context.FEATURE_DYNAMIC_SCOPE
See Also:   Context.hasFeature(int)



setDebugger
final public void setDebugger(Debugger debugger, Object contextData)(Code)
Set the associated debugger.
Parameters:
  debugger - the debugger to be used on callbacks fromthe engine.
Parameters:
  contextData - arbitrary object that debugger can use to storeper Context data.



setErrorReporter
final public ErrorReporter setErrorReporter(ErrorReporter reporter)(Code)
Change the current error reporter. the previous error reporter
See Also:   org.mozilla.javascript.ErrorReporter



setGenerateObserverCount
public void setGenerateObserverCount(boolean generateObserverCount)(Code)
Turn on or off generation of code with callbacks to track the count of executed instructions. Currently only affects JVM byte code generation: this slows down the generated code, but code generated without the callbacks will not be counted toward instruction thresholds. Rhino's interpretive mode does instruction counting without inserting callbacks, so there is no requirement to compile code differently.
Parameters:
  generateObserverCount - if true, generated code will containcalls to accumulate an estimate of the instructions executed.



setGeneratingDebug
final public void setGeneratingDebug(boolean generatingDebug)(Code)
Specify whether or not debug information should be generated.

Setting the generation of debug information on will set the optimization level to zero.
since:
   1.3




setGeneratingSource
final public void setGeneratingSource(boolean generatingSource)(Code)
Specify whether or not source information should be generated.

Without source information, evaluating the "toString" method on JavaScript functions produces only "[native code]" for the body of the function. Note that code generated without source is not fully ECMA conformant.
since:
   1.3




setInstructionObserverThreshold
final public void setInstructionObserverThreshold(int threshold)(Code)
Set threshold of executed instructions counter that triggers call to observeInstructionCount(). When the threshold is zero, instruction counting is disabled, otherwise each time the run-time executes at least the threshold value of script instructions, observeInstructionCount() will be called.

Note that the meaning of "instruction" is not guaranteed to be consistent between compiled and interpretive modes: executing a given script or function in the different modes will result in different instruction counts against the threshold. Context.setGenerateObserverCount is called with true if threshold is greater than zero, false otherwise.
Parameters:
  threshold - The instruction threshold




setLanguageVersion
public void setLanguageVersion(int version)(Code)
Set the language version.

Setting the language version will affect functions and scripts compiled subsequently. See the overview documentation for version-specific behavior.
Parameters:
  version - the version as specified by VERSION_1_0, VERSION_1_1, etc.




setLocale
final public Locale setLocale(Locale loc)(Code)
Set the current locale.
See Also:   java.util.Locale



setMaximumInterpreterStackDepth
final public void setMaximumInterpreterStackDepth(int max)(Code)
Sets the maximum stack depth (in terms of number of call frames) allowed in a single invocation of interpreter. If the set depth would be exceeded, the interpreter will throw an EvaluatorException in the script. Defaults to Integer.MAX_VALUE. The setting only has effect for interpreted functions (those compiled with optimization level set to -1). As the interpreter doesn't use the Java stack but rather manages its own stack in the heap memory, a runaway recursion in interpreted code would eventually consume all available memory and cause OutOfMemoryError instead of a StackOverflowError limited to only a single thread. This setting helps prevent such situations.
Parameters:
  max - the new maximum interpreter stack depth
throws:
  IllegalStateException - if this context's optimization level is not-1
throws:
  IllegalArgumentException - if the new depth is not at least 1



setOptimizationLevel
final public void setOptimizationLevel(int optimizationLevel)(Code)
Set the current optimization level.

The optimization level is expected to be an integer between -1 and 9. Any negative values will be interpreted as -1, and any values greater than 9 will be interpreted as 9. An optimization level of -1 indicates that interpretive mode will always be used. Levels 0 through 9 indicate that class files may be generated. Higher optimization levels trade off compile time performance for runtime performance. The optimizer level can't be set greater than -1 if the optimizer package doesn't exist at run time.
Parameters:
  optimizationLevel - an integer indicating the level ofoptimization to perform
since:
   1.3




setSecurityController
final public void setSecurityController(SecurityController controller)(Code)
Set the security controller for this context.

SecurityController may only be set if it is currently null and SecurityController.hasGlobal is false. Otherwise a SecurityException is thrown.
Parameters:
  controller - a SecurityController object
throws:
  SecurityException - if there is already a SecurityControllerobject for this Context or globally installed.
See Also:   SecurityController.initGlobal(SecurityController controller)
See Also:   SecurityController.hasGlobal




setWrapFactory
final public void setWrapFactory(WrapFactory wrapFactory)(Code)
Set a WrapFactory for this Context.

The WrapFactory allows custom object wrapping behavior for Java object manipulated with JavaScript.
See Also:   WrapFactory
since:
   1.5 Release 4




stringIsCompilableUnit
final public boolean stringIsCompilableUnit(String source)(Code)
Check whether a string is ready to be compiled.

stringIsCompilableUnit is intended to support interactive compilation of javascript. If compiling the string would result in an error that might be fixed by appending more source, this method returns false. In every other case, it returns true.

Interactive shells may accumulate source lines, using this method after each new line is appended to check whether the statement being entered is complete.
Parameters:
  source - the source buffer to check whether the source is ready for compilation
since:
   1.4 Release 2




throwAsScriptRuntimeEx
public static RuntimeException throwAsScriptRuntimeEx(Throwable e)(Code)
Rethrow the exception wrapping it as the script runtime exception. Unless the exception is instance of EcmaError or EvaluatorException it will be wrapped as WrappedException , a subclass of EvaluatorException . The resulting exception object always contains source name and line number of script that triggered exception.

This method always throws an exception, its return value is provided only for convenience to allow a usage like:

 throw Context.throwAsScriptRuntimeEx(ex);
 
to indicate that code after the method is unreachable.
throws:
  EvaluatorException -
throws:
  EcmaError -



toBoolean
public static boolean toBoolean(Object value)(Code)
Convert the value to a JavaScript boolean value.

See ECMA 9.2.
Parameters:
  value - a JavaScript value the corresponding boolean value converted usingthe ECMA rules




toNumber
public static double toNumber(Object value)(Code)
Convert the value to a JavaScript Number value.

Returns a Java double for the JavaScript Number.

See ECMA 9.3.
Parameters:
  value - a JavaScript value the corresponding double value converted usingthe ECMA rules




toObject
public static Scriptable toObject(Object value, Scriptable scope)(Code)
Convert the value to an JavaScript object value.

Note that a scope must be provided to look up the constructors for Number, Boolean, and String.

See ECMA 9.9.

Additionally, arbitrary Java objects and classes will be wrapped in a Scriptable object with its Java fields and methods reflected as JavaScript properties of the object.
Parameters:
  value - any Java object
Parameters:
  scope - global scope containing constructors for Number,Boolean, and String new JavaScript object




toObject
public static Scriptable toObject(Object value, Scriptable scope, Class staticType)(Code)

See Also:   Context.toObject(Object,Scriptable)



toString
public static String toString(Object value)(Code)
Convert the value to a JavaScript String value.

See ECMA 9.8.


Parameters:
  value - a JavaScript value the corresponding String value converted usingthe ECMA rules




toType
public static Object toType(Object value, Class desiredType) throws IllegalArgumentException(Code)

See Also:   Context.jsToJava(Object,Class)
throws:
  IllegalArgumentException - if the conversion cannot be performed.Note that Context.jsToJava(Object,Class) throwsEvaluatorException instead.



unseal
final public void unseal(Object sealKey)(Code)
Unseal previously sealed Context object. The sealKey argument should not be null and should match sealKey suplied with the last call to Context.seal(Object) or an exception will be thrown.
See Also:   Context.isSealed()
See Also:   Context.seal(Object sealKey)



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.