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

public Class Assertions

extends DataType
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.util.ArrayList, .List, .ListIterator, org.apache.tools.ant.BuildException, .Project

The assertion datatype. This type describes assertion settings for the <java> task and others. One can set the system assertions, and enable/disable those in packages and classes. Assertions can only be enabled or disabled when forking Java. Example: set system assertions and all org.apache packages except for ant, and the class org.apache.tools.ant.Main.
 <assertions enableSystemAssertions="true" >
   <enable package="org.apache" />
   <disable package="org.apache.ant" />
   <enable class="org.apache.tools.ant.Main"/>
 </assertions>
Disable system assertions; enable those in the anonymous package
 <assertions enableSystemAssertions="false" >
   <enable package="..." />
 </assertions>
 
enable assertions in a class called Test
 <assertions >
   <enable class="Test" />
 </assertions>
 
This type is a datatype, so you can declare assertions and use them later
 <assertions id="project.assertions" >
   <enable project="org.apache.test" />
 </assertions>

 <assertions refid="project.assertions" />

 
Since
Ant 1.6

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
Assertions.BaseAssertion

base class for our assertion elements.

public static class
Assertions.DisabledAssertion

A disabled assertion disables things

public static class
Assertions.EnabledAssertion

an enabled assertion enables things

Field Summary

Modifier and TypeField and Description
private ArrayList<Assertions.BaseAssertion>
assertionList

list of type BaseAssertion

private Boolean
enableSystemAssertions

enable/disable sys assertions; null means undefined

Inherited from org.apache.tools.ant.types.DataType:
checkedref

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addDisable(Assertions.DisabledAssertion
a disable assertion nested element
assertion
)

disable assertions

public void
addEnable(Assertions.EnabledAssertion
an enable assertion nested element
assertion
)

enable assertions

private static void
addVmArgument(CommandlineJava
ditto
command
,
String
ditto
arg
)

helper method to add a string JVM argument to a command

public void
applyAssertions(List<String>
the command line to format
commandList
)

add the assertions to a list in a format suitable for adding to a command line

public void
applyAssertions(CommandlineJava
the command line to format
command
)

apply all the assertions to the command.

public void
applyAssertions(final ListIterator<String>
list of commands
commandIterator
)

add the assertions to a list in a format suitable for adding to a command line

public Object

Returns:

a cli
clone
()

Overrides org.apache.tools.ant.types.DataType.clone.

clone the objects.
private Assertions

Returns:

the object that contains the assertion info
getFinalReference
()

get whatever we are referencing to.

private int

Returns:

number of assertions
getFinalSize
()

what is the final size of this object

public void
setEnableSystemAssertions(Boolean
if true enable system assertions
enableSystemAssertions
)

enable or disable system assertions.

public void
setRefid(Reference
the reference to use
ref
)

Overrides org.apache.tools.ant.types.DataType.setRefid.

Set the value of the refid attribute.
public int

Returns:

total # of commands to make
size
()

how many assertions are made...will resolve references before returning

Inherited from org.apache.tools.ant.types.DataType:
checkAttributesAllowedcheckChildrenAllowedcircularReferencedieOnCircularReferencedieOnCircularReferencedieOnCircularReferencegetCheckedRefgetCheckedRefgetCheckedRefgetCheckedRefgetCheckedRefgetDataTypeNamegetRefidinvokeCircularReferenceCheckisCheckedisReferencenoChildrenAllowedpushAndInvokeCircularReferenceChecksetCheckedtooManyAttributestoString

Field Detail

assertionListback to summary
private ArrayList<Assertions.BaseAssertion> assertionList

list of type BaseAssertion

enableSystemAssertionsback to summary
private Boolean enableSystemAssertions

enable/disable sys assertions; null means undefined

Constructor Detail

Assertionsback to summary
public Assertions()

Method Detail

addDisableback to summary
public void addDisable(Assertions.DisabledAssertion assertion)

disable assertions

Parameters
assertion:Assertions.DisabledAssertion

a disable assertion nested element

addEnableback to summary
public void addEnable(Assertions.EnabledAssertion assertion)

enable assertions

Parameters
assertion:Assertions.EnabledAssertion

an enable assertion nested element

addVmArgumentback to summary
private static void addVmArgument(CommandlineJava command, String arg)

helper method to add a string JVM argument to a command

Parameters
command:CommandlineJava

ditto

arg:String

ditto

applyAssertionsback to summary
public void applyAssertions(List<String> commandList)

add the assertions to a list in a format suitable for adding to a command line

Parameters
commandList:List<String>

the command line to format

applyAssertionsback to summary
public void applyAssertions(CommandlineJava command)

apply all the assertions to the command.

