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 property 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 |
|---|---|
| public static interface | PropertyHelper.Delegate
Marker interface for a PropertyHelper delegate. |
| public static interface | PropertyHelper.PropertyEnumerator
Obtains the names of all known properties. |
| public static interface | PropertyHelper.PropertyEvaluator
Looks up a property's value based on its name. |
| public static interface | PropertyHelper.PropertySetter
Sets or overrides a property. |
| Modifier and Type | Field and Description |
|---|---|
| private static final PropertyExpander | |
| private final Hashtable | |
| private static final PropertyHelper. | |
| private final Hashtable | inheritedProperties
Map of inherited "user" properties - that are those "user" properties that have been created by tasks and not been set from the command line or a GUI tool. |
| private PropertyHelper | |
| private Project | |
| private final Hashtable | properties
Project properties map (usually String to String). |
| private static final PropertyExpander | SKIP_DOUBLE_DOLLAR
dummy |
| private static final PropertyHelper. | |
| private final Hashtable | userProperties
Map of "user" properties (as created in the Ant task, for example). |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(PropertyHelper.
the delegate to add. delegateAdd the specified delegate object to this PropertyHelper. |
| public boolean | Returns: true if value contains property notation.the String to check. value)Learn whether a String contains replaceable properties. |
| public void | copyInheritedProperties(Project
the project to copy the properties to. Must not be null. 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. |
| public void | copyUserProperties(Project
the project to copy the properties to. Must not be null. 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. |
| private boolean | Returns: booleanObject value)Returns true if the value can be interpreted as a true value or cannot be interpreted as a false value and a property of the value's name exists. |
| protected static Set | Returns: Set<Class>the Delegate to inspect. dGet all Delegate interfaces (excluding Delegate itself) from the specified Delegate. |
| protected < desired type. D extends PropertyHelper. | Returns: Collection.delegate type. type)Get the Collection of delegates of the specified type. |
| public Collection | |
| public Hashtable | Returns: a hashtable containing just the inherited propertiesReturns a copy of the inherited property hashtable Does not contain properties held by implementations of delegates (like local properties). |
| protected Hashtable | Returns: the live hashtable inherited propertiesspecial back door for subclasses, internal access to the hashtables |
| protected Hashtable | Returns: the live hashtable of all propertiesspecial back door for subclasses, internal access to the hashtables |
| protected Hashtable | Returns: the live hashtable of user propertiesspecial back door for subclasses, internal access to the hashtables |
| public PropertyHelper | Returns: the next property helper.
Deprecated
use the delegate mechanism instead
Get the next property helper in the chain.
|
| public Project | |
| public Hashtable | Returns: a hashtable containing all properties (including user properties).Returns a copy of the properties table. |
| public static Object | Returns: the value of the property if present, null otherwise.the project in question. project, String the property name name)A helper static method to get a property from a particular project. |
| public Object | Returns: the property value, ornull for no match
or if a null name is provided.The namespace for the property (currently not used). ns, String The name of the property.
May be name)null, in which case
the return value is also null.
Deprecated
namespaces are unnecessary.
Returns the value of a property, if it is set.
|
| public Object | Returns: the property value, ornull for no match
or if a null name is provided.The name of the property.
May be name)null, in which case
the return value is also null.Implements org. |
| public static synchronized PropertyHelper | Returns: the project's property helper.the project for which the property helper is required. project)Factory method to create a property processor. |
| public Object | Returns: The property, if returned by a hook, or null if none.namespace of the sought property. ns, String name of the sought property. name, boolean True if this is a user property. user)
Deprecated
PropertyHelper chaining is deprecated.
Get a property.
|
| public Set | Returns: the names of all known properties.Returns the names of all known properties. |
| public Hashtable | Returns: a hashtable containing just the user propertiesReturns a copy of the user property hashtable Does not contain properties held by implementations of delegates (like local properties). |
| public Object | Returns: the property value, ornull for no match
or if a null name is provided.The namespace for the property (currently not used). ns, String The name of the property.
May be name)null, in which case
the return value is also null.
Deprecated
namespaces are unnecessary.
Returns the value of a user property, if it is set.
|
| public Object | Returns: the property value, ornull for no match
or if a null name is provided.The name of the property.
May be name)null, in which case
the return value is also null.Returns the value of a user property, if it is set. |
| private static boolean | Returns: booleanObject value)Returns true if the object is null or an empty string. |
| public Object | Returns: the original string with the properties replaced, ornull if the original string is null.The string to be scanned for property references.
May be value)null, in which case this
method returns immediately with no effect.Decode properties from a String representation. |
| public void | parsePropertyString(String
Text to parse. Must not be value, Vector<String> null.List to add text fragments to.
Must not be fragments, Vector<String> null.List to add property names to.
Must not be propertyRefs)null.
Deprecated
use the other mechanisms of this class instead
Parses a string containing ${xxx} style property
references into two lists.
|
| pack-priv static void | |
| public String | Returns: the original string with the properties replaced, ornull if the original string is null.The namespace for the property. ns, String The string to be scanned for property references.
May be value, Hashtable<String, Object> null, in which case this
method returns immediately with no effect.Mapping (String to Object) of property names to their
values. If keys)null, only project properties will
be used.Replaces |
| public String | Returns: the original string with the properties replaced, ornull if the original string is null.The string to be scanned for property references.
May be value)null, in which case this
method returns immediately with no effect.Replaces |
| public void | setInheritedProperty(String
The namespace for the property (currently not used). ns, String The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value)null.
Deprecated
namespaces are unnecessary.
Sets an inherited user property, which cannot be overwritten by set/unset
property calls.
|
| public void | setInheritedProperty(String
The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value)null.Sets an inherited user property, which cannot be overwritten by set/unset property calls. |
| public static void | setNewProperty(Project
the project in question. project, String the property name name, Object the value to use. value)A helper static method to set a new property from a particular project. |
| public void | setNewProperty(String
The namespace for the property (currently not used). ns, String The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value)null.
Deprecated
namespaces are unnecessary.
Sets a property if no value currently exists.
|
| public void | setNewProperty(String
The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value)null.Sets a property if no value currently exists. |
| public void | setNext(PropertyHelper
the next property helper in the chain. next)
Deprecated
use the delegate mechanism instead
Prior to Ant 1.8.0 there have been 2 ways to hook into property handling:
- you can replace the main PropertyHelper.
|
| public void | setProject(Project
the project instance. p)Set the project for which this helper is performing property resolution. |
| public static void | setProperty(Project
the project in question. project, String the property name name, Object the value to use. value)A helper static method to set a property from a particular project. |
| public boolean | Returns: true if the property is set.The namespace for the property (currently not used). ns, String The name of the property. name, Object The value to set the property to. value, boolean If this is true output extra log messages. verbose)
Deprecated
namespaces are unnecessary.
Default implementation of setProperty.
|
| public boolean | Returns: true if the property is set.The name of the property. name, Object The value to set the property to. value, boolean If this is true output extra log messages. verbose)Default implementation of setProperty. |
| public boolean | Returns: true if this helper has stored the property, false if it couldn't. Each helper should delegate to the next one (unless it has a good reason not to).The namespace that the property is in (currently
not used. ns, String The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value, boolean null.True if this property is inherited (an [sub]ant[call] property). inherited, boolean True if this property is a user property. user, boolean True is this is a new property. isNew)
Deprecated
PropertyHelper chaining is deprecated.
Sets a property.
|
| public void | setUserProperty(String
The namespace for the property (currently not used). ns, String The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value)null.
Deprecated
namespaces are unnecessary.
Sets a user property, which cannot be overwritten by
set/unset property calls.
|
| public void | setUserProperty(String
The name of property to set.
Must not be name, Object null.The new value of the property.
Must not be value)null.Sets a user property, which cannot be overwritten by set/unset property calls. |
| public boolean | Returns: booleanObject 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. |
| public boolean | Returns: booleanObject 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. |
| public static Boolean |