1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00

JSONzip value

This commit is contained in:
Douglas Crockford 2014-04-28 13:22:05 -07:00
parent b7a1aee4e1
commit 48d31b7f5c
3 changed files with 22 additions and 12 deletions

View file

@ -38,7 +38,7 @@ import org.json.Kim;
* JSONzip is a compression scheme for JSON text.
*
* @author JSON.org
* @version 2014-04-21
* @version 2014-04-28
*/
/**
@ -75,7 +75,7 @@ public class Compressor extends JSONzip {
* 'e' is 13.
*
* @param digit
* An ASCII character from a JSIN number.
* An ASCII character from a JSON number.
* @return
*/
private static int bcd(char digit) {
@ -514,11 +514,11 @@ public class Compressor extends JSONzip {
one();
if (longer < int7) {
zero();
write((int) longer, 7);
write((int)(longer - int4), 7);
return;
}
one();
write((int) longer, 14);
write((int)(longer - int7), 14);
return;
}
}

View file

@ -35,7 +35,7 @@ import org.json.Kim;
* JSONzip is a compression scheme for JSON text.
*
* @author JSON.org
* @version 2014-04-21
* @version 2014-04-28
*/
public class Decompressor extends JSONzip {
@ -288,7 +288,17 @@ public class Decompressor extends JSONzip {
private Object readValue() throws JSONException {
switch (read(2)) {
case 0:
return new Integer(read(!bit() ? 4 : !bit() ? 7 : 14));
int nr_bits = !bit() ? 4 : !bit() ? 7 : 14;
int integer = read(nr_bits);
switch (nr_bits) {
case 7:
integer += int4;
break;
case 14:
integer += int7;
break;
}
return new Integer(integer);
case 1:
byte[] bytes = new byte[256];
int length = 0;

View file

@ -44,7 +44,7 @@ package org.json.zip;
* ADEQUATELY FOR PRODUCTION USE.
*
* @author JSON.org
* @version 2014-04-21
* @version 2014-04-28
*/
public abstract class JSONzip implements None, PostMortem {
/**
@ -63,19 +63,19 @@ public abstract class JSONzip implements None, PostMortem {
};
/**
* The number of integers that can be encoded in 4 bits.
* The first positive integer than cannot be encoded in 4 bits.
*/
public static final long int4 = 16;
/**
* The number of integers that can be encoded in 7 bits.
* The first positive integer than cannot be encoded in 7 bits.
*/
public static final long int7 = 128;
public static final long int7 = 144;
/**
* The number of integers that can be encoded in 14 bits.
* The first positive integer than cannot be encoded in 14 bits.
*/
public static final long int14 = 16384;
public static final long int14 = 16528;
/**
* The end of string code.