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

public abstract Class Definer

extends DefBase
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.Typedef, org.apache.tools.ant.taskdefs.Componentdef
Imports
java.io.File, .IOException, .InputStream, java.net.URL, java.util.Collections, .Enumeration, .HashMap, .Locale, .Map, .Properties, org.apache.tools.ant.AntTypeDefinition, .BuildException, .ComponentHelper, .Location, .MagicNames, .Project, .ProjectHelper, org.apache.tools.ant.types.EnumeratedAttribute, org.apache.tools.ant.util.FileUtils

Base class for Taskdef and Typedef - handles all the attributes for Typedef. The uri and class handling is handled by DefBase
Since
Ant 1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Definer.Format

Enumerated type for format attribute

public static class
Definer.OnError

Enumerated type for onError attribute

Field Summary

Modifier and TypeField and Description
private String
private Class<?>
private String
private Class<?>
private static final String
ANTLIB_XML

the extension of an antlib file for autoloading.

private String
private boolean
private File
private int
private String
private int
private String
private static final ThreadLocal<Map<URL, Location>>
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
addDefinition(ClassLoader
the ClassLoader to use
al
,
String
the name of the definition
name
,
String
the classname of the definition
classname
)

Add a definition using the attributes of Definer

public void
execute()

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

Run the definition.
private URL

Returns:

the URL, or null if it isn't valid and the active error policy is not to raise a fault
fileToURL
()

Convert a file to a file: URL.

public String

Returns:

the class name
getClassname
()

Returns the classname of the object we are defining.

public File

Returns:

the file containing definitions
getFile
()

public String

Returns:

the name for this definition
getName
()

public String

Returns:

the resource containing definitions
getResource
()

private void
loadAntlib(ClassLoader
the classloader to use.
classLoader
,
URL
the url to load the definitions from.
url
)

Load an antlib from a URL.

protected void
loadProperties(ClassLoader
the classloader to use
al
,
URL
the url to get the definitions from
url
)

Load type definitions as properties from a URL.

public static String

Returns:

the name of a resource. It may not exist
makeResourceFromURI
(String
the xml namespace uri that to convert.
uri
)

This is where the logic to map from a URI to an antlib resource is kept.

private Enumeration<URL>
public void
setAdapter(String
the name of the adapter class
adapter
)

Set the class name of the adapter class.

protected void
setAdapterClass(Class<?>
the class to use to adapt the definition class
adapterClass
)

Set the adapter class.

public void
setAdaptTo(String
the name of the adaptto class
adaptTo
)

Set the classname of the class that the definition must be compatible with, either directly or by use of the adapter class.

protected void
setAdaptToClass(Class<?>
the class for adaptor.
adaptToClass
)

Set the class for adaptToClass, to be used by derived classes, used instead of the adaptTo attribute.

public void
setAntlib(String
the value to set.
antlib
)

Antlib attribute, sets resource and uri.

public void
setClassname(String
the name of the class
classname
)

The full class name of the object being defined.

public void
setFile(File
the file
file
)

Name of the property file to load ant name/classname pairs from.

public void
setFormat(Definer.Format
the enumerated value - xml or properties
format
)

Sets the format of the file or resource

public void
setName(String
the name of the definition
name
)

Name of the definition

public void
setOnError(Definer.OnError
an OnError value
onError
)

What to do if there is an error in loading the class.

public void
setResource(String
the resource to use
res
)

Name of the property resource to load ant name/classname pairs from.

protected void
setRestrict(boolean
the value to set.
restrict
)

The restrict attribute.

private void
tooManyDefinitions()

handle too many definitions by raising an exception.

Inherited from org.apache.tools.ant.taskdefs.DefBase:
createClasspathcreateLoadergetClasspathgetClasspathIdgetLoaderIdhasCpDelegateinitisReverseLoadersetClasspathsetClasspathRefsetLoaderRefsetReverseLoader

Field Detail

