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

public abstract Class DataType

extends ProjectComponent
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Known Direct Subclasses
org.apache.tools.ant.types.Description, org.apache.tools.ant.types.FileList, org.apache.tools.ant.types.FilterChain, org.apache.tools.ant.types.FilterSet, org.apache.tools.ant.types.Mapper, org.apache.tools.ant.types.Path, org.apache.tools.ant.types.PatternSet, org.apache.tools.ant.types.PropertySet, org.apache.tools.ant.types.RedirectorElement, org.apache.tools.ant.types.RegularExpression, org.apache.tools.ant.types.Resource, org.apache.tools.ant.types.Substitution, org.apache.tools.ant.types.XMLCatalog, org.apache.tools.ant.types.resources.AbstractResourceCollectionWrapper, org.apache.tools.ant.types.resources.Archives, org.apache.tools.ant.types.resources.BaseResourceCollectionContainer, org.apache.tools.ant.types.resources.MappedResourceCollection, org.apache.tools.ant.types.resources.ResourceList, org.apache.tools.ant.types.resources.Resources, org.apache.tools.ant.types.resources.comparators.ResourceComparator, org.apache.tools.ant.types.resources.selectors.Compare, org.apache.tools.ant.types.resources.selectors.ResourceSelectorContainer, org.apache.tools.ant.types.selectors.AbstractSelectorContainer, org.apache.tools.ant.types.selectors.BaseSelector, org.apache.tools.ant.types.selectors.SignedSelector, org.apache.tools.ant.taskdefs.condition.IsSigned, org.apache.tools.ant.taskdefs.optional.extension.ExtensionAdapter, org.apache.tools.ant.taskdefs.optional.extension.ExtensionSet, org.apache.tools.ant.types.AbstractFileSet, org.apache.tools.ant.types.AntFilterReader, org.apache.tools.ant.types.Assertions
Imports
java.util.Stack, org.apache.tools.ant.BuildException, .ComponentHelper, .Project, .ProjectComponent, org.apache.tools.ant.util.IdentityStack

Base class for those classes that can appear inside the build file as stand alone data types.

This class handles the common description attribute and provides a default implementation for reference handling and checking for circular references that is appropriate for types that can not be nested inside elements of the same type (i.e. <patternset> but not <path>).

Field Summary

Modifier and TypeField and Description
protected boolean
checked

Are we sure we don't hold circular references?

protected Reference
ref

Value to the refid attribute.

Inherited from org.apache.tools.ant.ProjectComponent:
descriptionlocationproject

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
checkAttributesAllowed()

check that it is ok to set attributes, i.e that no reference is defined

protected void
checkChildrenAllowed()

check that it is ok to add children, i.e that no reference is defined

protected BuildException

Returns:

the exception to throw
circularReference
()

Creates an exception that indicates the user has generated a loop of data types referencing each other.

public Object

Returns:

a shallow copy of this DataType.
clone
()

Overrides org.apache.tools.ant.ProjectComponent.clone.

Creates and returns a copy of this object.
protected void
dieOnCircularReference()

Convenience method.

protected void
dieOnCircularReference(Project
the Ant Project instance against which to resolve references.
p
)

Convenience method.

protected void
dieOnCircularReference(final Stack<Object>
the stack of references to check.
stack
,
final Project
the project to use to dereference the references.
project
)

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).

private String
displayName(Class<?> clazz)

protected <
required reference type
T
>
T

Returns:

the dereferenced object.
getCheckedRef
()

Deprecated use getCheckedRef(Class)
Performs the check for circular references and returns the referenced object.
protected <
required reference type
T
>
T

Returns:

the dereferenced object.
getCheckedRef
(final Class<T>
the class that this reference should be a subclass of.
requiredClass
)

Performs the check for circular references and returns the referenced object.

protected <
required reference type
T
>
T

Returns:

the dereferenced object.
getCheckedRef
(Project
the Ant Project instance against which to resolve references.
p
)

Deprecated use getCheckedRef(Class)
Performs the check for circular references and returns the referenced object.
protected <
required reference type
T
>
T

Returns:

the dereferenced object.
getCheckedRef
(final Class<T>
the class that this reference should be a subclass of.
requiredClass
,
final String
the name of the datatype that the reference should be (error message use only).
dataTypeName
)

Performs the check for circular references and returns the referenced object.

protected <
required reference type
T
>
T

Returns:

