DataObject is an often used Java class within The Othernet. The main uses of DataObjects are as calls/results to/from WebServices and Methods,
as well arguments/responses to database calls.
Constructors
// Build an empty DataObject
DataObject();
// Construct from a JSON string
DataObject( String jsonString );
// Copy another DataObject
DataObject( DataObject o );
Adding to the DataObject
// Put a variable into the DataObject
put( String name, DataObject x);
put( String name, String x);
put( String name, byte x);
put( String name, char x);
put( String name, short x);
put( String name, int x);
put( String name, long x);
put( String name, float x);
put( String name, double x);
put( String name, boolean x);
// Put a two dimensional array into the DataObject
// Same as above, only with two dimensional arrays
// Put a large array of bytes into the DataObject
// JSON object representation doesn't store large byte arrays efficiently
// Though this call modifies the JSON object representation slightly, the performance gain is large
putRawBytes( String name, byte[] x );
Retrieving elements from the DataObject
// Retrieve single elements from the DataObject
// Note that these calls will trigger errors if the requested element doesn't exist
DataObject getDataObject( String name );
String getString( String name );
byte getByte( String name );
char getChar( String name );
short getShort( String name );
int getInt( String name );
long getLong( String name );
float getFloat( String name );
double getDouble( String name );
boolean getBoolean( String name );
// Retrieve one dimensional arrays of elements from the DataObject
// Again, these calls will trigger errors if the requested array doesn't exist
DataObject[] getDataObjectArray( String name );
String[] getStringArray( String name );
byte[] getByteArray( String name );
char[] getCharArray( String name );
short[] getShortArray( String name );
int[] getIntArray( String name );
long[] getLongArray( String name );
float[] getFloatArray( String name );
double[] getDoubleArray( String name );
boolean[] getBooleanArray( String name );
// Retrieve two dimensional arrays of elements from the DataObject
// Same as above, except in the form get2DByteArray, get2DStringArray, etc
// Retrieve a large array of bytes from the DataObject
// Can only be used with byte arrays that were stored using the putRawBytes call
byte[] getRawBytes( String name );
Retrieving optional elements from the DataObject
// Retrieve single elements from the DataObject
// Returns null, or the default value if requested element doesn't exist
DataObject getOptionalDataObject( String name );
String getOptionalString( String name );
byte getOptionalByte( String name, byte default );
char getOptionalChar( String name, char default );
short getOptionalShort( String name, short default );
int getOptionalInt( String name,int default );
long getOptionalLong( String name, long default );
float getOptionalFloat( String name, float default );
double getOptionalDouble( String name, double default );
boolean getOptionalBoolean( String name, boolean default );
// Retrieve one dimensional arrays of elements from the DataObject
// Returns null if the requested array doesn't exist
DataObject[] getOptionalDataObjectArray( String name );
String[] getOptionalStringArray( String name );
byte[] getOptionalByteArray( String name );
char[] getOptionalCharArray( String name );
short[] getOptionalShortArray( String name );
int[] getOptionalIntArray( String name );
long[] getOptionalLongArray( String name );
float[] getOptionalFloatArray( String name );
double[] getOptionalDoubleArray( String name );
boolean[] getOptionalBooleanArray( String name );
// Retrieve two dimensional arrays of elements from the DataObject
// Same as above, except in the form getOptional2DByteArray, getOptional2DStringArray, etc
Misc
// Remove element from DataObject
remove( String name );
// Check for element existence
boolean exists( String name );