redstone.xmlrpc
Class XmlRpcStruct

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.lang.Object>
          extended by redstone.xmlrpc.XmlRpcStruct
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>

public class XmlRpcStruct
extends java.util.HashMap<java.lang.String,java.lang.Object>

A Struct represents an XML-RPC struct in its Java form. Essentially, it's just a plain java.util.HashMap with utility methods for extracting members of any of the data types supported by the XML-RPC library. The class does not introduce any new field members which makes it no more expensive than a regular HashMap.

To extract nested values from the struct, use the new simplified accessors which perform the casting for you:

  Date date = myStruct.getArray( "someListOfStructs" ).getStruct( 0 ).getDate( "someDate" );
  

Author:
Greger Olsson
See Also:
Serialized Form

Constructor Summary
XmlRpcStruct()
           
 
Method Summary
 XmlRpcArray getArray(java.lang.Object key)
          Returns the Array with the given key from the Struct.
 byte[] getBinary(java.lang.Object key)
          Returns the byte[] with the given key from the Struct.
 java.io.InputStream getBinaryAsStream(java.lang.Object key)
          Returns the byte[] with the given key from the Struct, as an input stream (currently, a java.io.ByteArrayInputStream).
 boolean getBoolean(java.lang.Object key)
          Returns the boolean with the given key from the Struct.
 java.lang.Boolean getBooleanWrapper(java.lang.Object key)
          Returns the Boolean wrapper with the given key from the Struct.
 java.util.Date getDate(java.lang.Object key)
          Returns the Date with the given key from the Struct.
 double getDouble(java.lang.Object key)
          Returns the double with the given key from the Struct.
 java.lang.Double getDoubleWrapper(java.lang.Object key)
          Returns the Double wrapper with the given key from the Struct.
 int getInteger(java.lang.Object key)
          Returns the integer with the given key from the Struct.
 java.lang.Integer getIntegerWrapper(java.lang.Object key)
          Returns the Integer wrapper with the given key from the Struct.
 java.lang.String getString(java.lang.Object key)
          Returns the String with the given key from the Struct.
 XmlRpcStruct getStruct(java.lang.Object key)
          Returns the Struct with the given key from the Struct.
 long getTimestamp(java.lang.Object key)
          Returns the long integer timestamp with the given key from the Struct.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

XmlRpcStruct

public XmlRpcStruct()
Method Detail

getString

public java.lang.String getString(java.lang.Object key)
Returns the String with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a String.

getBoolean

public boolean getBoolean(java.lang.Object key)
Returns the boolean with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Boolean.
java.lang.NullPointerException - if a value with the given key does not exist,

getBooleanWrapper

public java.lang.Boolean getBooleanWrapper(java.lang.Object key)
Returns the Boolean wrapper with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Boolean.

getInteger

public int getInteger(java.lang.Object key)
Returns the integer with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Integer.
java.lang.NullPointerException - if a value with the given key does not exist,

getIntegerWrapper

public java.lang.Integer getIntegerWrapper(java.lang.Object key)
Returns the Integer wrapper with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Integer.

getDouble

public double getDouble(java.lang.Object key)
Returns the double with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Double.
java.lang.NullPointerException - if a value with the given key does not exist,

getDoubleWrapper

public java.lang.Double getDoubleWrapper(java.lang.Object key)
Returns the Double wrapper with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Double.

getArray

public XmlRpcArray getArray(java.lang.Object key)
Returns the Array with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Array.
java.lang.NullPointerException - if a value at the given key does not exist.

getStruct

public XmlRpcStruct getStruct(java.lang.Object key)
Returns the Struct with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Struct.

getDate

public java.util.Date getDate(java.lang.Object key)
Returns the Date with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Date.

getTimestamp

public long getTimestamp(java.lang.Object key)
Returns the long integer timestamp with the given key from the Struct. The timestamp represents the number of milliseconds since midnight jan 01, 1970, as returned by Date.getTime().

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a Date.

getBinary

public byte[] getBinary(java.lang.Object key)
Returns the byte[] with the given key from the Struct.

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a byte[].

getBinaryAsStream

public java.io.InputStream getBinaryAsStream(java.lang.Object key)
Returns the byte[] with the given key from the Struct, as an input stream (currently, a java.io.ByteArrayInputStream).

Parameters:
key - The key of the value to extract.
Throws:
java.lang.ClassCastException - if the value with the given key is not a byte[].