Java Doc for Copy.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 Reference  Class Diagram Java Document (Java Doc) 


org.apache.tools.ant.Task
   org.apache.tools.ant.taskdefs.Copy

All known Subclasses:   org.apache.tools.ant.taskdefs.Move,
Copy
public class Copy extends Task (Code)
Copies a file or directory to a new file or directory. Files are only copied if the source file is newer than the destination file, or when the destination file does not exist. It is possible to explicitly overwrite existing files.

This implementation is based on Arnout Kuiper's initial design document, the following mailing list discussions, and the copyfile/copydir tasks.


since:
   Ant 1.2


Field Summary
final static  StringLINE_SEPARATOR
    
final static  FileNULL_FILE_PLACEHOLDER
    
protected  HashtablecompleteDirMap
    
protected  FiledestDir
    
protected  FiledestFile
    
protected  HashtabledirCopyMap
    
protected  booleanfailonerror
    
protected  Filefile
    
protected  HashtablefileCopyMap
    
protected  FileUtilsfileUtils
    
protected  booleanfiltering
    
protected  booleanflatten
    
protected  booleanforceOverwrite
    
protected  booleanincludeEmpty
    
protected  MappermapperElement
    
protected  booleanpreserveLastModified
    
protected  Vectorrcs
    
protected  intverbosity
    

Constructor Summary
public  Copy()
     Copy task constructor.

Method Summary
public  voidadd(ResourceCollection res)
     Add a collection of files to copy.
public  voidadd(FileNameMapper fileNameMapper)
     Add a nested filenamemapper.
public  voidaddFileset(FileSet set)
     Add a set of files to copy.
protected  voidbuildMap(File fromDir, File toDir, String[] names, FileNameMapper mapper, Hashtable map)
     Add to a map of files/directories to copy.
protected  MapbuildMap(Resource[] fromResources, File toDir, FileNameMapper mapper)
     Create a map of resources to copy.
Parameters:
  fromResources - The source resources.
Parameters:
  toDir - the destination directory.
Parameters:
  mapper - a FileNameMapper value.
public  FilterChaincreateFilterChain()
     Add a FilterChain.
public  FilterSetcreateFilterSet()
     Add a filterset.
public  MappercreateMapper()
     Define the mapper to map source to destination files.
protected  voiddoFileOperations()
     Actually does the file (and possibly empty directory) copies.
protected  voiddoResourceOperations(Map map)
     Actually does the resource copies.
public  voidexecute()
     Perform the copy operation.
public  StringgetEncoding()
     Get the character encoding to be used.
protected  FileUtilsgetFileUtils()
     Get the FileUtils for this task.
protected  VectorgetFilterChains()
     Get the filterchains being applied to this operation.
protected  VectorgetFilterSets()
     Get the filtersets being applied to this operation.
public  StringgetOutputEncoding()
     Get the character encoding for output files.
public  booleangetPreserveLastModified()
     Get whether to give the copied files the same last modified time as the original files.
public  booleanisEnableMultipleMapping()
     Get whether multiple mapping is enabled.
protected  voidscan(File fromDir, File toDir, String[] files, String[] dirs)
     Compares source files to destination files to see if they should be copied.
protected  Mapscan(Resource[] fromResources, File toDir)
     Compares source resources to destination files to see if they should be copied.
Parameters:
  fromResources - The source resources.
Parameters:
  toDir - The destination directory.
public  voidsetEnableMultipleMappings(boolean enableMultipleMappings)
     Set method of handling mappers that return multiple mappings for a given source path.
public  voidsetEncoding(String encoding)
     Set the character encoding.
public  voidsetFailOnError(boolean failonerror)
     Set whether to fail when errors are encountered.
public  voidsetFile(File file)
     Set a single source file to copy.
public  voidsetFiltering(boolean filtering)
     Set filtering mode.
public  voidsetFlatten(boolean flatten)
     Set whether files copied from directory trees will be "flattened" into a single directory.
public  voidsetGranularity(long granularity)
     Set the number of milliseconds leeway to give before deciding a target is out of date.
