Package com.glitchybyte.zappy
Class Zappy
java.lang.Object
com.glitchybyte.zappy.Zappy
Encoding and decoding compressed web text for transport.
It uses base64 as the message encoding, but the internal bytes are compressed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbase64StringDecode
(String str) Decodes a base64 string.base64StringEncode
(String str) Encodes a string into a base64 string.Turns a Zappy compressed string into a string.Turns a string into a Zappy compressed string.
-
Constructor Details
-
Zappy
Creates a Zappy object ready to encode and decode messages.- Parameters:
source
- The contraction source used for aiding compression. These will be overlaid on the default contractions that favors json. Whole tables are replaced in the overlay process, not individual items within a table. If source is null (and it has to be explicit by design), then only the default contractions are used. It is highly recommended users of this class add their own contractions.
-
-
Method Details
-
base64StringEncode
Encodes a string into a base64 string.Encodes with "-" and "_", and no padding.
- Parameters:
str
- Original string to encode.- Returns:
- A base64 string.
-
base64StringDecode
Decodes a base64 string.Expects encoding with "-" and "_", and no padding.
- Parameters:
str
- Base64 string.- Returns:
- The decoded string.
- Throws:
ZappyParseException
- if it's an invalid base64 string.
-
encode
Turns a string into a Zappy compressed string.- Parameters:
str
- A string.- Returns:
- A Zappy compressed string.
-
decode
Turns a Zappy compressed string into a string.- Parameters:
str
- A Zappy compressed string.- Returns:
- Expanded string.
- Throws:
ZappyParseException
- if it's an invalid Zappy string.
-