Browse Source

appending may be a bad thing to do for compressed outputs and other subclasses

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@718904 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
ade0b033e3
1 changed files with 26 additions and 12 deletions
  1. +26
    -12
      src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java

+ 26
- 12
src/main/org/apache/tools/ant/types/resources/ContentTransformingResource.java View File

@@ -115,19 +115,21 @@ public abstract class ContentTransformingResource extends ResourceDecorator {
*/ */
public Object as(Class clazz) { public Object as(Class clazz) {
if (Appendable.class.isAssignableFrom(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; return null;
} }
@@ -136,6 +138,18 @@ public abstract class ContentTransformingResource extends ResourceDecorator {
? null : getResource().as(clazz); ? null : getResource().as(clazz);
} }


/**
* 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. * Is supposed to wrap the stream.
* *


Loading…
Cancel
Save