public class PropertyHelper extends Object implements GetProperty
This code has been heavily restructured for Ant 1.8.0.  It is
 expected that custom PropertyHelper implementation that used the
 older chaining mechanism of Ant 1.6 won't work in all cases, and
 its usage is deprecated.  The preferred way to customize Ant's
 property handling is by adding delegates of the appropriate subinterface
 and have this implementation use them.
When expanding a string that may contain
 properties this class will delegate the actual parsing to parseProperties inside the ParseProperties class which in turn
 uses the PropertyExpander delegates to find properties inside the string
 and this class to expand the propertiy names found into the
 corresponding values.
When looking up a property value this class
 will first consult all PropertyEvaluator delegates and fall back to an internal map of
 "project properties" if no evaluator matched the property name.
When setting a property value this class
 will first consult all PropertySetter delegates and fall back to an internal map of
 "project properties" if no setter matched the property name.
| Modifier and Type | Class and Description | 
|---|---|
| static interface  | PropertyHelper.DelegateMarker interface for a PropertyHelper delegate. | 
| static interface  | PropertyHelper.PropertyEvaluatorLooks up a property's value based on its name. | 
| static interface  | PropertyHelper.PropertySetterSets or overrides a property. | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | PropertyHelper()Default constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | add(PropertyHelper.Delegate delegate)Add the specified delegate object to this PropertyHelper. | 
| boolean | containsProperties(String value)Learn whether a String contains replaceable properties. | 
| void | copyInheritedProperties(Project other)Copies all user properties that have not been set on the
 command line or a GUI tool from this instance to the Project
 instance given as the argument. | 
| void | copyUserProperties(Project other)Copies all user properties that have been set on the command
 line or a GUI tool from this instance to the Project instance
 given as the argument. | 
| protected static Set<Class<? extends PropertyHelper.Delegate>> | getDelegateInterfaces(PropertyHelper.Delegate d)Get all Delegate interfaces (excluding Delegate itself) from the specified Delegate. | 
| protected <D extends PropertyHelper.Delegate> | getDelegates(Class<D> type)Get the Collection of delegates of the specified type. | 
| Collection<PropertyExpander> | getExpanders()Get the  expanders. | 
| Hashtable<String,Object> | getInheritedProperties()Returns a copy of the inherited property hashtable | 
| protected Hashtable<String,Object> | getInternalInheritedProperties()special back door for subclasses, internal access to the hashtables | 
| protected Hashtable<String,Object> | getInternalProperties()special back door for subclasses, internal access to the hashtables | 
| protected Hashtable<String,Object> | getInternalUserProperties()special back door for subclasses, internal access to the hashtables | 
| Project | getProject()Get this PropertyHelper's Project. | 
| Hashtable<String,Object> | getProperties()Returns a copy of the properties table. | 
| static Object | getProperty(Project project,
           String name)A helper static method to get a property
 from a particular project. | 
| Object | getProperty(String name)Returns the value of a property, if it is set. | 
| static PropertyHelper | getPropertyHelper(Project project)Factory method to create a property processor. | 
| Hashtable<String,Object> | getUserProperties()Returns a copy of the user property hashtable | 
| Object | getUserProperty(String name)Returns the value of a user property, if it is set. | 
| Object | parseProperties(String value)Decode properties from a String representation. | 
| String | replaceProperties(String value)Replaces  ${xxx}style constructions in the given value
 with the string value of the corresponding data types. | 
| String | replaceProperties(String ns,
                 String value,
                 Hashtable<String,Object> keys)Replaces  ${xxx}style constructions in the given value
 with the string value of the corresponding data types. | 
| void | setInheritedProperty(String name,
                    Object value)Sets an inherited user property, which cannot be overwritten by set/unset
 property calls. | 
| static void | setNewProperty(Project project,
              String name,
              Object value)A helper static method to set a new property
 from a particular project. | 
| void | setNewProperty(String name,
              Object value)Sets a property if no value currently exists. | 
| void | setProject(Project p)Set the project for which this helper is performing property resolution. | 
| static void | setProperty(Project project,
           String name,
           Object value)A helper static method to set a property
 from a particular project. | 
| boolean | setProperty(String name,
           Object value,
           boolean verbose)Default implementation of setProperty. | 
| void | setUserProperty(String name,
               Object value)Sets a user property, which cannot be overwritten by
 set/unset property calls. | 
| boolean | testIfCondition(Object value)Returns true if the value is null or an empty string, can be
 interpreted as a true value or cannot be interpreted as a false
 value and a property of the value's name exists. | 
