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

public Class UnknownElement

extends Task
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Collections, .Iterator, .List, .Map, .Objects, org.apache.tools.ant.taskdefs.PreSetDef

Wrapper class that holds all the information necessary to create a task or data type that did not exist when Ant started, or one which has had its definition updated to use a different implementation class.

Field Summary

Modifier and TypeField and Description
private List<UnknownElement>
children

List of child elements (UnknownElements).

private final String
elementName

Holds the name of the task/type or nested child element of a task/type that hasn't been defined at parser time or has been redefined since original creation.

private String
namespace

Holds the namespace of the element.

private boolean
presetDefed

Specifies if a predefined definition has been done

private String
qname

Holds the namespace qname of the element.

private Object
realThing

The real object after it has been loaded.

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

Constructor Summary

AccessConstructor and Description
public
UnknownElement(String
The name of the unknown element. Must not be null.
elementName
)

Creates an UnknownElement for the given element name.

Method Summary

Modifier and TypeMethod and Description
public void
addChild(UnknownElement
The child element to add. Must not be null.
child
)

Adds a child element to this element.

public void
applyPreSet(UnknownElement
an UnknownElement containing the attributes, elements and text
u
)

This is used then the realobject of the UE is a PreSetDefinition.

public void
configure(Object
the real object this UnknownElement is representing.
realObject
)

Configure the given object from this UnknownElement

public UnknownElement

Returns:

the copied UE.
copy
(Project
the project to create the UE in.
newProject
)

Make a copy of the unknown element and set it in the new project.

public void
execute()

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

Executes the real object if it's a task.
public List<UnknownElement>

Returns:

the list of nested UnknownElements for this UnknownElement.
getChildren
()

protected String

Returns:

the component name - uses ProjectHelper#genComponentName()
getComponentName
()

public String

Returns:

Namespace URI used in the xmlns declaration.
getNamespace
()

Return the namespace of the XML element associated with this component.

protected BuildException

Returns:

a detailed description of what might have caused the problem.
getNotFoundException
(String
The kind of thing being created. For example, when a task name could not be found, this would be "task". Should not be null.
what
,
String
The name of the element which could not be found. Should not be null.
name
)

Returns a very verbose exception for when a task/data type cannot be found.

public String

Returns:

namespace Qname used in the element declaration.
getQName
()

Return the qname of the XML element associated with this component.

public Object

Returns:

the real thing whatever it is
getRealThing
()

Return the configured object

public String

Returns:

the name of the XML element which generated this unknown element.
getTag
()

Returns the name of the XML element which generated this unknown element.

public Task

Returns:

a task instance or null if the real object is not a task.
getTask
()

Returns the task instance after it has been created and if it is a task.

public String

Returns:

the name to use in logging messages.
getTaskName
()

Overrides org.apache.tools.ant.Task.getTaskName.

Returns the name to use in logging messages.
public RuntimeConfigurable

Returns:

the configuration info.
getWrapper
()

Overrides org.apache.tools.ant.Task.getWrapper.

Get the RuntimeConfigurable instance for this UnknownElement, containing the configuration information.
private boolean

Returns:

whether the creation has been successful
handleChild
(String parentUri, IntrospectionHelper ih, Object parent, UnknownElement child, RuntimeConfigurable childWrapper)

Try to create a nested element of parent for the given tag.

protected void
handleChildren(Object
The configured object for the parent. Must not be null.
parent
,
RuntimeConfigurable
The wrapper containing child wrappers to be configured. Must not be null if there are any children.
parentWrapper
)

Creates child elements, creates children of the children (recursively), and sets attributes of the child elements.

protected void
handleErrorFlush(String
The error output to log. Should not be null.
output
)

Overrides org.apache.tools.ant.Task.handleErrorFlush.

Handles error output sent to System.err by this task or its real task.
protected void
handleErrorOutput(String
The error output to log. Should not be null.
output
)

Overrides org.apache.tools.ant.Task.handleErrorOutput.

Handles error output sent to System.err by this task or its real task.
protected void
handleFlush(String
The output to log. Should not be null.
output
)

Overrides org.apache.tools.ant.Task.handleFlush.

Handles output sent to System.out by this task or its real task.
protected int

Returns:

the number of bytes read.
handleInput
(byte[]
the buffer into which data is to be read.
buffer
,
int
the offset into the buffer at which data is stored.
offset
,
int
the amount of data to read.
length
)

Overrides org.apache.tools.ant.Task.handleInput.

