8b522e9556054dea43572f6a5e4226f738e116b8
1 package be
.nikiroo
.utils
.serial
;
3 import java
.io
.NotSerializableException
;
4 import java
.util
.HashMap
;
7 import be
.nikiroo
.utils
.StringUtils
;
10 * A simple class to serialise objects to {@link String}.
12 * This class does not support inner classes (it does support nested classes,
17 public class Exporter
{
18 private Map
<Integer
, Object
> map
;
19 private StringBuilder builder
;
22 map
= new HashMap
<Integer
, Object
>();
23 builder
= new StringBuilder();
26 public Exporter
append(Object o
) throws NotSerializableException
{
27 SerialUtils
.append(builder
, o
, map
);
37 public String
toString(Boolean zip
) {
39 zip
= builder
.length() > 128;
43 return "ZIP:" + StringUtils
.zip64(builder
.toString());
46 return builder
.toString();
50 * The exported items in a serialised form.
52 * @return the items currently in this {@link Exporter}.
55 public String
toString() {
56 return toString(null);