|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.inxar.syntacs.util.Pickler
The Pickler
class contains static methods to transform
int
arrays into String
objects and vice
versa. Pickling is useful to decrease classfile size when one
requires large static final int
arrays. One the
shortcomings of Java's design is that there is little bytecode
support for array initialization. The classfile constant pool was
not designed to store arbitrarily typed arrays. Therefore, each
element in an array must be initialized expliclitly in bytecode
upon compilation. The constant pool /is/ designed to store char
arrays (Strings) however, so by converting an int
array into a String
, the compiler will put this in the
constant pool, saving the need for all those extra bytecode
instructions. Thus, when the class is initialized you can unpickle
the String back into the array. All said and done, the classfile
is not only /much/ smaller, the time needed to initialize the class
decreases.
Method Summary | |
static char[] |
bin(int x,
int bits)
|
static String |
pickle(int[] src)
"Pickles" a 1-dimensional array of int to a
String . |
static String |
pickle(int[][] src)
"Pickles" a 2-dimensional array of int to a
String . |
static String |
pickle(int[][][] src)
"Pickles" a 3-dimensional array of int to a
String . |
static int[] |
unpickle1D(String src)
"Unpickles" a String into a 1-dimensional array of
int that was previously pickled. |
static int[] |
unpickle1D(String[] src)
"Unpickles" a String[] array into a 1-dimensional
array of int that was previously pickled. |
static int[][] |
unpickle2D(String src)
"Unpickles" a String into a 2-dimensional array of
int that was previously pickled. |
static int[][] |
unpickle2D(String[] src)
"Unpickles" a String[] array into a 2-dimensional
array of int that was previously pickled. |
static int[][][] |
unpickle3D(String src)
"Unpickles" a String into a 3-dimensional array of
int that was previously pickled. |
static int[][][] |
unpickle3D(String[] src)
"Unpickles" a String[] array into a 3-dimensional
array of int that was previously pickled. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static String pickle(int[] src)
int
to a
String
.src
- - The source array to be pickled.String
. The
original in array can be restored using the unpickle1D()
method.
public static String pickle(int[][] src)
int
to a
String
.src
- - The source array to be pickled.String
. The
original in array can be restored using the unpickle2D()
method.
public static String pickle(int[][][] src)
int
to a
String
.src
- - The source array to be pickled.String
. The
original in array can be restored using the unpickle3D()
method.
public static int[] unpickle1D(String src)
String
into a 1-dimensional array of
int
that was previously pickled.src
- - The Pickle.public static int[] unpickle1D(String[] src)
String[]
array into a 1-dimensional
array of int
that was previously pickled. The
elements in the array are concatenated to a single string.
This method signature is provided to bypass the constant pool
requirement that a string have a maximum length of 65535 chars.src
- - The Pickle, split into several contiguous parts in
the array.public static int[][] unpickle2D(String src)
String
into a 2-dimensional array of
int
that was previously pickled.src
- - The Pickle.public static int[][] unpickle2D(String[] src)
String[]
array into a 2-dimensional
array of int
that was previously pickled. The
elements in the array are concatenated to a single string.
This method signature is provided to bypass the constant pool
requirement that a string have a maximum length of 65535 chars.src
- - The Pickle, split into several contiguous parts in
the array.public static int[][][] unpickle3D(String src)
String
into a 3-dimensional array of
int
that was previously pickled.src
- - The Pickle.public static int[][][] unpickle3D(String[] src)
String[]
array into a 3-dimensional
array of int
that was previously pickled. The
elements in the array are concatenated to a single string.
This method signature is provided to bypass the constant pool
requirement that a string have a maximum length of 65535 chars.src
- - The Pickle, split into several contiguous parts in
the array.public static char[] bin(int x, int bits)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |