Source Code Cross Referenced for PutsCmd.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) 


01:        /*
02:         * PutsCmd.java
03:         *
04:         * Copyright (c) 1997 Cornell University.
05:         * Copyright (c) 1997 Sun Microsystems, Inc.
06:         *
07:         * See the file "license.terms" for information on usage and
08:         * redistribution of this file, and for a DISCLAIMER OF ALL
09:         * WARRANTIES.
10:         * 
11:         * RCS: @(#) $Id: PutsCmd.java,v 1.6 2002/01/21 06:34:26 mdejong Exp $
12:         *
13:         */
14:
15:        package tcl.lang;
16:
17:        import java.util.*;
18:        import java.io.*;
19:
20:        /**
21:         * This class implements the built-in "puts" command in Tcl.
22:         */
23:
24:        class PutsCmd implements  Command {
25:            /**
26:             * Prints the given string to a channel. See Tcl user
27:             * documentation for details.
28:             *
29:             * @param interp the current interpreter.
30:             * @param argv command arguments.
31:             */
32:
33:            public void cmdProc(Interp interp, TclObject argv[])
34:                    throws TclException {
35:
36:                Channel chan; // The channel being operated on this method
37:                String channelId; // String containing the key to chanTable
38:                String arg; // Argv[i] converted to a string
39:                int i = 1; // Index to the next arg in argv
40:                boolean newline = true;
41:                // Indicates to print a newline in result
42:
43:                if ((argv.length >= 2)
44:                        && (argv[1].toString().equals("-nonewline"))) {
45:                    newline = false;
46:                    i++;
47:                }
48:                if ((i < argv.length - 3) || (i >= argv.length)) {
49:                    throw new TclNumArgsException(interp, 1, argv,
50:                            "?-nonewline? ?channelId? string");
51:                }
52:
53:                // The code below provides backwards compatibility with an old
54:                // form of the command that is no longer recommended or documented.
55:
56:                if (i == (argv.length - 3)) {
57:                    arg = argv[i + 2].toString();
58:                    if (!arg.equals("nonewline")) {
59:                        throw new TclException(interp, "bad argument \"" + arg
60:                                + "\": should be \"nonewline\"");
61:                    }
62:                    newline = false;
63:                }
64:
65:                if (i == (argv.length - 1)) {
66:                    channelId = "stdout";
67:                } else {
68:                    channelId = argv[i].toString();
69:                    i++;
70:                }
71:
72:                if (i != (argv.length - 1)) {
73:                    throw new TclNumArgsException(interp, 1, argv,
74:                            "?-nonewline? ?channelId? string");
75:                }
76:
77:                chan = TclIO.getChannel(interp, channelId);
78:                if (chan == null) {
79:                    throw new TclException(interp,
80:                            "can not find channel named \"" + channelId + "\"");
81:                }
82:
83:                try {
84:                    if (newline) {
85:                        chan.write(interp, argv[i]);
86:                        chan.write(interp, "\n");
87:                    } else {
88:                        chan.write(interp, argv[i]);
89:                    }
90:                } catch (IOException e) {
91:                    throw new TclRuntimeError(
92:                            "PutsCmd.cmdProc() Error: IOException when putting "
93:                                    + chan.getChanName());
94:                }
95:            }
96:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.