# tasks/ext/XmlPropertyTask.php

Task for setting properties from an XML file in buildfiles.

Author
  Jonathan Bond-Caron
Link
  http://ant.apache.org/manual/CoreTasks/xmlproperty.html
Package
  phing.tasks.ext
Since
  2.4.0
Version
  $Revision: 1110 $

## \XmlPropertyTask
jump to top

Package: phing\tasks\ext

Task for setting properties from an XML file in buildfiles.

Use {@link Project#createTask} to register a new Task.

Parent(s)
  \PropertyTask < \Task < \ProjectComponent
Author
  Jonathan Bond-Caron
Copyright
  2001,2002 THYRELL. All rights reserved
Link
  http://ant.apache.org/manual/CoreTasks/xmlproperty.html
Since
  2.4.0
Version
  $Revision: 1110 $

### Properties

`$_collapseAttr= 'false'`
Default value `false` Details

Type

`$_delimiter= '',''`
Default value`','`Details

Type

`$_keepRoot= 'true'`
Default value `true` Details

Type

`string $description= ''`
inherited

description of the taskInherited from: \Task::$description
Details

Type
  string
Inherited_from
  \Task::$description

`$env= ''`
inherited Inherited from: \PropertyTask::$env
Details

Type
Inherited_from
  \PropertyTask::$env

`$fallback= ''`
inherited Inherited from: \PropertyTask::$fallback
Details

Type
Inherited_from
  \PropertyTask::$fallback

`$file= ''`
inherited Inherited from: \PropertyTask::$file
Details

Type
Inherited_from
  \PropertyTask::$file

`\Location $location= ''`
inherited

stored buildfile locationInherited from: \Task::$location
Details

Type
  \Location
Inherited_from
  \Task::$location

`$name= ''`
inherited

name of the property

Inherited from: \PropertyTask::$name
Details

Type
Inherited_from
  \PropertyTask::$name

`$override= 'false'`
inherited

Whether to force overwrite of existing property.

Inherited from: \PropertyTask::$override
Default value `false` Details

Type
Inherited_from
  \PropertyTask::$override

`$prefix= ''`
inherited Inherited from: \PropertyTask::$prefix
Details

Type
Inherited_from
  \PropertyTask::$prefix

`\Project $project= 'null'`
inherited

Holds a reference to the project that a project component (a task, a target, etc.) belongs to

A reference to the current project instanceInherited from: \ProjectComponent::$project
Default value `null` Details

Type
  \Project
Inherited_from
  \ProjectComponent::$project

`$ref= ''`
inherited Inherited from: \PropertyTask::$ref
Details

Type
Inherited_from
  \PropertyTask::$ref

`$reference= ''`
inherited Inherited from: \PropertyTask::$reference
Details

Type
Inherited_from
  \PropertyTask::$reference

`\Target $target= ''`
inherited

owning Target objectInherited from: \Task::$target
Details

Type
  \Target
Inherited_from
  \Task::$target

`string $taskName= ''`
inherited

Taskname for loggerInherited from: \Task::$taskName
Details

Type
  string
Inherited_from
  \Task::$taskName

`string $taskType= ''`
inherited

internal taskname (req)Inherited from: \Task::$taskType
Details

Type
  string
Inherited_from
  \Task::$taskType

`$userProperty= 'false'`
inherited

Whether property should be treated as "user" property.

Inherited from: \PropertyTask::$userProperty
Default value `false` Details

Type
Inherited_from
  \PropertyTask::$userProperty

`$value= ''`
inherited

value of the property

Inherited from: \PropertyTask::$value
Details

Type
Inherited_from
  \PropertyTask::$value

`\RuntimeConfigurable $wrapper= ''`
inherited

wrapper of the taskInherited from: \Task::$wrapper
Details

Type
  \RuntimeConfigurable
Inherited_from
  \Task::$wrapper

### Methods

`_addNode( \SimpleXMLElement $node, array $path, \Properties $prop ) : void`

Adds an XML node

Parameters

Name | Type | Description
--- | --- | ---
$node | \SimpleXMLElement |
$path | array | Path to this node
$prop | \Properties | Properties will be added as they are found (by reference here)

`_getProperties( string $filePath ) : \Properties`

Parses an XML file and returns properties

Parameters

Name | Type | Description
--- | --- | ---
$filePath | string |

Returns

Type | Description
--- | ---
\Properties |

`addProperties( $props ) : void`
inherited

iterate through a set of properties, resolve them then assign them

Inherited from: \PropertyTask::addProperties()
Parameters

Name | Type | Description
--- | --- | ---
$props |  |

`addProperty( string $name, string $value ) : void`
inherited

add a name value pair to the project property set

Inherited from: \PropertyTask::addProperty()
Parameters

Name | Type | Description
--- | --- | ---
$name | string | name of property
$value | string | value to set

`addText( $value ) : void`
inherited

Sets value of property to CDATA tag contents.

Inherited from: \PropertyTask::addText()
Parameters

Name | Type | Description
--- | --- | ---
$value |  |

Details

Since
  2.2.0

`getCollapseAttributes( ) : bool`

Returns

Type | Description
--- | ---
bool |

`getDelimiter( ) : string`

Returns

Type | Description
--- | ---
string |

`getDescription( ) : string`
inherited

Returns the textual description of the task

Inherited from: \Task::getDescription()
Returns

Type | Description
--- | ---
string | The text description of the task

`getEnvironment( ) : void`
inherited

Inherited from: \PropertyTask::getEnvironment()
`getFallback( ) : void`
inherited

Inherited from: \PropertyTask::getFallback()
`getFile( ) : void`

Get the PhingFile that is being used as property source.

`getKeepRoot( ) : bool`

Returns

Type | Description
--- | ---
bool |

`getLocation( ) : \Location`
inherited

Returns the location within the buildfile this task occurs. Used by {@link BuildException} to give detailed error messages.

Inherited from: \Task::getLocation()
Returns

Type | Description
--- | ---
\Location | The location object describing the position of this task within the buildfile.

`getName( ) : void`
inherited

Get property component name.

Inherited from: \PropertyTask::getName()
`getOverride( ) : void`
inherited

Inherited from: \PropertyTask::getOverride()
`getOwningTarget( ) : \Target`
inherited

Returns the owning target of this task.

Inherited from: \Task::getOwningTarget()
Returns

Type | Description
--- | ---
\Target | The target object that owns this task

`getPrefix( ) : string`

Returns

Type | Description
--- | ---
string |

Details

Since
  2.0

`getProject( ) : \Project`
inherited

Returns a reference to current project

Inherited from: \ProjectComponent::getProject()
Returns

Type | Description
--- | ---
\Project | Reference to current porject object

`getRefid( ) : void`
inherited

Inherited from: \PropertyTask::getRefid()
`getRegisterSlot( $slotName ) : void`
inherited

Returns a name

Inherited from: \Task::getRegisterSlot()
Parameters

Name | Type | Description
--- | --- | ---
$slotName |  |

`getRuntimeConfigurableWrapper( ) : \RuntimeConfigurable`
inherited

Returns the wrapper object for runtime configuration

Inherited from: \Task::getRuntimeConfigurableWrapper()
Returns

Type | Description
--- | ---
\RuntimeConfigurable | The wrapper object used by this task

`getTaskName( ) : string`
inherited

Returns the name of task, used only for log messages

Inherited from: \Task::getTaskName()
Returns

Type | Description
--- | ---
string | Name of this task

`getTaskType( ) : string`
inherited

Returns the name of the task under which it was invoked, usually the XML tagname

Inherited from: \Task::getTaskType()
Returns

Type | Description
--- | ---
string | The type of this task (XML Tag)

`getUserProperty( ) : void`
inherited

Inherited from: \PropertyTask::getUserProperty()
`getValue( ) : void`
inherited

Get the value of current property component.

Inherited from: \PropertyTask::getValue()
`init( ) : void`
inherited

Called by the parser to let the task initialize properly.

Inherited from: \Task::init()

Should throw a BuildException if something goes wrong with the build

This is abstract here, but may not be overloaded by subclasses.

Throws

Exception | Description
--- | ---
\BuildException |

`loadEnvironment( string $prefix ) : void`
inherited

load the environment values

Inherited from: \PropertyTask::loadEnvironment()
Parameters

Name | Type | Description
--- | --- | ---
$prefix | string | prefix to place before them

`loadFile( \PhingFile $file ) : void`

load properties from an XML file.

Parameters

Name | Type | Description
--- | --- | ---
$file | \PhingFile |

`log( string $msg, integer $level = Project::MSG_INFO ) : void`
inherited

Provides a project level log event to the task.

Inherited from: \Task::log()

@param string $msg The message to be logged.

Parameters

Name | Type | Description
--- | --- | ---
$msg | string | The message to log
$level | integer | The priority of the message

Details

See
  \BuildEvent
See
  \BuildListener

`main( ) : void`

set the property in the project to the value.

if the task was give a file or env attribute here is where it is loaded

`maybeConfigure( ) : void`
inherited

Configure this task if it hasn't been done already.

Inherited from: \Task::maybeConfigure()
`parsePropertyString( string $value, array $fragments, array $propertyRefs ) : void`
inherited

This method will parse a string containing ${value} style property values into two lists. The first list is a collection of text fragments, while the other is a set of string property names null entries in the first list indicate a property reference from the second list.

Inherited from: \PropertyTask::parsePropertyString()

This is slower than regex, but useful for this class, which has to handle multiple parsing passes for properties.

Parameters

Name | Type | Description
--- | --- | ---
$value | string | The string to be scanned for property references
$fragments | array | &$fragments The found fragments
$propertyRefs | array | &$propertyRefs The found refs

`perform( ) : void`
inherited

Perfrom this task

Inherited from: \Task::perform()
`resolveAllProperties( \Properties $props ) : void`
inherited

Given a Properties object, this method goes through and resolves any references to properties within the object.

Inherited from: \PropertyTask::resolveAllProperties()
Parameters

Name | Type | Description
--- | --- | ---
$props | \Properties | The collection of Properties that need to be resolved.

`setCollapseAttributes( bool $yesNo ) : void`

Treat attributes as nested elements.

Parameters

Name | Type | Description
--- | --- | ---
$yesNo | bool |

`setDelimiter( string $d ) : void`

Delimiter for splitting multiple values.

Parameters

Name | Type | Description
--- | --- | ---
$d | string |

`setDescription( string $desc ) : void`
inherited

Sets a textual description of the task

Inherited from: \Task::setDescription()
Parameters

Name | Type | Description
--- | --- | ---
$desc | string | The text describing the task

`setEnvironment( \env $env ) : void`
inherited

the prefix to use when retrieving environment variables.

Inherited from: \PropertyTask::setEnvironment()

Thus if you specify environment="myenv" you will be able to access OS-specific environment variables via property names "myenv.PATH" or "myenv.TERM".

<

p> Note that if you supply a property name with a final "." it will not be doubled. ie environment="myenv." will still allow access of environment variables through "myenv.PATH" and "myenv.TERM". This functionality is currently only implemented on select platforms. Feel free to send patches to increase the number of platforms this functionality is supported on ;).
Note also that properties are case sensitive, even if the environment variables on your operating system are not, e.g. it will be ${env.Path} not ${env.PATH} on Windows 2000.

