Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class Touch

extends Task
Class Inheritance
Imports
java.io.File, .IOException, java.text.DateFormat, .ParseException, .SimpleDateFormat, java.util.List, .Vector, org.apache.tools.ant.BuildException, .DirectoryScanner, .Project, .Task, org.apache.tools.ant.types.FileList, .FileSet, .Mapper, .Resource, .ResourceCollection, org.apache.tools.ant.types.resources.FileProvider, .FileResource, .Touchable, .Union, org.apache.tools.ant.util.DateUtils, .FileNameMapper, .FileUtils

Touch a file and/or fileset(s) and/or filelist(s); corresponds to the Unix touch command.

If the file to touch doesn't exist, an empty one is created.

Since
Ant 1.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private String
private boolean
public static final Touch.DateFormatFactory
DEFAULT_DF_FACTORY

Provides access to DateUtils.EN_US_DATE_FORMAT_MIN (primary) and DateUtils.EN_US_DATE_FORMAT_SEC (fallback).

private Touch.DateFormatFactory
private File
private static final FileUtils
private FileNameMapper
private List<FileSet>
private long
private boolean
private Union
private boolean
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(FileNameMapper
the FileNameMapper to add.
fileNameMapper
)

Add a FileNameMapper.

public synchronized void
add(ResourceCollection
the collection to add.
rc
)

Add a collection of resources to touch.

public void
addConfiguredMapper(Mapper
the Mapper to add.
mapper
)

Add a Mapper.

public void
addFilelist(FileList
the Filelist to add.
list
)

Add a filelist to touch.

public void
addFileset(FileSet
the Fileset to add.
set
)

Add a set of files to touch.

protected synchronized void
checkConfiguration()

Check that this task has been configured properly.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Execute the touch operation.
private long
public void
setDatetime(String
the String date in the specified format.
dateTime
)

Set the new modification time of file(s) touched in the format "MM/DD/YYYY HH:MM AM or PM" or "MM/DD/YYYY HH:MM:SS AM or PM".

public void
setFile(File
the File to touch.
file
)

Sets a single source file to touch.

public void
setMillis(long
the long timestamp to use.
millis
)

Set the new modification time of file(s) touched in milliseconds since midnight Jan 1 1970.

public void
setMkdirs(boolean
boolean whether to create parent directories.
mkdirs
)

Set whether nonexistent parent directories should be created when touching new files.

public void
setPattern(final String
the SimpleDateFormat-compatible format pattern.
pattern
)

Set the format of the datetime attribute.

public void
setVerbose(boolean
boolean flag.
verbose
)

Set whether the touch task will report every file it creates; defaults to true.

protected void
touch()

Does the actual work; assumes everything has been checked by now.

protected void
touch(File
file to touch
file
)

Deprecated since 1.6.x.
Touch a single file with the current timestamp (this.millis).
private void
touch(Resource r, long defaultTimestamp)

private void
touch(File file, long modTime)

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

dateTimeback to summary
private String dateTime
dateTimeConfiguredback to summary
private boolean dateTimeConfigured
DEFAULT_DF_FACTORYback to summary
public static final Touch.DateFormatFactory DEFAULT_DF_FACTORY

Provides access to DateUtils.EN_US_DATE_FORMAT_MIN (primary) and DateUtils.EN_US_DATE_FORMAT_SEC (fallback).

dfFactoryback to summary
private Touch.DateFormatFactory dfFactory
fileback to summary
private File file
FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
fileNameMapperback to summary
private FileNameMapper fileNameMapper
filesetsback to summary
private List<FileSet> filesets
millisback to summary
private long millis
mkdirsback to summary
private boolean mkdirs
resourcesback to summary
private Union resources
verboseback to summary
private boolean verbose

Constructor Detail

Touchback to summary
public Touch()

Method Detail

addback to summary
public void add(FileNameMapper fileNameMapper) throws BuildException

Add a FileNameMapper.

Parameters
fileNameMapper:FileNameMapper

the FileNameMapper to add.

Exceptions
BuildException:
if multiple mappers are added.
Since
Ant 1.6.3
addback to summary
public synchronized void add(ResourceCollection rc)

Add a collection of resources to touch.

Parameters
rc:ResourceCollection

the collection to add.

Since
Ant 1.7
addConfiguredMapperback to summary
public void addConfiguredMapper(Mapper mapper)

Add a Mapper.

Parameters
mapper:Mapper

the Mapper to add.

Since
Ant 1.6.3
addFilelistback to summary
public void addFilelist(FileList list)

Add a filelist to touch.

Parameters
list:FileList

the Filelist to add.

addFilesetback to summary
public void addFileset(FileSet set)

Add a set of files to touch.

Parameters
set:FileSet

the Fileset to add.

checkConfigurationback to summary
protected synchronized void checkConfiguration() throws BuildException

Check that this task has been configured properly.

Exceptions
BuildException:
if configuration errors are detected.
Since
Ant 1.6.3
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Execute the touch operation.

Annotations
@Override
Exceptions
BuildException:
if an error occurs.
getTimestampback to summary
private long getTimestamp()
setDatetimeback to summary
public void setDatetime(String dateTime)

Set the new modification time of file(s) touched in the format "MM/DD/YYYY HH:MM AM or PM" or "MM/DD/YYYY HH:MM:SS AM or PM". Optional, default=now.

Parameters
dateTime:String

the String date in the specified format.

setFileback to summary
public void setFile(File file)

Sets a single source file to touch. If the file does not exist an empty file will be created.

Parameters
file:File

the File to touch.

setMillisback to summary
public void setMillis(long millis)

Set the new modification time of file(s) touched in milliseconds since midnight Jan 1 1970. Optional, default=now.

Parameters
millis:long

the long timestamp to use.

setMkdirsback to summary
public void setMkdirs(boolean mkdirs)

Set whether nonexistent parent directories should be created when touching new files.

Parameters
mkdirs:boolean

boolean whether to create parent directories.

Since
Ant 1.6.3
setPatternback to summary
public void setPattern(final String pattern)

Set the format of the datetime attribute.

Parameters
pattern:String

the SimpleDateFormat-compatible format pattern.

Since
Ant 1.6.3
setVerboseback to summary
public void setVerbose(boolean verbose)

Set whether the touch task will report every file it creates; defaults to true.

Parameters
verbose:boolean

boolean flag.

Since
Ant 1.6.3
touchback to summary
protected void touch() throws BuildException

Does the actual work; assumes everything has been checked by now.

Exceptions
BuildException:
if an error occurs.
touchback to summary
protected void touch(File file)

Deprecated

since 1.6.x.

Touch a single file with the current timestamp (this.millis). This method does not interact with any nested mappers and remains for reasons of backwards-compatibility only.

Parameters
file:File

file to touch

Annotations
@Deprecated
Exceptions
BuildException:
on error
touchback to summary
private void touch(Resource r, long defaultTimestamp)
touchback to summary
private void touch(File file, long modTime)
org.apache.tools.ant.taskdefs back to summary

public Interface Touch.DateFormatFactory


Method Summary

Modifier and TypeMethod and Description
public DateFormat
public DateFormat

Method Detail

getFallbackFormatback to summary
public DateFormat getFallbackFormat()
getPrimaryFormatback to summary
public DateFormat getPrimaryFormat()