Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tools.ant.taskdefs
Class XmlProperty

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.tools.ant.taskdefs.XmlProperty

public class XmlProperty
extends Task

Loads property values from a valid XML file, generating the property names from the file's element and attribute names. Example:

       <root-tag myattr="true">
         <inner-tag someattr="val">Text</inner-tag>
         <a2><a3><a4>false</a4></a3></a2>
       </root-tag>

this generates

      root-tag(myattr)=true
      root-tag.inner-tag=Text
      root-tag.inner-tag(someattr)=val
      root-tag.a2.a3.a4=false

Author:
  Nicola Ken Barozzi, Erik Hatcher

Field Summary

Fields inherited from class org.apache.tools.ant.Task
`description, location, target, taskName, taskType, wrapper`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`project`

Constructor Summary
`XmlProperty()` Constructor.

Method Summary
`void` | `execute()` Run the task.
`void` | `init()` Initializes the task.
`void` | `setCollapseAttributes(boolean collapseAttributes)` flag to treat attributes as nested elements; optional, default false
`void` | `setFile(java.io.File src)` The XML file to parse; required.
`void` | `setKeeproot(boolean keepRoot)` flag to include the xml root tag as a first value in the property name; optional, default is true
`void` | `setPrefix(java.lang.String prefix)` the prefix to prepend to each property
`void` | `setValidate(boolean validate)` flag to validate the XML file; optional, default false

Methods inherited from class org.apache.tools.ant.Task
`getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`getProject, setProject`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XmlProperty

    public XmlProperty()

  Constructor.

Method Detail

### init

    public void init()

  Initializes the task.

  Overrides:
    `init` in class `Task`

### execute

    public void execute()
                 throws BuildException

  Run the task.

  Overrides:
    `execute` in class `Task`
  Throws:
    `BuildException` - The exception raised during task execution.
  To do:
    validate the source file is valid before opening, print a better error message, add a verbose level log message listing the name of the file being loaded

### setFile

    public void setFile(java.io.File src)

  The XML file to parse; required.

### setPrefix

    public void setPrefix(java.lang.String prefix)

  the prefix to prepend to each property

### setKeeproot

    public void setKeeproot(boolean keepRoot)

  flag to include the xml root tag as a first value in the property name; optional, default is true

### setValidate

    public void setValidate(boolean validate)

  flag to validate the XML file; optional, default false

### setCollapseAttributes

    public void setCollapseAttributes(boolean collapseAttributes)

  flag to treat attributes as nested elements; optional, default false

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.