ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joseph Dane <...@hotu.com>
Subject [PATCH] Filterset should fail if it can't find token
Date Tue, 22 Jan 2002 23:28:31 GMT
Index: FilterSet.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/types/FilterSet.java,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 FilterSet.java
--- FilterSet.java	13 Sep 2001 13:43:04 -0000	1.2.2.2
+++ FilterSet.java	22 Jan 2002 23:20:33 -0000
@@ -178,7 +178,14 @@
     
     private String startOfToken = DEFAULT_TOKEN_START;
     private String endOfToken = DEFAULT_TOKEN_END;
-    
+
+
+    /**
+     * if <code>true</code>, and a translation for a token can't be
+     * found, signal an error.
+     */
+    private boolean abortIfMissing = false;
+
     /**
      * List of ordered filters and filter files.
      */
@@ -274,7 +281,14 @@
         }
         return endOfToken;
     }
-    
+
+    public void setAbortMissing( boolean abort ) {
+        this.abortIfMissing = abort;
+    }
+
+    public boolean getAbortMissing() {
+        return abortIfMissing;
+    }
     
     /**
      * Read the filters from the given file.
@@ -356,9 +370,15 @@
                         i = index + beginToken.length() + token.length() + endToken.length();
                     }
                     else {
-                        // just append beginToken and search further
-                        b.append(beginToken);
-                        i = index + beginToken.length();
+                        if (abortIfMissing) {
+                            throw new BuildException
+                                ("no replacement value for token " + token);
+                        }
+                        else {
+                            // just append beginToken and search further
+                            b.append(beginToken);
+                            i = index + beginToken.length();
+                        }
                     }
                 } while ((index = line.indexOf( beginToken, i )) > -1 );
                 




-- 

joe


Mime
View raw message