| boolean | testUnlessCondition(Object value)Returns true if the value is null or an empty string, can be
 interpreted as a false value or cannot be interpreted as a true
 value and a property of the value's name doesn't exist. | 
| static Boolean | toBoolean(Object value)If the given object can be interpreted as a true/false value,
 turn it into a matching Boolean - otherwise return null. | 
public void add(PropertyHelper.Delegate delegate)
delegate - the delegate to add.public boolean containsProperties(String value)
value - the String to check.true if value contains property notation.public void copyInheritedProperties(Project other)
To copy all "user" properties, you will also have to call
 copyUserProperties.
Does not copy properties held by implementations of delegates (like local properties).
other - the project to copy the properties to.  Must not be null.public void copyUserProperties(Project other)
To copy all "user" properties, you will also have to call
 copyInheritedProperties.
Does not copy properties held by implementations of delegates (like local properties).
other - the project to copy the properties to.  Must not be null.protected static Set<Class<? extends PropertyHelper.Delegate>> getDelegateInterfaces(PropertyHelper.Delegate d)
d - the Delegate to inspect.protected <D extends PropertyHelper.Delegate> List<D> getDelegates(Class<D> type)
type - delegate type.public Collection<PropertyExpander> getExpanders()
expanders.public Hashtable<String,Object> getInheritedProperties()
Does not contain properties held by implementations of delegates (like local properties).
protected Hashtable<String,Object> getInternalInheritedProperties()
protected Hashtable<String,Object> getInternalProperties()
protected Hashtable<String,Object> getInternalUserProperties()
public Project getProject()
public Hashtable<String,Object> getProperties()
Does not contain properties held by implementations of delegates (like local properties).
public static Object getProperty(Project project, String name)
project - the project in question.name - the property namepublic Object getProperty(String name)
This is the method that is invoked by {Project#getProperty Project.getProperty}.
You can override this method in order to plug your own
 storage but the recommended approach is to add your own
 implementation of PropertyEvaluator
 instead.
getProperty in interface GetPropertyname - The name of the property.
             May be null, in which case
             the return value is also null.null for no match
         or if a null name is provided.public static PropertyHelper getPropertyHelper(Project project)
project - the project for which the property helper is required.public Hashtable<String,Object> getUserProperties()
Does not contain properties held by implementations of delegates (like local properties).
public Object getUserProperty(String name)
Does not consult any delegates.
name - The name of the property.
             May be null, in which case
             the return value is also null.null for no match
         or if a null name is provided.public Object parseProperties(String value) throws BuildException
value - The string to be scanned for property references.
              May be null, in which case this
              method returns immediately with no effect.null if the original string is null.BuildException - if the string contains an opening
                           ${ without a closing
                           }public String replaceProperties(String value) throws BuildException
${xxx} style constructions in the given value
 with the string value of the corresponding data types.value - The string to be scanned for property references.
              May be null, in which case this
              method returns immediately with no effect.null if the original string is null.BuildException - if the string contains an opening
                           ${ without a closing
                           }public String replaceProperties(String ns, String value, Hashtable<String,Object> keys) throws BuildException
${xxx} style constructions in the given value
 with the string value of the corresponding data types.
 Delegates to the one-arg version, completely ignoring the ns and keys parameters.
ns - The namespace for the property.value - The string to be scanned for property references.
              May be null, in which case this
              method returns immediately with no effect.keys - Mapping (String to Object) of property names to their
              values. If null, only project properties will
              be used.null if the original string is null.BuildException - if the string contains an opening
                           ${ without a closing
                           }public void setInheritedProperty(String name, Object value)
Does not consult any delegates.
name - The name of property to set.
             Must not be null.value - The new value of the property.
              Must not be null.public static void setNewProperty(Project project, String name, Object value)
project - the project in question.name - the property namevalue - the value to use.public void setNewProperty(String name, Object value)
name - The name of property to set.
             Must not be null.value - The new value of the property.
              Must not be null.public void setProject(Project p)
p - the project instance.public static void setProperty(Project project, String name, Object value)
project - the project in question.name - the property namevalue - the value to use.public boolean setProperty(String name, Object value, boolean verbose)
name - The name of the property.value - The value to set the property to.verbose - If this is true output extra log messages.public void setUserProperty(String name, Object value)
Does not consult any delegates.
name - The name of property to set.
             Must not be null.value - The new value of the property.
              Must not be null.public boolean testIfCondition(Object value)
public boolean testUnlessCondition(Object value)