org.jcoderz.commons.taskdefs
Class XpathPropertyTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.jcoderz.commons.taskdefs.XpathPropertyTask
All Implemented Interfaces:
Cloneable

public class XpathPropertyTask
extends org.apache.tools.ant.Task

This task allows to set a property based on an xpath expression, evaluated on a given xml file.

The tasks needs 3 properties to be set:

name
The name of the property to be set.
file
The xml file to be parsed.
xpath
The xpath expression to be evaluated on the given file.

The task can be defined using the following taskdef:

     <taskdef name="xpathproperty" 
         classname="org.jcoderz.commons.taskdefs.XpathPropertyTask"
         classpath="fawkez-all.jar"/>
 

A possible use would be:

     <xpathproperty 
        name="xpathtest" 
        xpath="/project/@name" 
        file="build.xml"/>
 
Which would set the property xpathtest to fawkeZ is applied to the fawkez build.xml.

The task requires java5 to function properly.

Author:
Andreas Mandel

Field Summary
static String NAME
          Task name.
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
XpathPropertyTask()
           
 
Method Summary
 void execute()
          Perform the evaluation.
 void setFile(File xmlFile)
          Set the file to be parsed.
 void setName(String name)
          Set the name of the property to be set.
 void setXpath(String xpath)
          Set the xpath expression to be evaluated.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
Task name.

See Also:
Constant Field Values
Constructor Detail

XpathPropertyTask

public XpathPropertyTask()
Method Detail

setFile

public void setFile(File xmlFile)
Set the file to be parsed. The file must exist and be readable.

Parameters:
xmlFile - the file to be parsed.

setXpath

public void setXpath(String xpath)
Set the xpath expression to be evaluated. See javadoc or XPath Recommendation for details about XPath.

Parameters:
xpath - the xpath expression to be evaluated.

setName

public void setName(String name)
Set the name of the property to be set.

Parameters:
name - the name of the property to be set.

execute

public void execute()
Perform the evaluation.

Overrides:
execute in class org.apache.tools.ant.Task


Copyright 2007 The jCoderZ Project.