|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.util.Code
public class Code
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.
Type | Format |
boolean | true or false (old style, case sensitive) or T or F (new style, case sensitive) |
byte | bbyte| |
short | sshort| |
int | iint| |
long | llong| |
float | ffloatConvertedToIntForStorage|humanReadableFloat| or (only for reading in) f|humanReadableFloat| |
float | ddoubleConvertedToLongForStorage|humanReadableDouble| or (only for reading in) d|humanReadableDouble| |
char | standard Java char, except that the only valid escape sequences are: \0 \t \n \b \' \" \ u unicodeHex |
string | standard 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 DecodeReturn |
checkPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, then trims the line and checks the preamble. |
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. |
static boolean |
readBooleanWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a boolean value ("true" or "false") if there is one, and returns it. |
static byte |
readByteWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a byte if there is one, and returns it. |
static char |
readCharacterWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a character if there is one, and returns it. |
static double |
readDoubleWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a double if there is one, and returns it. |
static float |
readFloatWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a float if there is one, and returns it. |
static int |
readIntegerWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in an integer if there is one, and returns it. |
static long |
readLongWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a long if there is one, and returns it. |
static short |
readShortWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a short if there is one, and returns it. |
static java.lang.String |
readStringWithPreamble(java.lang.String preamble,
EvolutionState state,
java.io.LineNumberReader reader)
Finds the next nonblank line, skips past an expected preamble, and reads in a string if there is one, and returns it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Code()
Method Detail |
---|
public static java.lang.String encode(boolean b)
public static java.lang.String encode(byte b)
public static java.lang.String encode(char c)
public static java.lang.String encode(short s)
public static java.lang.String encode(int i)
public static java.lang.String encode(long l)
public static java.lang.String encode(float f)
public static java.lang.String encode(double d)
public static java.lang.String encode(java.lang.String s)
public static void decode(DecodeReturn d)
public static DecodeReturn checkPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static java.lang.String readStringWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static char readCharacterWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static byte readByteWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static short readShortWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static long readLongWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static int readIntegerWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static float readFloatWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static double readDoubleWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
public static boolean readBooleanWithPreamble(java.lang.String preamble, EvolutionState state, java.io.LineNumberReader reader)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |