|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.ulc.util.Anything
Anything is a polymorphic, self describing, and dynamic data structure. An Anything can represent simple data types like longs, boolean, doubles or strings, arrays of Anythings, and dictionaries mapping between strings and Anythings (i.e. associative arrays). Because Anythings are recursive by definition, they can model arbitrarily complex structures.
Anything are streamed with AnythingWriters and AnythingReaders. Two formats exist: a pretty printing pure ASCII format (classes AnythingReader and AnythingWriter) and a more compact easier to parse format (classes AnythingReader2 and AnythingWriter2).
In the context of ULC Anythings are used as a simple but robust marshalling mechanism.
AnythingReader
,
AnythingWriter
,
AnythingReader2
,
AnythingWriter2
, Serialized FormField Summary | |
static int |
BOOLEAN
|
static int |
BYTES
|
static int |
DOUBLE
|
static int |
LONG
|
static int |
NULL
|
static int |
SERIALIZABLE
|
static int |
STRING
|
static int |
VECTOR
|
Constructor Summary | |
Anything()
Constructs an empty (null) Anything. |
|
Anything(boolean l)
Constructs an Anything representing a boolean. |
|
Anything(byte[] s)
Constructs an Anything representing a byte array. |
|
Anything(double d)
Constructs an Anything representing a double. |
|
Anything(java.lang.Double d)
Constructs an Anything representing a double. |
|
Anything(int l)
Constructs an Anything representing an int. |
|
Anything(int[] ints)
Constructs an Anything representing a String. |
|
Anything(long l)
Constructs an Anything representing a long. |
|
Anything(java.io.Serializable s)
Constructs an Anything representing a Serializable. |
|
Anything(java.lang.String s)
Constructs an Anything representing a String. |
|
Anything(java.lang.String[] strings)
Constructs an Anything representing a String. |
|
Anything(java.util.Vector v)
Constructs an Anything representing a String. |
Method Summary | |
void |
append(Anything value)
Converts this Anything to a vector and adds the given Anything to the end of the vector. |
boolean |
asBoolean(boolean dflt)
Generates the boolean representation of this Anything. |
byte[] |
asBytes()
Generates the byte array representation of this Anything. |
double |
asDouble(double dflt)
Generates the double representation of this Anything. |
int |
asInt(int dflt)
Generates the int representation of this Anything. |
long |
asLong(long dflt)
Generates the long representation of this Anything. |
java.io.Serializable |
asSerializable(java.io.Serializable dflt)
Generates the Serializable representation of this Anything. |
java.lang.String |
asString(java.lang.String dflt)
Generates the string representation of this Anything. |
java.lang.Object |
clone()
Clones an Anything. |
void |
dump(java.io.OutputStream out)
Pretty prints the Anything to the given stream. |
void |
dump(java.io.OutputStream out,
boolean compact)
Pretty prints the Anything to the given stream. |
static Anything |
fromObject(java.lang.Object o)
Constructs an Anything representing an Object |
Anything |
get(int index)
Retrieves the element at the specified index in this Anything. |
Anything |
get(java.lang.String key)
Retrieves the element associated with the given key from this Anything. |
boolean |
get(java.lang.String key,
boolean dflt)
Retrieves the element associated with the given key from this Anything and converts it to a boolean. |
double |
get(java.lang.String key,
double dflt)
Retrieves the element associated with the given key from this Anything and converts it to a double. |
int |
get(java.lang.String key,
int dflt)
Retrieves the element associated with the given key from this Anything and converts it to an int. |
long |
get(java.lang.String key,
long dflt)
Retrieves the element associated with the given key from this Anything and converts it to a long. |
java.io.Serializable |
get(java.lang.String key,
java.io.Serializable dflt)
Retrieves the element associated with the given key from this Anything and converts it to a Serializable. |
java.lang.String |
get(java.lang.String key,
java.lang.String dflt)
Retrieves the element associated with the given key from this Anything and converts it to a String. |
byte[] |
getBytes(java.lang.String key)
Retrieves the element associated with the given key from this Anything and converts it to a byte array. |
int |
getType()
Retrieve the tag from the Anything. |
boolean |
isDefined(java.lang.String key)
Determines whether the given key is in this Anything. |
boolean |
isNull()
Is the Anything empty? |
java.util.Enumeration |
keys()
Gets all slot names (keys) of the Anything If the Anything doesn't represent a dictionary or if the index is out of bounds null is returned. |
static void |
main(java.lang.String[] args)
A unit test :-) |
void |
put(int index,
Anything value)
Replaces the element at the specified index in this vector. |
void |
put(java.lang.String key,
Anything value)
Stores the given value under the given key in this Anything. |
void |
put(java.lang.String key,
boolean value)
Stores the given boolean value under the given key in this Anything. |
void |
put(java.lang.String key,
byte[] value)
Stores the given byte array value under the given key in this Anything. |
void |
put(java.lang.String key,
double value)
Stores the given double value under the given key in this Anything. |
void |
put(java.lang.String key,
int value)
Stores the given int value under the given key in this Anything. |
void |
put(java.lang.String key,
int[] ints)
Stores the given String value under the given key in this Anything. |
void |
put(java.lang.String key,
long value)
Stores the given long value under the given key in this Anything. |
void |
put(java.lang.String key,
java.io.Serializable o)
|
void |
put(java.lang.String key,
java.lang.String value)
Stores the given String value under the given key in this Anything. |
void |
put(java.lang.String key,
java.util.Vector v)
Stores the given String value under the given key in this Anything. |
static Anything |
read(java.io.InputStream in)
Read an Anything from the given stream. |
static Anything |
read(java.lang.String filename)
Read an Anything from the given file. |
void |
remove(int ix)
Removes the element at the specified index from this vector. |
void |
remove(java.lang.String key)
Stores the given value under the given key in this Anything. |
int |
size()
The size of the Anything. |
java.lang.String |
slotName(int ix)
Gets the slot name (key) at the given index. |
java.util.Vector |
toCollection()
Stores the given value under the given key in this Anything. |
java.lang.Object |
toObject()
Stores the given value under the given key in this Anything. |
java.lang.String |
toString()
Generates the string representation of this Anything. |
java.util.Enumeration |
values()
Retrieves the values of this Anything |
void |
write(java.io.OutputStream out,
IAnythingWriter format)
Writes the Anything to the specified stream using the given format. |
void |
write(java.lang.String filename)
Write the Anything to the given file by using the pretty printing format. |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final int NULL
public static final int BOOLEAN
public static final int LONG
public static final int DOUBLE
public static final int STRING
public static final int BYTES
public static final int VECTOR
public static final int SERIALIZABLE
Constructor Detail |
public Anything()
public Anything(byte[] s)
public Anything(int[] ints)
public Anything(java.lang.String[] strings)
public Anything(double d)
public Anything(int l)
public Anything(long l)
public Anything(java.io.Serializable s)
ob
- java.io.Serializablepublic Anything(java.lang.Double d)
public Anything(java.lang.String s)
public Anything(java.util.Vector v)
public Anything(boolean l)
Method Detail |
public void append(Anything value)
public boolean asBoolean(boolean dflt)
public byte[] asBytes()
public double asDouble(double dflt)
public int asInt(int dflt)
public long asLong(long dflt)
public java.io.Serializable asSerializable(java.io.Serializable dflt)
public java.lang.String asString(java.lang.String dflt)
public java.lang.Object clone()
public void dump(java.io.OutputStream out)
public void dump(java.io.OutputStream out, boolean compact)
public static Anything fromObject(java.lang.Object o)
public Anything get(int index)
public Anything get(java.lang.String key)
public double get(java.lang.String key, double dflt)
public int get(java.lang.String key, int dflt)
public long get(java.lang.String key, long dflt)
public java.io.Serializable get(java.lang.String key, java.io.Serializable dflt)
public java.lang.String get(java.lang.String key, java.lang.String dflt)
public boolean get(java.lang.String key, boolean dflt)
public byte[] getBytes(java.lang.String key)
public int getType()
public boolean isDefined(java.lang.String key)
public boolean isNull()
public java.util.Enumeration keys()
public static void main(java.lang.String[] args)
public void put(int index, Anything value)
public void put(java.lang.String key, byte[] value)
public void put(java.lang.String key, int[] ints)
public void put(java.lang.String key, double value)
public void put(java.lang.String key, int value)
public void put(java.lang.String key, long value)
public void put(java.lang.String key, Anything value)
public void put(java.lang.String key, java.io.Serializable o)
public void put(java.lang.String key, java.lang.String value)
public void put(java.lang.String key, java.util.Vector v)
public void put(java.lang.String key, boolean value)
public static Anything read(java.io.InputStream in)
public static Anything read(java.lang.String filename)
public void remove(int ix)
public void remove(java.lang.String key)
public int size()
public java.lang.String slotName(int ix)
public java.util.Vector toCollection()
public java.lang.Object toObject()
public java.lang.String toString()
public java.util.Enumeration values()
public void write(java.io.OutputStream out, IAnythingWriter format)
public void write(java.lang.String filename)
AnythingWriter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |