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

public Class MakeUrl

extends Task
Class Inheritance
Imports
java.io.File, java.util.LinkedList, .List, org.apache.tools.ant.BuildException, .DirectoryScanner, .Project, .Task, org.apache.tools.ant.types.FileSet, .Path, org.apache.tools.ant.util.FileUtils

This task takes file and turns them into a URL, which it then assigns to a property. Use when for setting up RMI codebases.

nested filesets are supported; if present, these are turned into the url with the given separator between them (default = " ").

Field Summary

Modifier and TypeField and Description
public static final String
ERROR_MISSING_FILE

Missing file

public static final String
ERROR_NO_FILES

No files defined

public static final String
ERROR_NO_PROPERTY

No property defined

private File
file

name of a file to turn into a URL

private List<FileSet>
filesets

filesets of nested files to add to this url

private List<Path>
paths

paths to add

private String
property

name of the property to set

private String
separator

separator char

private boolean
validate

validation flag

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addFileSet(FileSet
the fileset to be added.
fileset
)

a fileset of jar files to include in the URL, each separated by the separator

public void
addPath(Path
a path value.
path
)

add a path to the URL.

public void
execute()

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

Create the url
private String

Returns:

null for no files
filesetsToURL
()

convert the filesets to urls.

private String

Returns:

the paths as a separated list of URLs
pathsToURL
()

convert all paths to URLs

public void
setFile(File
the file to be converted.
file
)

the name of a file to be converted into a URL

public void
setProperty(String
the name of the property.
property
)

set the name of a property to fill with the URL

public void
setSeparator(String
the separator to use.
separator
)

set the separator for the multi-url option.

public void
setValidate(boolean
a boolean value.
validate
)

set this flag to trigger validation that every named file exists.

private String

Returns:

trimmed string, or empty string
stripTrailingSeparator
(StringBuilder
URL buffer
urls
,
int
number of URL entries
count
)

convert the string buffer to a string, potentially stripping out any trailing separator

private String

Returns:

the file converted to a URL
toURL
(File
File
fileToConvert
)

convert a file to a URL;

private void
validate()

check for errors

private void
validateFile(File
file that may need to exist
fileToCheck
)

verify that the file exists, if validate is set

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

Field Detail

ERROR_MISSING_FILEback to summary
public static final String ERROR_MISSING_FILE

Missing file

ERROR_NO_FILESback to summary
public static final String ERROR_NO_FILES

No files defined

ERROR_NO_PROPERTYback to summary
public static final String ERROR_NO_PROPERTY

No property defined

fileback to summary
private File file

name of a file to turn into a URL

filesetsback to summary
private List<FileSet> filesets

filesets of nested files to add to this url

pathsback to summary
private List<Path> paths

paths to add

propertyback to summary
private String property

name of the property to set

separatorback to summary
private String separator

separator char

validateback to summary
private boolean validate

validation flag

Constructor Detail

MakeUrlback to summary
public MakeUrl()

Method Detail

addFileSetback to summary
public void addFileSet(FileSet fileset)

a fileset of jar files to include in the URL, each separated by the separator

Parameters
fileset:FileSet

the fileset to be added.

addPathback to summary
public void addPath(Path path)

add a path to the URL. All elements in the path will be converted to individual URL entries

Parameters
path:Path

a path value.

executeback to summary
public void execute() throws BuildException

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

Create the url

Annotations
@Override
Exceptions
BuildException:
if something goes wrong with the build
filesetsToURLback to summary
private String filesetsToURL()

convert the filesets to urls.

Returns:String

null for no files

pathsToURLback to summary
private String pathsToURL()

convert all paths to URLs

Returns:String

the paths as a separated list of URLs

setFileback to summary
public void setFile(File file)

the name of a file to be converted into a URL

Parameters
file:File

the file to be converted.

setPropertyback to summary
public void setProperty(String property)

set the name of a property to fill with the URL

Parameters
property:String

the name of the property.

setSeparatorback to summary
public void setSeparator(String separator)

set the separator for the multi-url option.

Parameters
separator:String

the separator to use.

setValidateback to summary
public void setValidate(boolean validate)

set this flag to trigger validation that every named file exists. Optional: default=true

Parameters
validate:boolean

a boolean value.

stripTrailingSeparatorback to summary
private String stripTrailingSeparator(StringBuilder urls, int count)

convert the string buffer to a string, potentially stripping out any trailing separator

Parameters
urls:StringBuilder

URL buffer

count:int

number of URL entries

Returns:String

trimmed string, or empty string

toURLback to summary
private String toURL(File fileToConvert)

convert a file to a URL;

Parameters
fileToConvert:File

File

Returns:String

the file converted to a URL

validateback to summary
private void validate()

check for errors

Exceptions
BuildException:
if we are not configured right
validateFileback to summary
private void validateFile(File fileToCheck)

verify that the file exists, if validate is set

Parameters
fileToCheck:File

file that may need to exist

Exceptions
BuildException:
with text beginning ERROR_MISSING_FILE