adapterback to summary
private String adapter
adapterClassback to summary
private Class<?> adapterClass
adaptToback to summary
private String adaptTo
adaptToClassback to summary
private Class<?> adaptToClass
ANTLIB_XMLback to summary
private static final String ANTLIB_XML

the extension of an antlib file for autoloading. /antlib.xml

classnameback to summary
private String classname
definerSetback to summary
private boolean definerSet
fileback to summary
private File file
formatback to summary
private int format
nameback to summary
private String name
onErrorback to summary
private int onError
resourceback to summary
private String resource
RESOURCE_STACKback to summary
private static final ThreadLocal<Map<URL, Location>> RESOURCE_STACK
restrictback to summary
private boolean restrict

Constructor Detail

Definerback to summary
public Definer()

Method Detail

addDefinitionback to summary
protected void addDefinition(ClassLoader al, String name, String classname) throws BuildException

Add a definition using the attributes of Definer

Parameters
al:ClassLoader

the ClassLoader to use

name:String

the name of the definition

classname:String

the classname of the definition

Exceptions
BuildException:
if an error occurs
executeback to summary
public void execute() throws BuildException

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

Run the definition.

Annotations
@Override
Exceptions
BuildException:
if an error occurs
fileToURLback to summary
private URL fileToURL()

Convert a file to a file: URL.

Returns:URL

the URL, or null if it isn't valid and the active error policy is not to raise a fault

Exceptions
BuildException:
if the file is missing/not a file and the policy requires failure at this point.
getClassnameback to summary
public String getClassname()

Returns the classname of the object we are defining. May be null.

Returns:String

the class name

getFileback to summary
public File getFile()
Returns:File

the file containing definitions

getNameback to summary
public String getName()
Returns:String

the name for this definition

getResourceback to summary
public String getResource()
Returns:String

the resource containing definitions

loadAntlibback to summary
private void loadAntlib(ClassLoader classLoader, URL url)

Load an antlib from a URL.

Parameters
classLoader:ClassLoader

the classloader to use.

url:URL

the url to load the definitions from.

loadPropertiesback to summary
protected void loadProperties(ClassLoader al, URL url)

Load type definitions as properties from a URL.

Parameters
al:ClassLoader

the classloader to use

url:URL

the url to get the definitions from

makeResourceFromURIback to summary
public static String makeResourceFromURI(String uri)

This is where the logic to map from a URI to an antlib resource is kept.

Parameters
uri:String

the xml namespace uri that to convert.

Returns:String

the name of a resource. It may not exist

resourceToURLsback to summary
private Enumeration<URL> resourceToURLs(ClassLoader classLoader)
setAdapterback to summary
public void setAdapter(String adapter)

Set the class name of the adapter class. An adapter class is used to proxy the definition class. It is used if the definition class is not assignable to the adaptto class, or if the adaptto class is not present.

Parameters
adapter:String

the name of the adapter class

setAdapterClassback to summary
protected void setAdapterClass(Class<?> adapterClass)

Set the adapter class.

Parameters
adapterClass:Class<?>

the class to use to adapt the definition class

setAdaptToback to summary
public void setAdaptTo(String adaptTo)

Set the classname of the class that the definition must be compatible with, either directly or by use of the adapter class.

Parameters
adaptTo:String

the name of the adaptto class

setAdaptToClassback to summary
protected void setAdaptToClass(Class<?> adaptToClass)

Set the class for adaptToClass, to be used by derived classes, used instead of the adaptTo attribute.

Parameters
adaptToClass:Class<?>

the class for adaptor.

setAntlibback to summary
public void setAntlib(String antlib)

Antlib attribute, sets resource and uri. uri is set the antlib value and, resource is set to the antlib.xml resource in the classpath. For example antlib="antlib:org.acme.bland.cola" corresponds to uri="antlib:org.acme.bland.cola" resource="org/acme/bland/cola/antlib.xml". ASF Bugzilla Bug 31999

Parameters
antlib:String

the value to set.