Parameters

Name | Type | Description
--- | --- | ---
$env | \env | prefix

`setFallback( \Project $p ) : void`
inherited

Inherited from: \PropertyTask::setFallback()
Parameters

Name | Type | Description
--- | --- | ---
$p | \Project |

`setFile( $file ) : void`

Set a file to use as the source for properties.

Parameters

Name | Type | Description
--- | --- | ---
$file |  |

`setKeepRoot( bool $yesNo ) : void`

Keep the xml root tag as the first value in the property name

Parameters

Name | Type | Description
--- | --- | ---
$yesNo | bool |

`setLocation( \Location $location ) : void`
inherited

Sets the location within the buildfile this task occurs. Called by the parser to set location information.

Inherited from: \Task::setLocation()
Parameters

Name | Type | Description
--- | --- | ---
$location | \Location | The location object describing the position of this task within the buildfile.

`setName( $name ) : void`
inherited

Sets a the name of current property component

Inherited from: \PropertyTask::setName()
Parameters

Name | Type | Description
--- | --- | ---
$name |  |

`setOverride( $v ) : void`
inherited

Inherited from: \PropertyTask::setOverride()
Parameters

Name | Type | Description
--- | --- | ---
$v |  |

`setOwningTarget( \Target $target ) : void`
inherited

