&& names.length == vals.length)
{
inputArgs = new Hashtable(names.length);
for (int i = 0; i < names.length; i++)
{
final UPnPStateVariable var = action.getStateVariable(names[i]);
final String upnpType = var.getUPnPDataType();
final Object argObj;
if (UPnPStateVariable.TYPE_STRING.equals(upnpType))
{
argObj = vals[i];
}
else if (UPnPStateVariable.TYPE_CHAR.equals(upnpType))
{
argObj = new Character(vals[i].charAt(0));
}
else if (UPnPStateVariable.TYPE_BIN_BASE64.equals(upnpType))
{
argObj = Base64.decodeBase64(vals[i]);
}
else if (UPnPStateVariable.TYPE_BIN_HEX.equals(upnpType))
{
argObj = Hex.decode(vals[i]);
}
else
{
Class javaType = var.getJavaDataType();
Constructor constructor = javaType.getConstructor(new Class[] { String.class });
argObj = constructor.newInstance(new Object[] { vals[i] });
}
inputArgs.put(names[i], argObj);
}
}
// invoke
final Dictionary out = action.invoke(inputArgs);
// prepare output arguments
if (out != null && out.size() > 0)
{
for (Enumeration e = out.keys(); e.hasMoreElements();)
{
final String key = (String) e.nextElement();
final UPnPStateVariable var = action.getStateVariable(key);
Object value = out.get(key);
if (value instanceof Date)
{
synchronized (DATA_FORMAT)
{
value = DATA_FORMAT.format((Date) value);
}
}
else if (value instanceof byte[])
{
value = Hex.encode((byte[]) value);
}
json.append("output", new JSONObject() // //$NON-NLS-1$
.put("name", key)// //$NON-NLS-1$
.put("type", var.getUPnPDataType()) // //$NON-NLS-1$
.put("value", value)); //$NON-NLS-1$
}
}
return json;
}