Source Code Cross Referenced for TJCReadyVar.java in  » Scripting » jacl » tcl » lang » 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 » jacl » tcl.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2006 Mo DeJong
003:         *
004:         * See the file "license.amd" for information on usage and
005:         * redistribution of this file, and for a DISCLAIMER OF ALL
006:         * WARRANTIES.
007:         * 
008:         * RCS: @(#) $Id: TJCReadyVar.java,v 1.1 2006/02/14 04:13:27 mdejong Exp $
009:         *
010:         */
011:
012:        // This class implements the TJCThread.CompiledClassReady
013:        // interface and sets a variable to the results of the
014:        // compilation.
015:        package tcl.lang;
016:
017:        import java.util.ArrayList;
018:
019:        public class TJCReadyVar implements  TJCThread.CompiledClassReady {
020:            final Interp interp;
021:            final String varname;
022:
023:            // Invoked in the calling Thread to indicate
024:            // where a compile result should be stored.
025:            // varname can be either a scalar or array
026:            // variable, it is assumed to be global
027:            // unless it has explicit namespace qualifiers.
028:            // The variable value is initailly set to {}
029:            // whole the compile job is processing.
030:
031:            public TJCReadyVar(Interp interp, String varname) {
032:                this .interp = interp;
033:                this .varname = varname;
034:                try {
035:                    interp.setVar(varname, null, "", TCL.GLOBAL_ONLY);
036:                } catch (TclException te) {
037:                }
038:            }
039:
040:            // Invoked by TJCThread when a compile job
041:            // is finished. This implementation will
042:            // set a variable to a list indicating the
043:            // status.
044:            //
045:            // {STATUS GENINFO FILENAME SRCCODE CNAMES CDATA MSG}
046:            //
047:            // STATUS: OK or FAIL
048:            // GENINFO: Key indicating generated info source
049:            // FILENAME: File name for Java source
050:            // SRCCODE: Java source code that was compiled
051:            // CNAMES: List of names for compiled classes in CDATA
052:            // CDATA: List of compiled class data as reflected byte[] Java objects
053:            // MSG: String indicating compile error if STATUS != OK
054:
055:            public void compiled(final String geninfo, // Name that identifies the source
056:                    // for generated Java code. This
057:                    // "" when compiling a Java file.
058:                    final String jfilename, // File name for Java source,
059:                    // like "Test.java".
060:                    final String jsrcode, // Java source that was compiled.
061:                    final ArrayList cnames, // List of compiled class names.
062:                    final ArrayList cdata, // List of compiled class data as byte[].
063:                    final int status, final String msg) {
064:                // Add event to Tcl queue that will
065:                // calculate and set variable value.
066:
067:                TclEvent event = new TclEvent() {
068:                    public int processEvent(int flags) {
069:                        try {
070:                            TclObject tlist = TclList.newInstance();
071:
072:                            // STATUS
073:                            if (status == TJCThread.STATUS_OK) {
074:                                TclList.append(interp, tlist, TclString
075:                                        .newInstance("OK"));
076:                            } else {
077:                                // FIXME: Check TJCThread status bits for more info.
078:                                TclList.append(interp, tlist, TclString
079:                                        .newInstance("FAIL"));
080:                            }
081:
082:                            // GENINFO
083:                            TclList.append(interp, tlist, TclString
084:                                    .newInstance(geninfo));
085:
086:                            // FILENAME
087:                            TclList.append(interp, tlist, TclString
088:                                    .newInstance(jfilename));
089:
090:                            // SRCCODE
091:                            TclList.append(interp, tlist, TclString
092:                                    .newInstance(jsrcode));
093:
094:                            // CNAMES
095:                            TclObject cnames_list = TclList.newInstance();
096:                            if (cnames != null) {
097:                                for (int i = 0; i < cnames.size(); i++) {
098:                                    TclList
099:                                            .append(
100:                                                    interp,
101:                                                    cnames_list,
102:                                                    TclString
103:                                                            .newInstance((String) cnames
104:                                                                    .get(i)));
105:                                }
106:                            }
107:                            TclList.append(interp, tlist, cnames_list);
108:
109:                            // CDATA
110:                            TclObject cdata_list = TclList.newInstance();
111:                            if (cdata != null) {
112:                                for (int i = 0; i < cdata.size(); i++) {
113:                                    byte[] bytes = (byte[]) cdata.get(i);
114:                                    TclObject tobj;
115:                                    if ((bytes.length == 4) && bytes[0] == 'F'
116:                                            && bytes[1] == 'A'
117:                                            && bytes[2] == 'K'
118:                                            && bytes[3] == 'E') {
119:                                        tobj = TclString.newInstance("FAKE");
120:                                    } else {
121:                                        tobj = ReflectObject.newInstance(
122:                                                interp, byte[].class, bytes);
123:                                    }
124:                                    TclList.append(interp, cdata_list, tobj);
125:                                }
126:                            }
127:                            TclList.append(interp, tlist, cdata_list);
128:
129:                            // MSG
130:                            if (cdata != null) {
131:                                TclList.append(interp, tlist, TclString
132:                                        .newInstance(msg));
133:                            } else {
134:                                TclList.append(interp, tlist, TclString
135:                                        .newInstance(""));
136:                            }
137:
138:                            interp
139:                                    .setVar(varname, null, tlist,
140:                                            TCL.GLOBAL_ONLY);
141:
142:                            //System.out.println("set TJCReadyVar result for variable " + varname);
143:                        } catch (TclException ex) {
144:                            // If an exception was raise, just set the variable to
145:                            // the empty string in case there is a vwait on the var.
146:
147:                            try {
148:                                interp.setVar(varname, null, "",
149:                                        TCL.GLOBAL_ONLY);
150:                            } catch (TclException te) {
151:                            }
152:                        }
153:                        return 1;
154:                    }
155:                };
156:                interp.getNotifier().queueEvent(event, TCL.QUEUE_TAIL);
157:
158:                // Don't want for var to be set, just continue processing
159:                // next event in TJCThread.
160:                //event.sync();
161:            }
162:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.