Source Code Cross Referenced for Echo.java in  » Build » ANT » org » apache » tools » ant » taskdefs » 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 » Build » ANT » org.apache.tools.ant.taskdefs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs;
020:
021:        import java.io.File;
022:        import java.io.FileWriter;
023:        import java.io.IOException;
024:        import java.io.Writer;
025:        import java.io.BufferedWriter;
026:        import java.io.OutputStreamWriter;
027:        import java.io.FileOutputStream;
028:
029:        import org.apache.tools.ant.BuildException;
030:        import org.apache.tools.ant.Project;
031:        import org.apache.tools.ant.Task;
032:        import org.apache.tools.ant.util.FileUtils;
033:        import org.apache.tools.ant.types.LogLevel;
034:
035:        /**
036:         * Writes a message to the Ant logging facilities.
037:         *
038:         * @since Ant 1.1
039:         *
040:         * @ant.task category="utility"
041:         */
042:        public class Echo extends Task {
043:            // CheckStyle:VisibilityModifier OFF - bc
044:            protected String message = "";
045:            protected File file = null;
046:            protected boolean append = false;
047:            /** encoding; set to null or empty means 'default' */
048:            private String encoding = "";
049:
050:            // by default, messages are always displayed
051:            protected int logLevel = Project.MSG_WARN;
052:
053:            // CheckStyle:VisibilityModifier ON
054:
055:            /**
056:             * Does the work.
057:             *
058:             * @exception BuildException if something goes wrong with the build
059:             */
060:            public void execute() throws BuildException {
061:                if (file == null) {
062:                    log(message, logLevel);
063:                } else {
064:                    Writer out = null;
065:                    try {
066:                        String filename = file.getAbsolutePath();
067:                        if (encoding == null || encoding.length() == 0) {
068:                            out = new FileWriter(filename, append);
069:                        } else {
070:                            out = new BufferedWriter(new OutputStreamWriter(
071:                                    new FileOutputStream(filename, append),
072:                                    encoding));
073:                        }
074:                        out.write(message, 0, message.length());
075:                    } catch (IOException ioe) {
076:                        throw new BuildException(ioe, getLocation());
077:                    } finally {
078:                        FileUtils.close(out);
079:                    }
080:                }
081:            }
082:
083:            /**
084:             * Message to write.
085:             *
086:             * @param msg Sets the value for the message variable.
087:             */
088:            public void setMessage(String msg) {
089:                this .message = msg;
090:            }
091:
092:            /**
093:             * File to write to.
094:             * @param file the file to write to, if not set, echo to
095:             *             standard output
096:             */
097:            public void setFile(File file) {
098:                this .file = file;
099:            }
100:
101:            /**
102:             * If true, append to existing file.
103:             * @param append if true, append to existing file, default
104:             *               is false.
105:             */
106:            public void setAppend(boolean append) {
107:                this .append = append;
108:            }
109:
110:            /**
111:             * Set a multiline message.
112:             * @param msg the CDATA text to append to the output text
113:             */
114:            public void addText(String msg) {
115:                message += getProject().replaceProperties(msg);
116:            }
117:
118:            /**
119:             * Set the logging level. Level should be one of
120:             * <ul>
121:             *  <li>error</li>
122:             *  <li>warning</li>
123:             *  <li>info</li>
124:             *  <li>verbose</li>
125:             *  <li>debug</li>
126:             * </ul>
127:             * <p>The default is &quot;warning&quot; to ensure that messages are
128:             * displayed by default when using the -quiet command line option.</p>
129:             * @param echoLevel the logging level
130:             */
131:            public void setLevel(EchoLevel echoLevel) {
132:                logLevel = echoLevel.getLevel();
133:            }
134:
135:            /**
136:             * Declare the encoding to use when outputting to a file;
137:             * Use "" for the platform's default encoding.
138:             * @param encoding the character encoding to use.
139:             * @since 1.7
140:             */
141:            public void setEncoding(String encoding) {
142:                this .encoding = encoding;
143:            }
144:
145:            /**
146:             * The enumerated values for the level attribute.
147:             */
148:            public static class EchoLevel extends LogLevel {
149:            }
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.