the dereferenced object.
getCheckedRef
(final Class<T>
the class that this reference should be a subclass of.
requiredClass
,
final String
the name of the datatype that the reference should be (error message use only).
dataTypeName
,
final Project
the fallback Project instance for dereferencing.
project
)

Performs the check for circular references and returns the referenced object.

protected String

Returns:

String name.
getDataTypeName
()

Gets as descriptive as possible a name used for this datatype instance.

public Reference

Returns:

the reference or null
getRefid
()

get the reference set on this object

public static void
invokeCircularReferenceCheck(DataType
the DataType to check.
dt
,
Stack<Object>
the stack of references to check.
stk
,
Project
the project to use to dereference the references.
p
)

Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.

protected boolean

Returns:

true if circular references have been checked
isChecked
()

The flag that is used to indicate that circular references have been checked.

public boolean

Returns:

true if the refid attribute has been set
isReference
()

Has the refid attribute of this element been set?

protected BuildException

Returns:

the exception to throw
noChildrenAllowed
()

Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.

public static void
pushAndInvokeCircularReferenceCheck(DataType
the DataType to check.
dt
,
Stack<Object>
the stack of references to check.
stk
,
Project
the project to use to dereference the references.
p
)

Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.

protected void
setChecked(final boolean
if true, if circular references have been checked
checked
)

Set the flag that is used to indicate that circular references have been checked.

public void
setRefid(final Reference
the reference to use
ref
)

Set the value of the refid attribute.

protected BuildException

Returns:

the exception to throw
tooManyAttributes
()

Creates an exception that indicates that refid has to be the only attribute if it is set.

public String

Returns:

this DataType formatted as a String.
toString
()

Overrides java.lang.Object.toString.

Basic DataType toString().
Inherited from org.apache.tools.ant.ProjectComponent:
getDescriptiongetLocationgetProjectloglogsetDescriptionsetLocationsetProject

Field Detail

checkedback to summary
protected boolean checked

Deprecated

since 1.7. The user should not be directly referencing variable. Please use setChecked or isChecked instead.

Are we sure we don't hold circular references?

Subclasses are responsible for setting this value to false if we'd need to investigate this condition (usually because a child element has been added that is a subclass of DataType).

Annotations
@Deprecated
refback to summary
protected Reference ref

Deprecated

since 1.7. The user should not be directly referencing variable. Please use getRefid instead.

Value to the refid attribute.

Annotations
@Deprecated

Constructor Detail

DataTypeback to summary
public DataType()

Method Detail

checkAttributesAllowedback to summary
protected void checkAttributesAllowed()

check that it is ok to set attributes, i.e that no reference is defined

Exceptions
BuildException:
if not allowed
Since
Ant 1.6
checkChildrenAllowedback to summary
protected void checkChildrenAllowed()

check that it is ok to add children, i.e that no reference is defined

Exceptions
BuildException:
if not allowed
Since
Ant 1.6
circularReferenceback to summary
protected BuildException circularReference()

Creates an exception that indicates the user has generated a loop of data types referencing each other.

Returns:BuildException

the exception to throw

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides org.apache.tools.ant.ProjectComponent.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a shallow copy of this DataType.

Annotations
@Override
Exceptions
CloneNotSupportedException:
if there is a problem.
Since
Ant 1.7
dieOnCircularReferenceback to summary
protected void dieOnCircularReference()

Convenience method.

Since
Ant 1.7
dieOnCircularReferenceback to summary
protected void dieOnCircularReference(Project p)

Convenience method.

Parameters
p:Project

the Ant Project instance against which to resolve references.

Since
Ant 1.7
dieOnCircularReferenceback to summary
protected void dieOnCircularReference(final Stack<Object> stack, final Project project) throws BuildException

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).

If one is included, throw a BuildException created by circularReference.

This implementation is appropriate only for a DataType that cannot hold other DataTypes as children.

The general contract of this method is that it shouldn't do anything if checked is true and set it to true on exit.

Parameters
stack:Stack<Object>

the stack of references to check.

project:Project

the project to use to dereference the references.

Exceptions
BuildException:
on error.
displayNameback to summary
private String displayName(Class<?> clazz)
getCheckedRefback to summary
protected <T> T getCheckedRef()

Deprecated

use getCheckedRef(Class)

Performs the check for circular references and returns the referenced object.

Parameters
<T>
required reference type
Returns:T

the dereferenced object.

