public class TypeEncoder
extends java.lang.Object
TypeEncoder
gives the ability to encode a polyglot
Type
as a Java string.
It uses a form of serialization to encode the Type
into
a byte stream and then converts the byte stream to a standard Java string.
The difference between the encoder and a normal serialization process is
that in order to encode this type, we need to sever any links to other types
in the current environment. So any ClassType
other than the
the type being encoded is replaced in the stream with a
PlaceHolder
that contains the name of the class. To aid
in the decoding process, placeholders for member classes user their
"mangled" name; non-member classes use their fully qualified name.
Modifier and Type | Field and Description |
---|---|
protected boolean |
base64 |
protected int |
depth |
protected java.util.Map<java.lang.Object,java.lang.Object> |
placeHolderCache |
protected boolean |
test |
protected TypeSystem |
ts |
protected boolean |
zip |
Constructor and Description |
---|
TypeEncoder(TypeSystem ts) |
Modifier and Type | Method and Description |
---|---|
TypeObject |
decode(java.lang.String s,
java.lang.String name)
Decode a serialized type object.
|
java.lang.String |
encode(TypeObject t)
Serialize a type object into a string.
|
TypeInputStream |
ois(java.io.ByteArrayInputStream bais) |
protected TypeSystem ts
protected final boolean zip
protected final boolean base64
protected final boolean test
protected java.util.Map<java.lang.Object,java.lang.Object> placeHolderCache
protected int depth
public TypeEncoder(TypeSystem ts)
public java.lang.String encode(TypeObject t) throws java.io.IOException
t
- The TypeObject to encode.java.io.IOException
- If the encoding fails.public TypeObject decode(java.lang.String s, java.lang.String name) throws java.io.InvalidClassException
s
- String containing the encoded type object.java.io.InvalidClassException
- If the string is malformed.public TypeInputStream ois(java.io.ByteArrayInputStream bais) throws java.io.IOException
java.io.IOException