Sets the owning target this task belongs to.

Inherited from: \Task::setOwningTarget()
Parameters

Name | Type | Description
--- | --- | ---
$target | \Target | Reference to owning target

`setPrefix( string $prefix ) : void`

Prefix to apply to properties loaded using `file`.

A "." is appended to the prefix if not specified.

Parameters

Name | Type | Description
--- | --- | ---
$prefix | string | prefix string

Details

Since
  2.0

`setProject( \Project $project ) : void`
inherited

References the project to the current component.

Inherited from: \ProjectComponent::setProject()
Parameters

Name | Type | Description
--- | --- | ---
$project | \Project | The reference to the current project

`setRefid( $ref ) : void`
inherited

Inherited from: \PropertyTask::setRefid()
Parameters

Name | Type | Description
--- | --- | ---
$ref |  |

`setRuntimeConfigurableWrapper( \RuntimeConfigurable $wrapper ) : void`
inherited

Sets the wrapper object this task should use for runtime configurable elements.

Inherited from: \Task::setRuntimeConfigurableWrapper()
Parameters

Name | Type | Description
--- | --- | ---
$wrapper | \RuntimeConfigurable | The wrapper object this task should use

`setTaskName( $name ) : string`
inherited

Sets the name of this task for log messages

Inherited from: \Task::setTaskName()
Parameters

Name | Type | Description
--- | --- | ---
$name |  |

Returns

Type | Description
--- | ---
string | A string representing the name of this task for log

`setTaskType( string $name ) : void`
inherited

Sets the type of the task. Usually this is the name of the XML tag

Inherited from: \Task::setTaskType()
Parameters

Name | Type | Description
--- | --- | ---
$name | string | The type of this task (XML Tag)

`setUserProperty( boolean $v ) : void`
inherited

Set whether this is a user property (ro).

Inherited from: \PropertyTask::setUserProperty()

This is deprecated in Ant 1.5, but the userProperty attribute of the class is still being set via constructor, so Phing will allow this method to function.

Parameters

Name | Type | Description
--- | --- | ---
$v | boolean |

`setValue( mixed $value ) : void`
inherited

Sets a the value of current property component.

Inherited from: \PropertyTask::setValue()
Parameters

Name | Type | Description
--- | --- | ---
$value | mixed | Value of name, all scalars allowed

`toString( ) : void`
inherited

Inherited from: \PropertyTask::toString()
Documentation was generated by DocBlox 0.15.1.