Source Code Cross Referenced for JavaTestExtension.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:         * JavaTestExtension.java --
003:         *
004:         *	This file contains loads classes needed by the Jacl
005:         *	test suite.
006:         *
007:         * Copyright (c) 1997 Sun Microsystems, Inc.
008:         *
009:         * See the file "license.terms" for information on usage and
010:         * redistribution of this file, and for a DISCLAIMER OF ALL
011:         * WARRANTIES.
012:         *
013:         * RCS: @(#) $Id: JavaTestExtension.java,v 1.9 2006/08/03 23:24:03 mdejong Exp $
014:         *
015:         */
016:
017:        package tcl.lang;
018:
019:        import java.util.*;
020:
021:        /*
022:         * This Extension class contains commands used by the Jacl
023:         * test suite.
024:         */
025:
026:        public class JavaTestExtension extends Extension {
027:
028:            /*
029:             *----------------------------------------------------------------------
030:             *
031:             * init --
032:             *
033:             *	Initializes the JavaTestExtension.
034:             *
035:             * Results:
036:             *	None.
037:             *
038:             * Side effects:
039:             *	Commands are created in the interpreter.
040:             *
041:             *----------------------------------------------------------------------
042:             */
043:
044:            public void init(Interp interp) {
045:                interp.createCommand("jtest", new JtestCmd());
046:                interp.createCommand("testevalex", new TestEvalExCmd());
047:                interp.createCommand("testparser", new TestParserCmd());
048:                interp.createCommand("testparsevar", new TestParsevarCmd());
049:                interp.createCommand("testparsevarname",
050:                        new TestParsevarnameCmd());
051:                interp.createCommand("testexprparser", new TestExprParserCmd());
052:                interp.createCommand("testevalobjv", new TestEvalObjvCmd());
053:                interp.createCommand("testcompcode", new TestcompcodeCmd());
054:                interp.createCommand("testsetplatform",
055:                        new TestsetplatformCmd());
056:                interp.createCommand("testtranslatefilename",
057:                        new TesttranslatefilenameCmd());
058:                interp.createCommand("testchannel", new TestChannelCmd());
059:                interp.createCommand("testvarframe", new TestVarFrameCmd());
060:                interp.createCommand("testtclobjectmemory",
061:                        new TclObjectMemory());
062:                interp.createCommand("testinterpdelete",
063:                        new TestInterpDeleteCmd());
064:
065:                // Create "testobj" and friends
066:                TestObjCmd.init(interp);
067:
068:                // Create "T1" and "T2" test expr functions
069:                createExprTestFunctions(interp);
070:            }
071:
072:            void createExprTestFunctions(Interp interp) {
073:                Expression expr = interp.expr;
074:                expr.registerMathFunction("T1", new TestMathFunc(123));
075:                expr.registerMathFunction("T2", new TestMathFunc(345));
076:                expr.registerMathFunction("T3", new TestMathFunc2());
077:            }
078:
079:        } // JavaTestExtension
080:
081:        // Implement "T1" and "T2" expr math functions
082:
083:        class TestMathFunc extends NoArgMathFunction {
084:            int clientData;
085:
086:            TestMathFunc(int clientData) {
087:                this .clientData = clientData;
088:            }
089:
090:            void apply(Interp interp, ExprValue value) throws TclException {
091:                value.setIntValue(clientData);
092:            }
093:        }
094:
095:        // Implement "T3" expr math function
096:
097:        class TestMathFunc2 extends MathFunction {
098:
099:            TestMathFunc2() {
100:                argTypes = new int[2];
101:                argTypes[0] = EITHER;
102:                argTypes[1] = EITHER;
103:            }
104:
105:            // Return the maximum of the two arguments with the correct type.
106:
107:            void apply(Interp interp, ExprValue[] values) throws TclException {
108:                ExprValue arg0 = values[0];
109:                ExprValue arg1 = values[1];
110:
111:                if (arg0.isIntType()) {
112:                    int i0 = arg0.getIntValue();
113:
114:                    if (arg1.isIntType()) {
115:                        int i1 = arg1.getIntValue();
116:                        arg0.setIntValue(((i0 > i1) ? i0 : i1));
117:                    } else if (arg1.isDoubleType()) {
118:                        double d0 = (double) i0;
119:                        double d1 = arg1.getDoubleValue();
120:                        arg0.setDoubleValue(((d0 > d1) ? d0 : d1));
121:                    } else {
122:                        throw new TclException(interp,
123:                                "T3: wrong type for arg 2");
124:                    }
125:                } else if (arg0.isDoubleType()) {
126:                    double d0 = arg0.getDoubleValue();
127:
128:                    if (arg1.isIntType()) {
129:                        double d1 = (double) arg1.getIntValue();
130:                        arg0.setDoubleValue(((d0 > d1) ? d0 : d1));
131:                    } else if (arg1.isDoubleType()) {
132:                        double d1 = arg1.getDoubleValue();
133:                        arg0.setDoubleValue(((d0 > d1) ? d0 : d1));
134:                    } else {
135:                        throw new TclException(interp,
136:                                "T3: wrong type for arg 2");
137:                    }
138:                } else {
139:                    throw new TclException(interp, "T3: wrong type for arg 1");
140:                }
141:            }
142:        }
143:
144:        class TestAssocData implements  AssocData {
145:            Interp interp;
146:            String testCmd;
147:            String removeCmd;
148:
149:            public TestAssocData(Interp i, String tcmd, String rcmd) {
150:                interp = i;
151:                testCmd = tcmd;
152:                removeCmd = rcmd;
153:            }
154:
155:            public void disposeAssocData(Interp interp) {
156:                try {
157:                    interp.eval(removeCmd);
158:                } catch (TclException e) {
159:                    throw new TclRuntimeError("unexpected TclException: " + e);
160:                }
161:            }
162:
163:            public void test() throws TclException {
164:                interp.eval(testCmd);
165:            }
166:
167:            public String getData() throws TclException {
168:                return testCmd;
169:            }
170:
171:        } // end TestAssocData
172:
173:        class Test2AssocData implements  AssocData {
174:            String internalData;
175:
176:            public Test2AssocData(String data) {
177:                internalData = data;
178:            }
179:
180:            public void disposeAssocData(Interp interp) {
181:            }
182:
183:            public String getData() throws TclException {
184:                return internalData;
185:            }
186:
187:        } // end Test2AssocData
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.