String-list Task Reference

From ControlTier

Revision as of 17:30, 11 November 2010 by Ahonor (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Contents

Description

The string-list ant task takes a delimited string, and provides various list actions.

General syntax

	<string-list list="e1,e2,e3" delimiter="," resultproperty="result">
 	  <add>e4</add>
	</string-list>

Parameters

AttributeDescriptionRequired
listValue containing listYes
resultpropertyProperty name to store result. No. defaults to "result"
delimiterString delimiting elements in the list valueNo. defaults to "," (comma)

Parameters specified as nested elements

The string-list task takes one action element.

actiondescriptioninput data
containsChecks if list contains value. If the value is found resultproperty is set true, otherwise the property is not set. value to find
getRetrieves element from list. Takes an index number or optionally a regex pattern if regex=true. an integer or a regex pattern if regex attribute is set true
addAdds element to listvalue to add
removeRemoves element from listvalue to remove
reverseReverses elements in list.none
sizeCounts elements in listnone

Examples

The examples below show off a variety of string-list actions.

 <!-- count the elements -->
  <string-list list="one,two,three"
	       delimiter=","
	       resultproperty="list.size">
    <size/>
  </string-list>
 
  <!-- check if the list contains the value, one -->
  <string-list list="one,two,three" resultproperty="contains.one">
    <contains>one</contains>
  </string-list>
 
  <!-- get the first element -->
  <string-list list="one,two,three" resultproperty="list.zeroth">
    <get>0</get>
  </string-list>
 
  <!-- retreive the element by a regex pattern -->
  <string-list list="one,two,three" resultproperty="list.get.regex">
    <get regex="true">on.</get>
  </string-list>
 
  <!-- add an element -->
  <string-list list="one,two,three" resultproperty="list.added">
    <add>four</add>
  </string-list>
 
  <!-- remove an element -->
  <string-list list="one,two,three" resultproperty="list.removed">
    <remove>three</remove>
  </string-list>
 
 
  <echo>
    number elements: ${list.size}
    contains one?: ${contains.one}
    first num: ${list.zeroth}
    get pattern.: ${list.get.regex}
    reversed: ${list.reversed}
    add an element: ${list.added}
    remove an element: ${list.removed}
  </echo>

results would look like:

	  number elements: 3
	  contains one?: true
          first num: one
	  get pattern: one
	  reversed: two,three,one
	  add an element: one,two,three,four
	  remove an element: one,two
      
Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export