public class

CommandParameter

extends Object
java.lang.Object
   ↳ mason.hardware.platform.CommandParameter

Class Overview

A helper class to construct the commands parameter additional data into a single object.

 CommandParameter metadataParameter = new CommandParameter();
 metadataParameter.addIntegerParameter("age", 97);
 metadataParameter.addIntegerParameter("height", 180);
 metadataParameter.addIntegerParameter("weight", 10);
 metadataParameter.addIntegerParameter("gender", 0);
 

Summary

Public Constructors
CommandParameter()
Public Methods
static CommandParameter BuildFromJsonString(String data)
Construct the CommandParameter form string data
void addIntegerParameter(String key, Integer value)
Add pair of (key, value) to the CommandParameter where value will be treated as type Integer
void addStringParameter(String key, String value)
Add pair of (key, value) to the CommandParameter were value will be treated as type String
Integer getInteger(String key)
Returns the integer value to which the key is mapped.
String getString(String key)
Returns the string value to which the key is mapped.
JSONObject toJson()
Converts the CommandParameter object to JSONObject.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public CommandParameter ()

Public Methods

public static CommandParameter BuildFromJsonString (String data)

Construct the CommandParameter form string data

Parameters
data String: string to construct the CommandParameter
Returns
CommandParameter the CommandParameter object to be used on the command execution

public void addIntegerParameter (String key, Integer value)

Add pair of (key, value) to the CommandParameter where value will be treated as type Integer

Parameters
key String: the expected identifier, specific per command
value Integer: the value to assign to this key.

public void addStringParameter (String key, String value)

Add pair of (key, value) to the CommandParameter were value will be treated as type String

Parameters
key String: the expected identifier, specific per command
value String: the value to assign to this key.

public Integer getInteger (String key)

Returns the integer value to which the key is mapped. Returns null if key does not exist.

Parameters
key String: the expected identifier, specific per command.
Returns
Integer value maped to key.

public String getString (String key)

Returns the string value to which the key is mapped. Returns null if key does not exist.

Parameters
key String: the expected identifier, specific per command.
Returns
String value maped to key.

public JSONObject toJson ()

Converts the CommandParameter object to JSONObject.

Returns
JSONObject JSONObject equivalent to the CommandParameter object
Throws
JSONException