ec.util
Class Code

java.lang.Object
  |
  +--ec.util.Code

public class Code
extends java.lang.Object

Code provides some simple wrapper functions for encoding and decoding basic data types for storage in a pseudo-Java source code strings format. This differs from just "printing" them to string in that the actual precision of the object is maintained. Code attempts to keep the representations as "Java-like" as possible -- the exceptions being primarily floats and doubles, which are encoded as ints and longs. Encoding of objects and arrays is not supported. You'll have to handle that yourself. Strings are supported.

Everything is case-sensitive. Here's the breakdown.

TypeFormat
booleantrue or false
bytebbyte|
shortsshort|
intiint|
longllong|
floatffloatConvertedToIntForStorage|humanReadableFloat|
floatddoubleConvertedToLongForStorage|humanReadableDouble|
charstandard Java char, except that the only valid escape sequences are: \0 \t \n \b \' \" \ u unicodeHex
stringstandard Java string with \ u ...\ u Unicode escapes, except that the only other valid escape sequences are: \0 \t \n \b \' \"


Constructor Summary
Code()
           
 
Method Summary
static void decode(DecodeReturn d)
          Decodes the next item out of a DecodeReturn and modifies the DecodeReturn to hold the results.
static java.lang.String encode(boolean b)
          Encodes a boolean.
static java.lang.String encode(byte b)
          Encodes a byte.
static java.lang.String encode(char c)
          Encodes a character.
static java.lang.String encode(double d)
          Encodes a double.
static java.lang.String encode(float f)
          Encodes a float.
static java.lang.String encode(int i)
          Encodes an int.
static java.lang.String encode(long l)
          Encodes a long.
static java.lang.String encode(short s)
          Encodes a short.
static java.lang.String encode(java.lang.String s)
          Encodes a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Code

public Code()
Method Detail

encode

public static java.lang.String encode(boolean b)
Encodes a boolean.

encode

public static java.lang.String encode(byte b)
Encodes a byte.

encode

public static java.lang.String encode(char c)
Encodes a character.

encode

public static java.lang.String encode(short s)
Encodes a short.

encode

public static java.lang.String encode(int i)
Encodes an int.

encode

public static java.lang.String encode(long l)
Encodes a long.

encode

public static java.lang.String encode(float f)
Encodes a float.

encode

public static java.lang.String encode(double d)
Encodes a double.

encode

public static java.lang.String encode(java.lang.String s)
Encodes a String.

decode

public static void decode(DecodeReturn d)
Decodes the next item out of a DecodeReturn and modifies the DecodeReturn to hold the results. See DecodeReturn for more explanations about how to interpret the results.