public  voidsetIncludeEmptyDirs(boolean includeEmpty)
     Set whether to copy empty directories.
Parameters:
  includeEmpty - if true copy empty directories.
public  voidsetOutputEncoding(String encoding)
     Set the character encoding for output files.
public  voidsetOverwrite(boolean overwrite)
     Set overwrite mode regarding existing destination file(s).
Parameters:
  overwrite - if true force overwriting of destination file(s)even if the destination file(s) are younger thanthe corresponding source file.
public  voidsetPreserveLastModified(String preserve)
     Give the copied files the same last modified time as the original files.
public  voidsetPreserveLastModified(boolean preserve)
     Give the copied files the same last modified time as the original files.
public  voidsetTodir(File destDir)
     Set the destination directory.
public  voidsetTofile(File destFile)
     Set the destination file.
public  voidsetVerbose(boolean verbose)
     Set verbose mode.
protected  booleansupportsNonFileResources()
     Whether this task can deal with non-file resources.

<copy> can while <move> can't since we don't know how to remove non-file resources.

This implementation returns true only if this task is <copy>.

protected  voidvalidateAttributes()
     Ensure we have a consistent and legal set of attributes, and set any internal flags necessary based on different combinations of attributes.

Field Detail
LINE_SEPARATOR
final static String LINE_SEPARATOR(Code)



NULL_FILE_PLACEHOLDER
final static File NULL_FILE_PLACEHOLDER(Code)



completeDirMap
protected Hashtable completeDirMap(Code)



destDir
protected File destDir(Code)



destFile
protected File destFile(Code)



dirCopyMap
protected Hashtable dirCopyMap(Code)



failonerror
protected boolean failonerror(Code)



file
protected File file(Code)



fileCopyMap
protected Hashtable fileCopyMap(Code)



fileUtils
protected FileUtils fileUtils(Code)



filtering
protected boolean filtering(Code)



flatten
protected boolean flatten(Code)



forceOverwrite
protected boolean forceOverwrite(Code)



includeEmpty
protected boolean includeEmpty(Code)



mapperElement
protected Mapper mapperElement(Code)



preserveLastModified
protected boolean preserveLastModified(Code)



rcs
protected Vector rcs(Code)



verbosity
protected int verbosity(Code)




Constructor Detail
Copy
public Copy()(Code)
Copy task constructor.




Method Detail
add
public void add(ResourceCollection res)(Code)
Add a collection of files to copy.
Parameters:
  res - a resource collection to copy.
since:
   Ant 1.7



add
public void add(FileNameMapper fileNameMapper)(Code)
Add a nested filenamemapper.
Parameters:
  fileNameMapper - the mapper to add.
since:
   Ant 1.6.3



addFileset
public void addFileset(FileSet set)(Code)
Add a set of files to copy.
Parameters:
  set - a set of files to copy.



buildMap
protected void buildMap(File fromDir, File toDir, String[] names, FileNameMapper mapper, Hashtable map)(Code)
Add to a map of files/directories to copy.
Parameters:
  fromDir - the source directory.
Parameters:
  toDir - the destination directory.
Parameters:
  names - a list of filenames.
Parameters:
  mapper - a FileNameMapper value.
Parameters:
  map - a map of source file to array of destination files.



buildMap
protected Map buildMap(Resource[] fromResources, File toDir, FileNameMapper mapper)(Code)
Create a map of resources to copy.
Parameters:
  fromResources - The source resources.
Parameters:
  toDir - the destination directory.
Parameters:
  mapper - a FileNameMapper value. a map of source resource to array of destination files.
since:
   Ant 1.7



createFilterChain
public FilterChain createFilterChain()(Code)
Add a FilterChain. a filter chain object.



createFilterSet
public FilterSet createFilterSet()(Code)
Add a filterset. a filter set object.



createMapper
public Mapper createMapper() throws BuildException(Code)
Define the mapper to map source to destination files. a mapper to be configured.
exception:
  BuildException - if more than one mapper is defined.



