Java Doc for Context.java in  » Ajax » GWT » com » google » gwt » dev » js » rhino » 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 » Ajax » GWT » com.google.gwt.dev.js.rhino 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.google.gwt.dev.js.rhino.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 enter() method.

The behavior of the execution engine may be altered through methods such as setErrorReporter.

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_MEMBER_EXPR_AS_FUNCTION_NAME
     if hasFeature(FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME) returns true, allow 'function (...) { ...
final public static  intFEATURE_NON_ECMA_GET_YEAR
    
final public static  intFEATURE_RESERVED_KEYWORD_AS_IDENTIFIER
    
final public static  intFEATURE_TO_STRING_AS_SOURCE
     if hasFeature(FEATURE_TO_STRING_AS_SOURCE) returns true, calling toString on JS objects gives JS source with code to create an object with all enumeratable fields of the original object instead of printing "[object ]".
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_DEFAULT
     The default version.
final public static  intVERSION_UNKNOWN
     The unknown version.
final static  booleancheck
    
final static  StringdefaultResource
    
 interrorCount
    
final public static  StringerrorReporterProperty
    
 intinstructionCount
    
 intinstructionThreshold
    
final public static  StringlanguageVersionProperty
    
final static  booleanprintICode
    
final static  booleanprintTrees
    
 intversion
    

Constructor Summary
public  Context()
     Create a new Context.

Method Summary
static  voidcodeBug()
    
public static  Contextenter()
     Get a context associated with the current thread, creating one if need be. The Context stores the execution state of the JavaScript engine, so it is required that the context be entered before execution may begin.
public static  Contextenter(Context cx)
     Get a Context associated with the current thread, using the given Context if need be.
public static  voidexit()
     Exit a block of code requiring a Context.
 voidfirePropertyChange(String property, Object oldValue, Object newValue)
    
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  ErrorReportergetErrorReporter()
     Get the current error reporter.
public  StringgetImplementationVersion()
     Get the implementation version.
public  intgetLanguageVersion()
     Get the current language version.
public  LocalegetLocale()
     Get the current locale.
static  StringgetMessage(String messageId, Object[] arguments)
    
static  StringgetMessage0(String messageId)
    
static  StringgetMessage1(String messageId, Object arg1)
    
static  StringgetMessage2(String messageId, Object arg1, Object arg2)
    
static  StringgetMessage3(String messageId, Object arg1, Object arg2, Object arg3)
    
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 retreived.

final public  booleanhasCompileFunctionsWithDynamicScope()
     Return whether functions are compiled by this context using dynamic scope.
public  booleanhasFeature(int featureIndex)
     Controls certain aspects of script semantics.
final  booleanisVersionECMA1()
    
public  voidputThreadLocal(Object key, Object value)
     Put a value that can later be retrieved using a given key.
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  voidreportWarning(String message, String sourceName, int lineno, String lineSource, int lineOffset)
     Report a warning using the error reporter for the current thread.
public  voidsetCompileFunctionsWithDynamicScope(boolean flag)
     Set whether functions compiled by this context should use dynamic scope.
public  ErrorReportersetErrorReporter(ErrorReporter reporter)
     Change the current error reporter.
public  voidsetLanguageVersion(int version)
     Set the language version.

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

public  LocalesetLocale(Locale loc)
     Set the current locale.

Field Detail
FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME
final public static int FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME(Code)
if hasFeature(FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME) returns true, allow 'function (...) { ... }' to be syntax sugar for ' = function(...) { ... }', when is not simply identifier. See Ecma-262, section 11.2 for definition of



FEATURE_NON_ECMA_GET_YEAR
final public static int FEATURE_NON_ECMA_GET_YEAR(Code)
if hasFeature(FEATURE_NON_ECMA_GET_YEAR) returns true, Date.prototype.getYear subtructs 1900 only if 1900 <= date < 2000 in deviation with Ecma B.2.4



FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER
final public static int FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER(Code)
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



FEATURE_TO_STRING_AS_SOURCE
final public static int FEATURE_TO_STRING_AS_SOURCE(Code)
if hasFeature(FEATURE_TO_STRING_AS_SOURCE) returns true, calling toString on JS objects gives JS source with code to create an object with all enumeratable fields of the original object instead of printing "[object ]". By default Context.hasFeature(int) returns true only if the current JS version is set to Context.VERSION_1_2 .



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_DEFAULT
final public static int VERSION_DEFAULT(Code)
The default version.



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



check
final static boolean check(Code)



defaultResource
final static String defaultResource(Code)



errorCount
int errorCount(Code)



errorReporterProperty
final public static String errorReporterProperty(Code)



instructionCount
int instructionCount(Code)



instructionThreshold
int instructionThreshold(Code)



languageVersionProperty
final public static String languageVersionProperty(Code)



printICode
final static boolean printICode(Code)



printTrees
final static boolean printTrees(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.
See Also:   org.mozilla.javascript.Context.enter




Method Detail
codeBug
static void codeBug()(Code)



enter
public static Context enter()(Code)
Get a context associated with the current thread, creating one if need be. The Context stores the execution state of the JavaScript engine, so it is required that the context be entered before execution may begin. Once a thread has entered a Context, then getCurrentContext() may be called to find the context that is associated with the current thread.

Calling enter() will return either the Context currently associated with the thread, or will create a new context and associate it with the current thread. Each call to enter() must have a matching call to exit(). For example,

 Context cx = Context.enter();
 try {
 ...
 cx.evaluateString(...);
 }
 finally { Context.exit(); }
 
a Context associated with the current thread
See Also:   org.mozilla.javascript.Context.getCurrentContext
See Also:   org.mozilla.javascript.Context.exit



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 thread




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 enter() 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:   org.mozilla.javascript.Context.enter



firePropertyChange
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:
  newVale - the new value



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:   org.mozilla.javascript.Context.enter
See Also:   org.mozilla.javascript.Context.exit




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



getImplementationVersion
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.



getLanguageVersion
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
public Locale getLocale()(Code)
Get the current locale. Returns the default locale if none has been set.
See Also:   java.util.Locale



getMessage
static String getMessage(String messageId, Object[] arguments)(Code)



getMessage0
static String getMessage0(String messageId)(Code)
end of API *********



getMessage1
static String getMessage1(String messageId, Object arg1)(Code)



getMessage2
static String getMessage2(String messageId, Object arg1, Object arg2)(Code)



getMessage3
static String getMessage3(String messageId, Object arg1, Object arg2, Object arg3)(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 retreived. 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.




hasCompileFunctionsWithDynamicScope
final public boolean hasCompileFunctionsWithDynamicScope()(Code)
Return whether functions are compiled by this context using dynamic scope.

If functions are compiled with dynamic scope, then they execute in the scope of their caller, rather than in their parent scope. This is useful for sharing functions across multiple scopes.
since:
   1.5 Release 1




hasFeature
public boolean hasFeature(int featureIndex)(Code)
Controls certain aspects of script semantics. Should be overwritten to alter default behavior.
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



isVersionECMA1
final boolean isVersionECMA1()(Code)



putThreadLocal
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




removeThreadLocal
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



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



setCompileFunctionsWithDynamicScope
public void setCompileFunctionsWithDynamicScope(boolean flag)(Code)
Set whether functions compiled by this context should use dynamic scope.


Parameters:
  flag - if true, compile functions with dynamic scope
since:
   1.5 Release 1




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



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
public Locale setLocale(Locale loc)(Code)
Set the current locale.
See Also:   java.util.Locale



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.