Java Doc for Context.java in  » 6.0-JDK-Modules-sun » javac-compiler » com » sun » tools » javac » util » 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 » 6.0 JDK Modules sun » javac compiler » com.sun.tools.javac.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.tools.javac.util.Context

Context
public class Context (Code)
Support for an abstract context, modelled loosely after ThreadLocal but using a user-provided context instead of the current thread.

Within the compiler, a single Context is used for each invocation of the compiler. The context is then used to ensure a single copy of each compiler phase exists per compiler invocation.

The context can be used to assist in extending the compiler by extending its components. To do that, the extended component must be registered before the base component. We break initialization cycles by (1) registering a factory for the component rather than the component itself, and (2) a convention for a pattern of usage in which each base component registers itself by calling an instance method that is overridden in extended components. A base phase supporting extension would look something like this:

 public class Phase {
 protected static final Context.Key phaseKey =
 new Context.Key();
 public static Phase instance(Context context) {
 Phase instance = context.get(phaseKey);
 if (instance == null)
 // the phase has not been overridden
 instance = new Phase(context);
 return instance;
 }
 protected Phase(Context context) {
 context.put(phaseKey, this);
 // other intitialization follows...
 }
 }
 

In the compiler, we simply use Phase.instance(context) to get the reference to the phase. But in extensions of the compiler, we must register extensions of the phases to replace the base phase, and this must be done before any reference to the phase is accessed using Phase.instance(). An extended phase might be declared thus:

 public class NewPhase extends Phase {
 protected NewPhase(Context context) {
 super(context);
 }
 public static void preRegister(final Context context) {
 context.put(phaseKey, new Context.Factory() {
 public Phase make() {
 return new NewPhase(context);
 }
 });
 }
 }
 

And is registered early in the extended compiler like this

 NewPhase.preRegister(context);
 

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Inner Class :public static class Key
Inner Class :public static interface Factory


Constructor Summary
public  Context()
    

Method Summary
public  voidclear()
    
public  voiddump()
    
public  Tget(Key<T> key)
     Get the value for the key in this context.
public  Tget(Class<T> clazz)
    
public  voidput(Key<T> key, Factory<T> fac)
     Set the factory for the key in this context.
public  voidput(Key<T> key, T data)
     Set the value for the key in this context.
public  voidput(Class<T> clazz, T data)
    
public  voidput(Class<T> clazz, Factory<T> fac)
    


Constructor Detail
Context
public Context()(Code)




Method Detail
clear
public void clear()(Code)



dump
public void dump()(Code)



get
public T get(Key<T> key)(Code)
Get the value for the key in this context.



get
public T get(Class<T> clazz)(Code)



put
public void put(Key<T> key, Factory<T> fac)(Code)
Set the factory for the key in this context.



put
public void put(Key<T> key, T data)(Code)
Set the value for the key in this context.



put
public void put(Class<T> clazz, T data)(Code)



put
public void put(Class<T> clazz, Factory<T> fac)(Code)



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.