setClassnameback to summary
public void setClassname(String classname)

The full class name of the object being defined. Required, unless file or resource have been specified.

Parameters
classname:String

the name of the class

setFileback to summary
public void setFile(File file)

Name of the property file to load ant name/classname pairs from.

Parameters
file:File

the file

setFormatback to summary
public void setFormat(Definer.Format format)

Sets the format of the file or resource

Parameters
format:Definer.Format

the enumerated value - xml or properties

setNameback to summary
public void setName(String name)

Name of the definition

Parameters
name:String

the name of the definition

setOnErrorback to summary
public void setOnError(Definer.OnError onError)

What to do if there is an error in loading the class.

  • error - throw build exception
  • report - output at warning level
  • ignore - output at debug level
Parameters
onError:Definer.OnError

an OnError value

setResourceback to summary
public void setResource(String res)

Name of the property resource to load ant name/classname pairs from.

Parameters
res:String

the resource to use

setRestrictback to summary
protected void setRestrict(boolean restrict)

The restrict attribute. If this is true, only use this definition in add(X).

Parameters
restrict:boolean

the value to set.

tooManyDefinitionsback to summary
private void tooManyDefinitions()

handle too many definitions by raising an exception.

Exceptions
BuildException:
always.
org.apache.tools.ant.taskdefs back to summary

public Class Definer.Format

extends EnumeratedAttribute
Class Inheritance

Enumerated type for format attribute
See Also
EnumeratedAttribute

Field Summary

Modifier and TypeField and Description
public static final int
PROPERTIES

Enumerated values

public static final int
XML

Enumerated values

Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
value

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

an array of the allowed values for this attribute.
getValues
()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

get the values
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Field Detail

PROPERTIESback to summary
public static final int PROPERTIES

Enumerated values

XMLback to summary
public static final int XML

Enumerated values

Constructor Detail

Formatback to summary
public Format()

Method Detail

getValuesback to summary
public String[] getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

get the values

Returns:String[]

an array of the allowed values for this attribute.

Annotations
@Override
org.apache.tools.ant.taskdefs back to summary

public Class Definer.OnError

extends EnumeratedAttribute
Class Inheritance

Enumerated type for onError attribute
See Also
EnumeratedAttribute

Field Summary

Modifier and TypeField and Description
public static final int
FAIL

Enumerated values

public static final int
FAIL_ALL

Enumerated values

public static final int
IGNORE

Enumerated values

public static final String
POLICY_FAIL

text value of onerror option fail

public static final String
POLICY_FAILALL

text value of onerror option failall

public static final String
POLICY_IGNORE

text value of onerror option ignore

public static final String
POLICY_REPORT

text value of onerror option report

public static final int
REPORT

Enumerated values

Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
value

Constructor Summary

AccessConstructor and Description
public
OnError()

Constructor

public
OnError(String
the value of the attribute
value
)

Constructor using a string.

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

an array of the allowed values for this attribute.
getValues
()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

get the values
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Field Detail

FAILback to summary
public static final int FAIL

Enumerated values

FAIL_ALLback to summary
public static final int FAIL_ALL

Enumerated values

IGNOREback to summary
public static final int IGNORE

Enumerated values

POLICY_FAILback to summary
public static final String POLICY_FAIL

text value of onerror option fail

POLICY_FAILALLback to summary
public static final String POLICY_FAILALL

text value of onerror option failall

POLICY_IGNOREback to summary
public static final String POLICY_IGNORE

text value of onerror option ignore

POLICY_REPORTback to summary
public static final String POLICY_REPORT

text value of onerror option report

REPORTback to summary
public static final int REPORT

Enumerated values

Constructor Detail

OnErrorback to summary
public OnError()

Constructor

OnErrorback to summary
public OnError(String value)

Constructor using a string.

Parameters
value:String

the value of the attribute

Method Detail

getValuesback to summary
public String[] getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

get the values

Returns:String[]

an array of the allowed values for this attribute.

Annotations
@Override