bndlib fixes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1363873 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/lib/json/Encoder.java b/bundleplugin/src/main/java/aQute/lib/json/Encoder.java
index b6112e7..0808de3 100644
--- a/bundleplugin/src/main/java/aQute/lib/json/Encoder.java
+++ b/bundleplugin/src/main/java/aQute/lib/json/Encoder.java
@@ -4,6 +4,7 @@
import java.lang.reflect.*;
import java.security.*;
import java.util.*;
+import java.util.zip.*;
public class Encoder implements Appendable, Closeable, Flushable {
final JSONCodec codec;
@@ -11,7 +12,8 @@
MessageDigest digest;
boolean writeDefaults;
String encoding = "UTF-8";
-
+ boolean deflate;
+
Encoder(JSONCodec codec) {
this.codec = codec;
}
@@ -21,6 +23,7 @@
to();
codec.encode(this, object, null, new IdentityHashMap<Object,Type>());
+ flush();
return this;
}
@@ -53,6 +56,9 @@
}
public Encoder to(OutputStream out) throws IOException {
+ if ( deflate)
+ out = new DeflaterOutputStream(out);
+
return to(new OutputStreamWriter(out, encoding));
}
@@ -109,4 +115,10 @@
((Flushable) app).flush();
}
}
+ public Encoder deflate() {
+ if ( app != null)
+ throw new IllegalStateException("Writer already set, deflate must come before to(...)");
+ deflate = true;
+ return this;
+ }
}