doFileOperations
protected void doFileOperations()(Code)
Actually does the file (and possibly empty directory) copies. This is a good method for subclasses to override.



doResourceOperations
protected void doResourceOperations(Map map)(Code)
Actually does the resource copies. This is a good method for subclasses to override.
Parameters:
  map - a map of source resource to array of destination files.
since:
   Ant 1.7



execute
public void execute() throws BuildException(Code)
Perform the copy operation.
exception:
  BuildException - if an error occurs.



getEncoding
public String getEncoding()(Code)
Get the character encoding to be used. the character encoding, null if not set.
since:
   1.32, Ant 1.5



getFileUtils
protected FileUtils getFileUtils()(Code)
Get the FileUtils for this task. the fileutils object.



getFilterChains
protected Vector getFilterChains()(Code)
Get the filterchains being applied to this operation. a vector of FilterChain objects.



getFilterSets
protected Vector getFilterSets()(Code)
Get the filtersets being applied to this operation. a vector of FilterSet objects.



getOutputEncoding
public String getOutputEncoding()(Code)
Get the character encoding for output files. the character encoding for output files,null if not set.
since:
   Ant 1.6



getPreserveLastModified
public boolean getPreserveLastModified()(Code)
Get whether to give the copied files the same last modified time as the original files. the whether destination files will inherit the modificationtimes of the corresponding source files.
since:
   1.32, Ant 1.5



isEnableMultipleMapping
public boolean isEnableMultipleMapping()(Code)
Get whether multiple mapping is enabled. true if multiple mapping is enabled; false otherwise.



scan
protected void scan(File fromDir, File toDir, String[] files, String[] dirs)(Code)
Compares source files to destination files to see if they should be copied.
Parameters:
  fromDir - The source directory.
Parameters:
  toDir - The destination directory.
Parameters:
  files - A list of files to copy.
Parameters:
  dirs - A list of directories to copy.



scan
protected Map scan(Resource[] fromResources, File toDir)(Code)
Compares source resources to destination files to see if they should be copied.
Parameters:
  fromResources - The source resources.
Parameters:
  toDir - The destination directory. a Map with the out-of-date resources as keys and anarray of target file names as values.
since:
   Ant 1.7



setEnableMultipleMappings
public void setEnableMultipleMappings(boolean enableMultipleMappings)(Code)
Set method of handling mappers that return multiple mappings for a given source path.
Parameters:
  enableMultipleMappings - If true the task willcopy to all the mappings for a given source path, iffalse, only the first file or directory isprocessed.By default, this setting is false to provide backwardcompatibility with earlier releases.
since:
   Ant 1.6



setEncoding
public void setEncoding(String encoding)(Code)
Set the character encoding.
Parameters:
  encoding - the character encoding.
since:
   1.32, Ant 1.5



setFailOnError
public void setFailOnError(boolean failonerror)(Code)
Set whether to fail when errors are encountered. If false, note errors to the output but keep going. Default is true.
Parameters:
  failonerror - true or false.



setFile
public void setFile(File file)(Code)
Set a single source file to copy.
Parameters:
  file - the file to copy.



setFiltering
public void setFiltering(boolean filtering)(Code)
Set filtering mode.
Parameters:
  filtering - if true enable filtering; default is false.



setFlatten
public void setFlatten(boolean flatten)(Code)
Set whether files copied from directory trees will be "flattened" into a single directory. If there are multiple files with the same name in the source directory tree, only the first file will be copied into the "flattened" directory, unless the forceoverwrite attribute is true.
Parameters:
  flatten - if true flatten the destination directory. Defaultis false.



setGranularity
public void setGranularity(long granularity)(Code)
Set the number of milliseconds leeway to give before deciding a target is out of date.

Default is 1 second, or 2 seconds on DOS systems.


Parameters:
  granularity - the granularity used to decide if a target is out ofdate.
since:
   Ant 1.6.2