Parameters
command:CommandlineJava

the command line to format

applyAssertionsback to summary
public void applyAssertions(final ListIterator<String> commandIterator)

add the assertions to a list in a format suitable for adding to a command line

Parameters
commandIterator:ListIterator<String>

list of commands

cloneback to summary
public Object clone() throws CloneNotSupportedException

Overrides org.apache.tools.ant.types.DataType.clone.

clone the objects. This is not a full depth clone; the list of assertions is cloned, but it does not clone the underlying assertions.

Returns:Object

a cli

Annotations
@Override
Exceptions
CloneNotSupportedException:
if the super class does not support cloning
getFinalReferenceback to summary
private Assertions getFinalReference()

get whatever we are referencing to. This could be ourself.

Returns:Assertions

the object that contains the assertion info

getFinalSizeback to summary
private int getFinalSize()

what is the final size of this object

Returns:int

number of assertions

setEnableSystemAssertionsback to summary
public void setEnableSystemAssertions(Boolean enableSystemAssertions)

enable or disable system assertions. Default is not set (neither -enablesystemassertions or -disablesytemassertions are used on the command line).

Parameters
enableSystemAssertions:Boolean

if true enable system assertions

setRefidback to summary
public void setRefid(Reference ref)

Overrides org.apache.tools.ant.types.DataType.setRefid.

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

sizeback to summary
public int size()

how many assertions are made...will resolve references before returning

Returns:int

total # of commands to make

org.apache.tools.ant.types back to summary

public abstract Class Assertions.BaseAssertion

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.types.Assertions.EnabledAssertion, org.apache.tools.ant.types.Assertions.DisabledAssertion

base class for our assertion elements.

Field Summary

Modifier and TypeField and Description
private String
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String

Returns:

classname or null
getClassName
()

what is the class name?

public abstract String

Returns:

prefix
getCommandPrefix
()

get the prefix used to begin the command; -ea or -da.

protected String

Returns:

package name or null
getPackageName
()

what is the package name?

public void
setClass(String
a class name
className
)

name a class

public void
setPackage(String
a package name
packageName
)

name a package

public String

Returns:

The command string
toCommand
()

create a full command string from this class

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classNameback to summary
private String className
packageNameback to summary
private String packageName

Constructor Detail

BaseAssertionback to summary
public BaseAssertion()

Method Detail

getClassNameback to summary
protected String getClassName()

what is the class name?

Returns:String

classname or null

See Also
setClass
getCommandPrefixback to summary
public abstract String getCommandPrefix()

get the prefix used to begin the command; -ea or -da.

Returns:String

prefix

getPackageNameback to summary
protected String getPackageName()

what is the package name?

Returns:String

package name or null

See Also
setPackage
setClassback to summary
public void setClass(String className)

name a class

Parameters
className:String

a class name

setPackageback to summary
public void setPackage(String packageName)

name a package

Parameters
packageName:String

a package name

toCommandback to summary
public String toCommand()

create a full command string from this class

Returns:String

The command string

Exceptions
BuildException:
in case of trouble
org.apache.tools.ant.types back to summary

public Class Assertions.DisabledAssertion

extends BaseAssertion
Class Inheritance

A disabled assertion disables things

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

prefix
getCommandPrefix
()

Implements abstract org.apache.tools.ant.types.Assertions.BaseAssertion.getCommandPrefix.

get the prefix used to begin the command; -ea or -da.
Inherited from org.apache.tools.ant.types.Assertions.BaseAssertion:
getClassNamegetPackageNamesetClasssetPackagetoCommand

Constructor Detail

DisabledAssertionback to summary
public DisabledAssertion()

Method Detail

getCommandPrefixback to summary
public String getCommandPrefix()

Implements abstract org.apache.tools.ant.types.Assertions.BaseAssertion.getCommandPrefix.

get the prefix used to begin the command; -ea or -da.

Returns:String

prefix

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

public Class Assertions.EnabledAssertion

extends BaseAssertion
Class Inheritance

an enabled assertion enables things

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

prefix
getCommandPrefix
()

Implements abstract org.apache.tools.ant.types.Assertions.BaseAssertion.getCommandPrefix.

get the prefix used to begin the command; -ea or -da.
Inherited from org.apache.tools.ant.types.Assertions.BaseAssertion:
getClassNamegetPackageNamesetClasssetPackagetoCommand

Constructor Detail

EnabledAssertionback to summary
public EnabledAssertion()

Method Detail

getCommandPrefixback to summary
public String getCommandPrefix()

Implements abstract org.apache.tools.ant.types.Assertions.BaseAssertion.getCommandPrefix.

get the prefix used to begin the command; -ea or -da.

Returns:String

prefix

Annotations
@Override