Source Code Cross Referenced for Copydir.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.IOException;
023:        import java.util.Enumeration;
024:        import java.util.Hashtable;
025:        import org.apache.tools.ant.BuildException;
026:        import org.apache.tools.ant.DirectoryScanner;
027:        import org.apache.tools.ant.Project;
028:
029:        /**
030:         * Copies a directory.
031:         *
032:         * @since Ant 1.1
033:         *
034:         * @deprecated The copydir task is deprecated since Ant 1.2.  Use copy instead.
035:         */
036:
037:        public class Copydir extends MatchingTask {
038:
039:            private File srcDir;
040:            private File destDir;
041:            private boolean filtering = false;
042:            private boolean flatten = false;
043:            private boolean forceOverwrite = false;
044:            private Hashtable filecopyList = new Hashtable();
045:
046:            /**
047:             * The src attribute
048:             *
049:             * @param src the source file
050:             */
051:            public void setSrc(File src) {
052:                srcDir = src;
053:            }
054:
055:            /**
056:             * The dest attribute
057:             *
058:             * @param dest the destination file
059:             */
060:            public void setDest(File dest) {
061:                destDir = dest;
062:            }
063:
064:            /**
065:             * The filtering attribute.
066:             * Default  is false.
067:             * @param filter if true use filtering
068:             */
069:            public void setFiltering(boolean filter) {
070:                filtering = filter;
071:            }
072:
073:            /**
074:             * The flattening attribute.
075:             * Default  is false.
076:             * @param flatten if true use flattening
077:             */
078:            public void setFlatten(boolean flatten) {
079:                this .flatten = flatten;
080:            }
081:
082:            /**
083:             * The forceoverwrite attribute.
084:             * Default  is false.
085:             * @param force if true overwrite even if the destination file
086:             *              is newer that the source file
087:             */
088:            public void setForceoverwrite(boolean force) {
089:                forceOverwrite = force;
090:            }
091:
092:            /**
093:             * Execute the task.
094:             * @throws BuildException on error
095:             */
096:            public void execute() throws BuildException {
097:                log("DEPRECATED - The copydir task is deprecated.  Use copy instead.");
098:
099:                if (srcDir == null) {
100:                    throw new BuildException("src attribute must be set!",
101:                            getLocation());
102:                }
103:
104:                if (!srcDir.exists()) {
105:                    throw new BuildException("srcdir " + srcDir.toString()
106:                            + " does not exist!", getLocation());
107:                }
108:
109:                if (destDir == null) {
110:                    throw new BuildException("The dest attribute must be set.",
111:                            getLocation());
112:                }
113:
114:                if (srcDir.equals(destDir)) {
115:                    log("Warning: src == dest", Project.MSG_WARN);
116:                }
117:
118:                DirectoryScanner ds = super .getDirectoryScanner(srcDir);
119:
120:                try {
121:                    String[] files = ds.getIncludedFiles();
122:                    scanDir(srcDir, destDir, files);
123:                    if (filecopyList.size() > 0) {
124:                        log("Copying " + filecopyList.size() + " file"
125:                                + (filecopyList.size() == 1 ? "" : "s")
126:                                + " to " + destDir.getAbsolutePath());
127:                        Enumeration e = filecopyList.keys();
128:                        while (e.hasMoreElements()) {
129:                            String fromFile = (String) e.nextElement();
130:                            String toFile = (String) filecopyList.get(fromFile);
131:                            try {
132:                                getProject().copyFile(fromFile, toFile,
133:                                        filtering, forceOverwrite);
134:                            } catch (IOException ioe) {
135:                                String msg = "Failed to copy " + fromFile
136:                                        + " to " + toFile + " due to "
137:                                        + ioe.getMessage();
138:                                throw new BuildException(msg, ioe,
139:                                        getLocation());
140:                            }
141:                        }
142:                    }
143:                } finally {
144:                    filecopyList.clear();
145:                }
146:            }
147:
148:            private void scanDir(File from, File to, String[] files) {
149:                for (int i = 0; i < files.length; i++) {
150:                    String filename = files[i];
151:                    File srcFile = new File(from, filename);
152:                    File destFile;
153:                    if (flatten) {
154:                        destFile = new File(to, new File(filename).getName());
155:                    } else {
156:                        destFile = new File(to, filename);
157:                    }
158:                    if (forceOverwrite
159:                            || (srcFile.lastModified() > destFile
160:                                    .lastModified())) {
161:                        filecopyList.put(srcFile.getAbsolutePath(), destFile
162:                                .getAbsolutePath());
163:                    }
164:                }
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.