com.buildforge.services.common.api
Class APIRequest

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<java.lang.String,java.lang.Object>
          extended by com.buildforge.services.common.api.APIRequest
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>

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

This class encapsulates an API request from a remote connection. It also provides static methods for interpreting information from hashes in general.

See Also:
Serialized Form

Constructor Summary
APIRequest(int cmd)
          Create a new API request structure.
 
Method Summary
 java.lang.StringBuilder append(java.lang.StringBuilder sb, boolean pretty)
           
 java.lang.Object[] getArray(java.lang.String key)
           
 boolean getBoolean(java.lang.String key, boolean def)
           
 char getChar(java.lang.String key, char def)
           
 int getCommand()
          Get the command code for this request.
 double getDouble(java.lang.String key, double def)
           
 int getInt(java.lang.String key, int def)
           
 long getLong(java.lang.String key, long def)
           
 java.util.Map<?,?> getMap(java.lang.String key)
           
 java.lang.String getString(java.lang.String key)
           
 java.lang.String getString(java.lang.String key, java.lang.String def)
           
 java.lang.String getTrimmedString(java.lang.String key)
           
 java.lang.String getTrimmedString(java.lang.String key, java.lang.String def)
           
 int getUserId()
          Get the user id for the request to use.
 boolean isSet(char flag)
           
 void setUserId(int uid)
          Set the user id for the request to use.
 
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

APIRequest

public APIRequest(int cmd)
Create a new API request structure.

Parameters:
conn - the connection that issued the request
cmd - the command for the request
Method Detail

setUserId

public void setUserId(int uid)
Set the user id for the request to use.

Parameters:
uid - the user id

getUserId

public int getUserId()
Get the user id for the request to use.

Returns:
the user id

getCommand

public int getCommand()
Get the command code for this request.

Returns:
the command code
Throws:
java.lang.IllegalStateException - if the command code has not been set

isSet

public boolean isSet(char flag)

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean def)

getChar

public char getChar(java.lang.String key,
                    char def)

getInt

public int getInt(java.lang.String key,
                  int def)

getLong

public long getLong(java.lang.String key,
                    long def)

getDouble

public double getDouble(java.lang.String key,
                        double def)

getString

public java.lang.String getString(java.lang.String key)

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String def)

getTrimmedString

public java.lang.String getTrimmedString(java.lang.String key)

getTrimmedString

public java.lang.String getTrimmedString(java.lang.String key,
                                         java.lang.String def)

getArray

public java.lang.Object[] getArray(java.lang.String key)

getMap

public java.util.Map<?,?> getMap(java.lang.String key)

append

public final java.lang.StringBuilder append(java.lang.StringBuilder sb,
                                            boolean pretty)