Annotations
@Deprecated
Exceptions
BuildException:
if the reference is invalid (circular ref, wrong class, etc).
Since
Ant 1.7
getCheckedRefback to summary
protected <T> T getCheckedRef(final Class<T> requiredClass)

Performs the check for circular references and returns the referenced object.

Parameters
<T>
required reference type
requiredClass:Class<T>

the class that this reference should be a subclass of.

Returns:T

the dereferenced object.

Exceptions
BuildException:
if the reference is invalid (circular ref, wrong class, etc).
Since
Ant 1.10.6
getCheckedRefback to summary
protected <T> T getCheckedRef(Project p)

Deprecated

use getCheckedRef(Class)

Performs the check for circular references and returns the referenced object.

Parameters
<T>
required reference type
p:Project

the Ant Project instance against which to resolve references.

Returns:T

the dereferenced object.

Annotations
@Deprecated
@SuppressWarnings:unchecked
Exceptions
BuildException:
if the reference is invalid (circular ref, wrong class, etc).
Since
Ant 1.7
getCheckedRefback to summary
protected <T> T getCheckedRef(final Class<T> requiredClass, final String dataTypeName)

Performs the check for circular references and returns the referenced object.

Parameters
<T>
required reference type
requiredClass:Class<T>

the class that this reference should be a subclass of.

dataTypeName:String

the name of the datatype that the reference should be (error message use only).

Returns:T

the dereferenced object.

Exceptions
BuildException:
if the reference is invalid (circular ref, wrong class, etc).
getCheckedRefback to summary
protected <T> T getCheckedRef(final Class<T> requiredClass, final String dataTypeName, final Project project)

Performs the check for circular references and returns the referenced object. This version allows the fallback Project instance to be specified.

Parameters
<T>
required reference type
requiredClass:Class<T>

the class that this reference should be a subclass of.

dataTypeName:String

the name of the datatype that the reference should be (error message use only).

project:Project

the fallback Project instance for dereferencing.

Returns:T

the dereferenced object.

Exceptions
BuildException:
if the reference is invalid (circular ref, wrong class, etc), or if project is null.
Since
Ant 1.7
getDataTypeNameback to summary
protected String getDataTypeName()

Gets as descriptive as possible a name used for this datatype instance.

Returns:String

String name.

getRefidback to summary
public Reference getRefid()

get the reference set on this object

Returns:Reference

the reference or null

invokeCircularReferenceCheckback to summary
public static void invokeCircularReferenceCheck(DataType dt, Stack<Object> stk, Project p)

Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.

Parameters
dt:DataType

the DataType to check.

stk:Stack<Object>

the stack of references to check.

p:Project

the project to use to dereference the references.

Exceptions
BuildException:
on error.
Since
Ant 1.7
isCheckedback to summary
protected boolean isChecked()

The flag that is used to indicate that circular references have been checked.

Returns:boolean

true if circular references have been checked

isReferenceback to summary
public boolean isReference()

Has the refid attribute of this element been set?

Returns:boolean

true if the refid attribute has been set

noChildrenAllowedback to summary
protected BuildException noChildrenAllowed()

Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.

Returns:BuildException

the exception to throw

pushAndInvokeCircularReferenceCheckback to summary
public static void pushAndInvokeCircularReferenceCheck(DataType dt, Stack<Object> stk, Project p)

Allow DataTypes outside org.apache.tools.ant.types to indirectly call dieOnCircularReference on nested DataTypes.

Pushes dt on the stack, runs dieOnCircularReference and pops it again.

Parameters
dt:DataType

the DataType to check.

stk:Stack<Object>

the stack of references to check.

p:Project

the project to use to dereference the references.

Exceptions
BuildException:
on error.
Since
Ant 1.8.0
setCheckedback to summary
protected void setChecked(final boolean checked)

Set the flag that is used to indicate that circular references have been checked.

Parameters
checked:boolean

if true, if circular references have been checked

setRefidback to summary
public void setRefid(final Reference ref)

Set the value of the refid attribute.

Subclasses may need to check whether any other attributes have been set as well or child elements have been created and thus override this method. if they do the must call super.setRefid.

Parameters
ref:Reference

the reference to use

tooManyAttributesback to summary
protected BuildException tooManyAttributes()

Creates an exception that indicates that refid has to be the only attribute if it is set.

Returns:BuildException

the exception to throw

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Basic DataType toString().

Returns:String

this DataType formatted as a String.

Annotations
@Override