Package totalcross.json.zip
Class JSONzip
- java.lang.Object
-
- totalcross.json.zip.JSONzip
-
- All Implemented Interfaces:
None,PostMortem
public abstract class JSONzip extends java.lang.Object implements None, PostMortem
JSONzip is a binary-encoded JSON dialect. It is designed to compress the messages in a session in bandwidth constrained applications, such as mobile. JSONzip is adaptive, so with each message seen, it should improve its compression. It minimizes JSON's overhead, reducing punctuation to a small number of bits. It uses Huffman encoding to reduce the average size of characters. It uses caches (or Keeps) to keep recently seen strings and values, so repetitive content (such as object keys) can be substantially reduced. It uses a character encoding called Kim (Keep it minimal) that is smaller than UTF-8 for most East European, African, and Asian scripts. JSONzip tends to reduce most content by about half. If there is a lot of recurring information, the reduction can be much more dramatic. FOR EVALUATION PURPOSES ONLY. THIS PACKAGE HAS NOT YET BEEN TESTED ADEQUATELY FOR PRODUCTION USE.
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]bcdThe characters in JSON numbers can be reduced to 4 bits each.static intendThe end of string code.static intendOfNumberThe end of number code.static longint14The first positive integer that cannot be encoded in 14 bits.static longint4The first positive integer that cannot be encoded in 4 bits.static longint7The first positive integer that cannot be encoded in 7 bits.protected HuffnamehuffA Huffman encoder for names.protected HuffnamehuffextA Huffman encoder for names extended bytes.protected totalcross.json.zip.KeepnamekeepA place to keep the names (keys).static booleanprobeThe package supports tracing for debugging.protected HuffstringhuffA Huffman encoder for string values.protected HuffstringhuffextA Huffman encoder for string values extended bytes.protected totalcross.json.zip.KeepstringkeepA place to keep the strings.protected totalcross.json.zip.KeepvaluekeepA place to keep the values.static intzipArrayStringThe value code for an array with a string as its first element.static intzipArrayValueThe value code for an array with a non-string value as its first element.static intzipEmptyArrayThe value code for an empty array.static intzipEmptyObjectThe value code for an empty object.static intzipFalseThe value code for false.static intzipNullThe value code for null.static intzipObjectThe value code for a non-empty object.static intzipTrueThe value code for true.
-
Constructor Summary
Constructors Modifier Constructor Description protectedJSONzip()Initialize the data structures.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidgenerate()Generate the Huffman tables.booleanpostMortem(PostMortem pm)This method is used for testing the implementation of JSONzip.
-
-
-
Field Detail
-
bcd
public static final byte[] bcd
The characters in JSON numbers can be reduced to 4 bits each.
-
end
public static final int end
The end of string code.- See Also:
- Constant Field Values
-
endOfNumber
public static final int endOfNumber
The end of number code.
-
int4
public static final long int4
The first positive integer that cannot be encoded in 4 bits.- See Also:
- Constant Field Values
-
int7
public static final long int7
The first positive integer that cannot be encoded in 7 bits.- See Also:
- Constant Field Values
-
int14
public static final long int14
The first positive integer that cannot be encoded in 14 bits.- See Also:
- Constant Field Values
-
probe
public static final boolean probe
The package supports tracing for debugging.- See Also:
- Constant Field Values
-
zipEmptyObject
public static final int zipEmptyObject
The value code for an empty object.- See Also:
- Constant Field Values
-
zipEmptyArray
public static final int zipEmptyArray
The value code for an empty array.- See Also:
- Constant Field Values
-
zipTrue
public static final int zipTrue
The value code for true.- See Also:
- Constant Field Values
-
zipFalse
public static final int zipFalse
The value code for false.- See Also:
- Constant Field Values
-
zipNull
public static final int zipNull
The value code for null.- See Also:
- Constant Field Values
-
zipObject
public static final int zipObject
The value code for a non-empty object.- See Also:
- Constant Field Values
-
zipArrayString
public static final int zipArrayString
The value code for an array with a string as its first element.- See Also:
- Constant Field Values
-
zipArrayValue
public static final int zipArrayValue
The value code for an array with a non-string value as its first element.- See Also:
- Constant Field Values
-
namehuff
protected final Huff namehuff
A Huffman encoder for names.
-
namehuffext
protected final Huff namehuffext
A Huffman encoder for names extended bytes.
-
namekeep
protected final totalcross.json.zip.Keep namekeep
A place to keep the names (keys).
-
stringhuff
protected final Huff stringhuff
A Huffman encoder for string values.
-
stringhuffext
protected final Huff stringhuffext
A Huffman encoder for string values extended bytes.
-
stringkeep
protected final totalcross.json.zip.Keep stringkeep
A place to keep the strings.
-
valuekeep
protected final totalcross.json.zip.Keep valuekeep
A place to keep the values.
-
-
Method Detail
-
generate
protected void generate()
Generate the Huffman tables.
-
postMortem
public boolean postMortem(PostMortem pm)
This method is used for testing the implementation of JSONzip. It is not suitable for any other purpose. It is used to compare a Compressor and a Decompressor, verifying that the data structures that were built during zipping and unzipping were the same.- Specified by:
postMortemin interfacePostMortem- Parameters:
pm- Another object of the same type.- Returns:
- true if the structures match.
-
-