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/Decoder.java b/bundleplugin/src/main/java/aQute/lib/json/Decoder.java
index 09b6a7f..87cd1bc 100644
--- a/bundleplugin/src/main/java/aQute/lib/json/Decoder.java
+++ b/bundleplugin/src/main/java/aQute/lib/json/Decoder.java
@@ -4,6 +4,7 @@
import java.lang.reflect.*;
import java.security.*;
import java.util.*;
+import java.util.zip.*;
import aQute.lib.converter.*;
@@ -16,6 +17,7 @@
String encoding = "UTF-8";
boolean strict;
+ boolean inflate;
Decoder(JSONCodec codec) {
this.codec = codec;
@@ -26,6 +28,10 @@
}
public Decoder from(InputStream in) throws Exception {
+
+ if ( inflate)
+ in = new InflaterInputStream(in);
+
return from(new InputStreamReader(in, encoding));
}
@@ -140,4 +146,11 @@
extra = new HashMap<String,Object>();
return extra;
}
+
+ public Decoder inflate() {
+ if ( reader != null)
+ throw new IllegalStateException("Reader already set, inflate must come before from()");
+ inflate = true;
+ return this;
+ }
}
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;
+ }
}