public class Pickler
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
Pickler.Memo
A memoized object.
|
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.Map<java.lang.Class<?>,IObjectPickler> |
customPicklers
Registry of picklers for custom classes, to be able to not just pickle simple built in datatypes.
|
static int |
HIGHEST_PROTOCOL
The highest Python pickle protocol supported by this Pickler.
|
protected static int |
MAX_RECURSE_DEPTH
Limit on the recursion depth to avoid stack overflows.
|
protected java.util.HashMap<java.lang.Integer,Pickler.Memo> |
memo
The memoization cache.
|
protected java.io.OutputStream |
out
Output where the pickle data is written to.
|
protected int |
PROTOCOL
The Python pickle protocol version of the pickles created by this library.
|
protected int |
recurse
Current recursion level.
|
protected boolean |
useMemo
Use memoization or not.
|
protected boolean |
valueCompare
When memoizing, compare objects by value.
|
| Constructor and Description |
|---|
Pickler()
Create a Pickler.
|
Pickler(boolean useMemo)
Create a Pickler.
|
Pickler(boolean useMemo,
boolean valueCompare)
Create a Pickler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the pickler stream, discard any internal buffers.
|
void |
dump(java.lang.Object o,
java.io.OutputStream stream)
Pickle a given object graph, writing the result to the output stream.
|
byte[] |
dumps(java.lang.Object o)
Pickle a given object graph, returning the result as a byte array.
|
protected IObjectPickler |
getCustomPickler(java.lang.Class<?> t)
Get the custom pickler fot the given class, to be able to pickle not just built in collection types.
|
static void |
registerCustomPickler(java.lang.Class<?> clazz,
IObjectPickler pickler)
Register additional object picklers for custom classes.
|
void |
save(java.lang.Object o)
Pickle a single object and write its pickle representation to the output stream.
|
protected void |
writeMemo(java.lang.Object obj)
Write the object to the memo table and output a memo write opcode
Only works for hashable objects
|
public static int HIGHEST_PROTOCOL
protected static int MAX_RECURSE_DEPTH
protected int recurse
protected java.io.OutputStream out
protected int PROTOCOL
protected static java.util.Map<java.lang.Class<?>,IObjectPickler> customPicklers
registerCustomPickler(java.lang.Class<?>, net.razorvine.pickle.IObjectPickler)protected boolean useMemo
protected boolean valueCompare
protected java.util.HashMap<java.lang.Integer,Pickler.Memo> memo
public Pickler()
public Pickler(boolean useMemo)
public Pickler(boolean useMemo,
boolean valueCompare)
public void close()
throws java.io.IOException
java.io.IOExceptionpublic static void registerCustomPickler(java.lang.Class<?> clazz,
IObjectPickler pickler)
public byte[] dumps(java.lang.Object o)
throws PickleException,
java.io.IOException
PickleExceptionjava.io.IOExceptionpublic void dump(java.lang.Object o,
java.io.OutputStream stream)
throws java.io.IOException,
PickleException
java.io.IOExceptionPickleExceptionpublic void save(java.lang.Object o)
throws PickleException,
java.io.IOException
PickleExceptionjava.io.IOExceptionprotected void writeMemo(java.lang.Object obj)
throws java.io.IOException
java.io.IOExceptionprotected IObjectPickler getCustomPickler(java.lang.Class<?> t)
t - the class of the object to be pickledregisterCustomPickler(java.lang.Class<?>, net.razorvine.pickle.IObjectPickler))Copyright © 2019. All Rights Reserved.