setIncludeEmptyDirs
public void setIncludeEmptyDirs(boolean includeEmpty)(Code)
Set whether to copy empty directories.
Parameters:
  includeEmpty - if true copy empty directories. Default is true.



setOutputEncoding
public void setOutputEncoding(String encoding)(Code)
Set the character encoding for output files.
Parameters:
  encoding - the output character encoding.
since:
   Ant 1.6



setOverwrite
public void setOverwrite(boolean overwrite)(Code)
Set overwrite mode regarding existing destination file(s).
Parameters:
  overwrite - if true force overwriting of destination file(s)even if the destination file(s) are younger thanthe corresponding source file. Default is false.



setPreserveLastModified
public void setPreserveLastModified(String preserve)(Code)
Give the copied files the same last modified time as the original files.
Parameters:
  preserve - a boolean string.



setPreserveLastModified
public void setPreserveLastModified(boolean preserve)(Code)
Give the copied files the same last modified time as the original files.
Parameters:
  preserve - if true preserve the modified time; default is false.



setTodir
public void setTodir(File destDir)(Code)
Set the destination directory.
Parameters:
  destDir - the destination directory.



setTofile
public void setTofile(File destFile)(Code)
Set the destination file.
Parameters:
  destFile - the file to copy to.



setVerbose
public void setVerbose(boolean verbose)(Code)
Set verbose mode. Used to force listing of all names of copied files.
Parameters:
  verbose - whether to output the names of copied files.Default is false.



supportsNonFileResources
protected boolean supportsNonFileResources()(Code)
Whether this task can deal with non-file resources.

<copy> can while <move> can't since we don't know how to remove non-file resources.

This implementation returns true only if this task is <copy>. Any subclass of this class that also wants to support non-file resources needs to override this method. We need to do so for backwards compatibility reasons since we can't expect subclasses to support resources.

true if this task supports non file resources.
since:
   Ant 1.7



validateAttributes
protected void validateAttributes() throws BuildException(Code)
Ensure we have a consistent and legal set of attributes, and set any internal flags necessary based on different combinations of attributes.
exception:
  BuildException - if an error occurs.



Fields inherited from org.apache.tools.ant.Task
protected Target target(Code)(Java Doc)
protected String taskName(Code)(Java Doc)
protected String taskType(Code)(Java Doc)
protected RuntimeConfigurable wrapper(Code)(Java Doc)

Methods inherited from org.apache.tools.ant.Task
final public void bindToOwner(Task owner)(Code)(Java Doc)
public void execute() throws BuildException(Code)(Java Doc)
public Target getOwningTarget()(Code)(Java Doc)
public RuntimeConfigurable getRuntimeConfigurableWrapper()(Code)(Java Doc)
public String getTaskName()(Code)(Java Doc)
public String getTaskType()(Code)(Java Doc)
protected RuntimeConfigurable getWrapper()(Code)(Java Doc)
protected void handleErrorFlush(String output)(Code)(Java Doc)
protected void handleErrorOutput(String output)(Code)(Java Doc)
protected void handleFlush(String output)(Code)(Java Doc)
protected int handleInput(byte[] buffer, int offset, int length) throws IOException(Code)(Java Doc)
protected void handleOutput(String output)(Code)(Java Doc)
public void init() throws BuildException(Code)(Java Doc)
final protected boolean isInvalid()(Code)(Java Doc)
public void log(String msg)(Code)(Java Doc)
public void log(String msg, int msgLevel)(Code)(Java Doc)
public void log(Throwable t, int msgLevel)(Code)(Java Doc)
public void log(String msg, Throwable t, int msgLevel)(Code)(Java Doc)
public void maybeConfigure() throws BuildException(Code)(Java Doc)
final public void perform()(Code)(Java Doc)
public void reconfigure()(Code)(Java Doc)
public void setOwningTarget(Target target)(Code)(Java Doc)
public void setRuntimeConfigurableWrapper(RuntimeConfigurable wrapper)(Code)(Java Doc)
public void setTaskName(String name)(Code)(Java Doc)
public void setTaskType(String type)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.