Delegate to realThing if present and if it as task.
protected void
handleOutput(String
The output to log. Should not be null.
output
)

Overrides org.apache.tools.ant.Task.handleOutput.

Handles output sent to System.out by this task or its real task.
protected Object

Returns:

the task or data type represented by the given unknown element.
makeObject
(UnknownElement
The unknown element to create the real object for. Must not be null.
ue
,
RuntimeConfigurable
Ignored in this implementation.
w
)

Creates a named task or data type.

protected Task

Returns:

the task specified by the given unknown element, or null if the task name is not recognised.
makeTask
(UnknownElement
The UnknownElement to create the real task for. Must not be null.
ue
,
RuntimeConfigurable
Ignored.
w
)

Creates a named task and configures it up to the init() stage.

public void
maybeConfigure()

Overrides org.apache.tools.ant.Task.maybeConfigure.

Creates the real object instance and child elements, then configures the attributes and text of the real object.
public void
setNamespace(String
URI used in the xmlns declaration.
namespace
)

Set the namespace of the XML element associated with this component.

public void
setQName(String
the qualified name of the element
qname
)

Set the namespace qname of the XML element.

public void
setRealThing(Object
the configured object
realThing
)

Set the configured object

public boolean

Returns:

true if this UnknownElement has the same contents the other
similar
(Object
the object to check against
obj
)

like contents equals, but ignores project

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

Field Detail

childrenback to summary
private List<UnknownElement> children

List of child elements (UnknownElements).

elementNameback to summary
private final String elementName

Holds the name of the task/type or nested child element of a task/type that hasn't been defined at parser time or has been redefined since original creation.

namespaceback to summary
private String namespace

Holds the namespace of the element.

presetDefedback to summary
private boolean presetDefed

Specifies if a predefined definition has been done

qnameback to summary
private String qname

Holds the namespace qname of the element.

realThingback to summary
private Object realThing

The real object after it has been loaded.

Constructor Detail

UnknownElementback to summary
public UnknownElement(String elementName)

Creates an UnknownElement for the given element name.

Parameters
elementName:String

The name of the unknown element. Must not be null.

Method Detail

addChildback to summary
public void addChild(UnknownElement child)

Adds a child element to this element.

Parameters
child:UnknownElement

The child element to add. Must not be null.

applyPreSetback to summary
public void applyPreSet(UnknownElement u)

This is used then the realobject of the UE is a PreSetDefinition. This is also used when a presetdef is used on a presetdef The attributes, elements and text are applied to this UE.

Parameters
u:UnknownElement

an UnknownElement containing the attributes, elements and text

configureback to summary
public void configure(Object realObject)

Configure the given object from this UnknownElement

Parameters
realObject:Object

the real object this UnknownElement is representing.

copyback to summary
public UnknownElement copy(Project newProject)

Make a copy of the unknown element and set it in the new project.

Parameters
newProject:Project

the project to create the UE in.

Returns:UnknownElement

the copied UE.

executeback to summary
public void execute()

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

Executes the real object if it's a task. If it's not a task (e.g. a data type) then this method does nothing.

getChildrenback to summary
public List<UnknownElement> getChildren()
Returns:List<UnknownElement>

the list of nested UnknownElements for this UnknownElement.

getComponentNameback to summary
protected String getComponentName()
Returns:String

the component name - uses ProjectHelper#genComponentName()

getNamespaceback to summary
public String getNamespace()

Return the namespace of the XML element associated with this component.

Returns:String

Namespace URI used in the xmlns declaration.

getNotFoundExceptionback to summary
protected BuildException getNotFoundException(String what, String name)

Returns a very verbose exception for when a task/data type cannot be found.

Parameters
what:String

The kind of thing being created. For example, when a task name could not be found, this would be "task". Should not be null.

name:String

The name of the element which could not be found. Should not be null.

Returns:BuildException

a detailed description of what might have caused the problem.

getQNameback to summary
public String getQName()

Return the qname of the XML element associated with this component.

Returns:String

namespace Qname used in the element declaration.

getRealThingback to summary
public Object getRealThing()

Return the configured object

Returns:Object

the real thing whatever it is

Since
ant 1.6
getTagback to summary
public String getTag()

Returns the name of the XML element which generated this unknown element.

Returns:String

the name of the XML element which generated this unknown element.

getTaskback to summary
public Task getTask()

Returns the task instance after it has been created and if it is a task.

Returns:Task

a task instance or null if the real object is not a task.

