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

public Class Basename

extends Task
Class Inheritance
Imports
java.io.File, org.apache.tools.ant.BuildException, .Task

Sets a property to the base name of a specified file, optionally minus a suffix. This task can accept the following attributes: The file and property attributes are required. The suffix attribute can be specified either with or without the ".", and the result will be the same (ie., the returned file name will be minus the .suffix).

When this task executes, it will set the specified property to the value of the last element in the specified file. If file is a directory, the basename will be the last directory element. If file is a full-path filename, the basename will be the simple file name. If a suffix is specified, and the specified file ends in that suffix, the basename will be the simple file name without the suffix.

Since
Ant 1.5

Field Summary

Modifier and TypeField and Description
private File
private String
private String
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
private String
public void
setFile(File
file or directory to get base name from
file
)

file or directory to get base name from

public void
setProperty(String
name of property
property
)

Property to set base name to.

public void
setSuffix(String
suffix to remove from base name
suffix
)

Optional suffix to remove from base name.

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

Field Detail

fileback to summary
private File file
propertyback to summary
private String property
suffixback to summary
private String suffix

Constructor Detail

Basenameback to summary
public Basename()

Method Detail

executeback to summary
public void execute() throws BuildException

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

do the work

Annotations
@Override
Exceptions
BuildException:
if required attributes are not supplied property and attribute are required attributes
removeExtensionback to summary
private String removeExtension(String s, String ext)
setFileback to summary
public void setFile(File file)

file or directory to get base name from

Parameters
file:File

file or directory to get base name from

setPropertyback to summary
public void setProperty(String property)

Property to set base name to.

Parameters
property:String

name of property

setSuffixback to summary
public void setSuffix(String suffix)

Optional suffix to remove from base name.

Parameters
suffix:String

suffix to remove from base name