ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r567752 - /ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
Date Mon, 20 Aug 2007 17:00:06 GMT
Author: peterreilly
Date: Mon Aug 20 10:00:06 2007
New Revision: 567752

URL: http://svn.apache.org/viewvc?rev=567752&view=rev
Log:
add in property delegate to set properties

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java?rev=567752&r1=567751&r2=567752&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/PropertyHelper.java Mon Aug 20 10:00:06 2007
@@ -52,7 +52,7 @@
 /** 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.
  *
@@ -60,6 +60,12 @@
  */
 public class PropertyHelper implements Cloneable {
 
+    //  --------------------------------------------------------
+    //
+    //    The property delegate interfaces
+    //
+    //  --------------------------------------------------------
+
     /**
      * Marker interface for a PropertyHelper delegate.
      * @since Ant 1.8
@@ -93,9 +99,43 @@
          * @param propertyHelper the invoking PropertyHelper.
          * @return parsed String if any, else <code>null</code>.
          */
-        String parsePropertyName(String s, ParsePosition pos, PropertyHelper propertyHelper);
+        String parsePropertyName(
+            String s, ParsePosition pos, PropertyHelper propertyHelper);
     }
 
+    /**
+     * Describes an entity capable of setting a property to a value.
+     * @since Ant 1.8
+     */
+    public interface PropertySetter extends Delegate {
+        /**
+         * Set a *new" property.
+         * @param property the property's String "identifier".
+         * @param value    the value to set.
+         * @param propertyHelper the invoking PropertyHelper.
+         * @return true if this entity 'owns' the property.
+         */
+        boolean setNew(
+            String property, Object value, PropertyHelper propertyHelper);
+
+        /**
+         * Set a property.
+         * @param property the property's String "identifier".
+         * @param value    the value to set.
+         * @param propertyHelper the invoking PropertyHelper.
+         * @return true if this entity 'owns' the property.
+         */
+        boolean set(
+            String property, Object value, PropertyHelper propertyHelper);
+    }
+
+
+    //  --------------------------------------------------------
+    //
+    //    The predefined property delegates
+    //
+    //  --------------------------------------------------------
+
     private static final PropertyEvaluator TO_STRING = new PropertyEvaluator() {
         private String prefix = "toString:";
         public Object evaluate(String property, PropertyHelper propertyHelper) {
@@ -549,6 +589,13 @@
      *  @return true if the property is set.
      */
     public synchronized boolean setProperty(String name, Object value, boolean verbose) {
+        for (Iterator iter = getDelegates(PropertySetter.class).iterator();
+             iter.hasNext();) {
+            PropertySetter setter = (PropertySetter) iter.next();
+            if (setter.set(name, value, this)) {
+                return true;
+            }
+        }
         // user (CLI) properties take precedence
         if (null != userProperties.get(name)) {
             if (verbose) {
@@ -607,6 +654,13 @@
      * @since Ant 1.8
      */
     public synchronized void setNewProperty(String name, Object value) {
+        for (Iterator iter = getDelegates(PropertySetter.class).iterator();
+             iter.hasNext();) {
+            PropertySetter setter = (PropertySetter) iter.next();
+            if (setter.setNew(name, value, this)) {
+                return;
+            }
+        }
         if (null != properties.get(name)) {
             project.log("Override ignored for property \"" + name + "\"", Project.MSG_VERBOSE);
             return;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message