getTaskNameback to summary
public String getTaskName()

Overrides org.apache.tools.ant.Task.getTaskName.

Returns the name to use in logging messages.

Returns:String

the name to use in logging messages.

getWrapperback to summary
public RuntimeConfigurable getWrapper()

Overrides org.apache.tools.ant.Task.getWrapper.

Get the RuntimeConfigurable instance for this UnknownElement, containing the configuration information.

Returns:RuntimeConfigurable

the configuration info.

handleChildback to summary
private boolean handleChild(String parentUri, IntrospectionHelper ih, Object parent, UnknownElement child, RuntimeConfigurable childWrapper)

Try to create a nested element of parent for the given tag.

Returns:boolean

whether the creation has been successful

handleChildrenback to summary
protected void handleChildren(Object parent, RuntimeConfigurable parentWrapper) throws BuildException

Creates child elements, creates children of the children (recursively), and sets attributes of the child elements.

Parameters
parent:Object

The configured object for the parent. Must not be null.

parentWrapper:RuntimeConfigurable

The wrapper containing child wrappers to be configured. Must not be null if there are any children.

Exceptions
BuildException:
if the children cannot be configured.
handleErrorFlushback to summary
protected void handleErrorFlush(String output)

Overrides org.apache.tools.ant.Task.handleErrorFlush.

Handles error output sent to System.err by this task or its real task.

Parameters
output:String

The error output to log. Should not be null.

handleErrorOutputback to summary
protected void handleErrorOutput(String output)

Overrides org.apache.tools.ant.Task.handleErrorOutput.

Handles error output sent to System.err by this task or its real task.

Parameters
output:String

The error output to log. Should not be null.

handleFlushback to summary
protected void handleFlush(String output)

Overrides org.apache.tools.ant.Task.handleFlush.

Handles output sent to System.out by this task or its real task.

Parameters
output:String

The output to log. Should not be null.

handleInputback to summary
protected int handleInput(byte[] buffer, int offset, int length) throws IOException

Overrides org.apache.tools.ant.Task.handleInput.

Delegate to realThing if present and if it as task.

Parameters
buffer:byte[]

the buffer into which data is to be read.

offset:int

the offset into the buffer at which data is stored.

length:int

the amount of data to read.

Returns:int

the number of bytes read.

Exceptions
IOException:
if the data cannot be read.
Since
Ant 1.6
See Also
Task#handleInput(byte[], int, int)
handleOutputback to summary
protected void handleOutput(String output)

Overrides org.apache.tools.ant.Task.handleOutput.

Handles output sent to System.out by this task or its real task.

Parameters
output:String

The output to log. Should not be null.

makeObjectback to summary
protected Object makeObject(UnknownElement ue, RuntimeConfigurable w)

Creates a named task or data type. If the real object is a task, it is configured up to the init() stage.

Parameters
ue:UnknownElement

The unknown element to create the real object for. Must not be null.

w:RuntimeConfigurable

Ignored in this implementation.

Returns:Object

the task or data type represented by the given unknown element.

makeTaskback to summary
protected Task makeTask(UnknownElement ue, RuntimeConfigurable w)

Creates a named task and configures it up to the init() stage.

Parameters
ue:UnknownElement

The UnknownElement to create the real task for. Must not be null.

w:RuntimeConfigurable

Ignored.

Returns:Task

the task specified by the given unknown element, or null if the task name is not recognised.

maybeConfigureback to summary
public void maybeConfigure() throws BuildException

Overrides org.apache.tools.ant.Task.maybeConfigure.

Creates the real object instance and child elements, then configures the attributes and text of the real object. This unknown element is then replaced with the real object in the containing target's list of children.

Exceptions
BuildException:
if the configuration fails
setNamespaceback to summary
public void setNamespace(String namespace)

Set the namespace of the XML element associated with this component. This method is typically called by the XML processor. If the namespace is "ant:current", the component helper is used to get the current antlib uri.

Parameters
namespace:String

URI used in the xmlns declaration.

setQNameback to summary
public void setQName(String qname)

Set the namespace qname of the XML element. This method is typically called by the XML processor.

Parameters
qname:String

the qualified name of the element

setRealThingback to summary
public void setRealThing(Object realThing)

Set the configured object

Parameters
realThing:Object

the configured object

Since
ant 1.7
similarback to summary
public boolean similar(Object obj)

like contents equals, but ignores project

Parameters
obj:Object

the object to check against

Returns:boolean

true if this UnknownElement has the same contents the other