polyglot.util
Class TypeEncoder

java.lang.Object
  extended by polyglot.util.TypeEncoder

public class TypeEncoder
extends java.lang.Object

The 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.


Field Summary
protected  boolean base64
           
protected  boolean test
           
protected  TypeSystem ts
           
protected  boolean zip
           
 
Constructor Summary
TypeEncoder(TypeSystem ts)
           
 
Method Summary
 Type decode(java.lang.String s)
           
 java.lang.String encode(Type t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ts

protected TypeSystem ts

zip

protected final boolean zip
See Also:
Constant Field Values

base64

protected final boolean base64
See Also:
Constant Field Values

test

protected final boolean test
See Also:
Constant Field Values
Constructor Detail

TypeEncoder

public TypeEncoder(TypeSystem ts)
Method Detail

encode

public java.lang.String encode(Type t)
                        throws java.io.IOException
Throws:
java.io.IOException

decode

public Type decode(java.lang.String s)
            throws java.io.InvalidClassException
Throws:
java.io.InvalidClassException