public class Boss
extends java.lang.Object
Specification version: 1.4 (stream mode with no caching, regular cached mode)
BOSS is an acronym for Binary Object Streaming Specification.
The bit-effective, platform-independent streamable and traversable typed binary protocol. Allow to effectively store small or any sized integers, strings or binary data of any size, floats and doubles, arrays and hashes and time objects in a very effective way. It caches repeating objects and stores/restores links to objects.
The protocol allow to effectively store texts and binary data of absolutely any size, signed integers of absolutely any size, arrays and hashes with no limit on items and overall gross size. It is desirable to use build-in compression when appropriate.
Streamable means that you can use a pipe (for example tcp/ip), put the object at one side and load it on other, one-by-one, and caching and links will be restored properly.
Initially, this protocol was intended to be used in secure communications. Its gui.main.main goal was to very effective data sending and is a great replacement for json/boss/whatever. For example, typical JSON reduces in size twice with Boss.
Boss protocol also allow to transparently compress its representations.
Boss also supports "stream mode" that lacks tree reconstruction but could be effectively use when implementing long-living streams (e.g. stream protocols). In regular mode it causes unlimited cache grows as Boss would try to reconstruct all possible references to already serialized objects. In the stream mode only strings are cached, and cache size and capacity are dynamically limited. Boss writes stream mode marker and handles stream mode on receiving end automatically.
Supported types:
- Signed integers of any length - Signed floats and doubles (4 or 8 bytes) - Boolean values (true/false) - UTF-8 encoded texts, any length - Binary data, any length - Date objects (date and time with 1 second resolution) - Arrays with any number of mixed type elements - Hashes with any keys and values and unlimited length - Reference to the object that already was serialized (unless in stream mode)
| Modifier and Type | Class and Description |
|---|---|
static class |
Boss.Dictionary |
protected static class |
Boss.Header |
static class |
Boss.Reader |
static class |
Boss.Writer
BOSS serializer.
|
| Constructor and Description |
|---|
Boss() |
| Modifier and Type | Method and Description |
|---|---|
static Bytes |
dump(java.lang.Object first,
java.lang.Object... objects)
Encodes one or more objects one by one.
|
static byte[] |
dumpToArray(java.lang.Object first,
java.lang.Object... objects)
Encodes one or more objects one by one.
|
static boolean |
isUseOldDates() |
static <T> T |
load(byte[] data)
Load boss-encoded object tree from binary data.
|
static <T> T |
load(byte[] data,
BiDeserializer mapper) |
static <T> T |
load(Bytes bytes)
Load boss-encoded object tree from binary data.
|
static <K,V> java.util.Map<K,V> |
loadMap(Bytes bytes) |
static byte[] |
pack(java.lang.Object object) |
static void |
setUseOldDates(boolean useOldDates)
Set to true to use
Date class instead of ZonedDateTime (default) |
static void |
trace(byte[] packed) |
static void |
trace(java.lang.Object object) |
static Binder |
unpack(byte[] data)
Load boss-encoded object and cast ti to
Binder. |
public static boolean isUseOldDates()
Date class instead of ZonedDateTime (default behavior)public static void setUseOldDates(boolean useOldDates)
Date class instead of ZonedDateTime (default)public static Bytes dump(java.lang.Object first, java.lang.Object... objects)
objects - objects one by onepublic static byte[] pack(java.lang.Object object)
public static byte[] dumpToArray(java.lang.Object first,
java.lang.Object... objects)
objects - objects one by onepublic static <K,V> java.util.Map<K,V> loadMap(Bytes bytes)
public static <T> T load(Bytes bytes)
BiAdapter on how to serialize any types.bytes - data to loadpublic static <T> T load(byte[] data)
BiAdapter on how to serialize any types.data - binary data to decodepublic static <T> T load(byte[] data,
BiDeserializer mapper)
public static Binder unpack(byte[] data)
Binder.data - public static void trace(byte[] packed)
public static void trace(java.lang.Object object)