You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/11/19 09:38:52 UTC

svn commit: r718904 - /ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java

Author: bodewig
Date: Wed Nov 19 00:38:51 2008
New Revision: 718904

URL: http://svn.apache.org/viewvc?rev=718904&view=rev
Log:
appending may be a bad thing to do for compressed outputs and other subclasses

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java?rev=718904&r1=718903&r2=718904&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java Wed Nov 19 00:38:51 2008
@@ -115,19 +115,21 @@
      */
     public Object as(Class clazz) {
         if (Appendable.class.isAssignableFrom(clazz)) {
-            final Appendable a =
-                (Appendable) getResource().as(Appendable.class);
-            if (a != null) {
-                return new Appendable() {
-                    public OutputStream getAppendOutputStream()
-                        throws IOException {
-                        OutputStream out = a.getAppendOutputStream();
-                        if (out != null) {
-                            out = wrapStream(out);
+            if (isAppendSupported()) {
+                final Appendable a =
+                    (Appendable) getResource().as(Appendable.class);
+                if (a != null) {
+                    return new Appendable() {
+                        public OutputStream getAppendOutputStream()
+                            throws IOException {
+                            OutputStream out = a.getAppendOutputStream();
+                            if (out != null) {
+                                out = wrapStream(out);
+                            }
+                            return out;
                         }
-                        return out;
-                    }
-                };
+                    };
+                }
             }
             return null;
         }
@@ -137,6 +139,18 @@
     }
 
     /**
+     * whether the transformation performed allows appends.
+     *
+     * <p>In general compressed outputs will become invalid if they
+     * are appended to, for example.</p>
+     *
+     * <p>This implementations returns false.</p>
+     */
+    protected boolean isAppendSupported() {
+        return false;
+    }    
+
+    /**
      * Is supposed to wrap the stream.
      *
      * @param in InputStream to wrap, will never be null.