From 8967c1546c538b72ca4c4fb2b715869356606ecc Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Mon, 20 Aug 2007 16:44:58 +0000 Subject: [PATCH] add some helper methods on PropertyHelper to access the get/get methods git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@567747 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/PropertyHelper.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/PropertyHelper.java b/src/main/org/apache/tools/ant/PropertyHelper.java index 5396ad08c..b631c69cc 100644 --- a/src/main/org/apache/tools/ant/PropertyHelper.java +++ b/src/main/org/apache/tools/ant/PropertyHelper.java @@ -52,7 +52,7 @@ import java.util.Enumeration; /** NOT FINAL. API MAY CHANGE * * Deals with properties - substitution, dynamic properties, etc. - * + *q * This is the same code as in Ant1.5. The main addition is the ability * to chain multiple PropertyHelpers and to replace the default. * @@ -173,6 +173,52 @@ public class PropertyHelper implements Cloneable { add(DEFAULT_EXPANDER); } + // -------------------------------------------------------- + // + // Some helper static methods to get and set properties + // + // -------------------------------------------------------- + + /** + * A helper static method to get a property + * from a particular project. + * @param project the project in question. + * @param name the property name + * @return the value of the property if present, null otherwise. + * @since Ant 1.8 + */ + public static Object getProperty(Project project, String name) { + return PropertyHelper.getPropertyHelper(project) + .getProperty(name); + } + + /** + * A helper static method to set a property + * from a particular project. + * @param project the project in question. + * @param name the property name + * @param value the value to use. + * @since Ant 1.8 + */ + public static void setProperty(Project project, String name, Object value) { + PropertyHelper.getPropertyHelper(project) + .setProperty(name, value, true); + } + + /** + * A helper static method to set a new property + * from a particular project. + * @param project the project in question. + * @param name the property name + * @param value the value to use. + * @since Ant 1.8 + */ + public static void setNewProperty( + Project project, String name, Object value) { + PropertyHelper.getPropertyHelper(project) + .setNewProperty(name, value); + } + //override facility for subclasses to put custom hashtables in // -------------------- Hook management --------------------