getValueDataType
getValueDataType()
The getValueDataType method returns the data type of a NameValuePair object.
You should use getValueDataType before using getValueAsDate, getValueAsNumeric, or getValueAsString to confirm you are referencing the correct data type.
Return value
The getValueDataType method returns a string indicating whether the NameValuePair contains a data, number, or string.
The valid values are:
*
DATA_TYPE_DATETIME-a date containing a date and time value.
*
DATA_TYPE_NUMERIC-a double containing a number value.
*
DATA_TYPE_STRING-a string containing a text value.
Example
The following example is an excerpt from a method which processes the response object from a getProfile method.
for(NameValuePair nvp : response.getProfileRecord())
{
System.out.println("Name:"+nvp.getName());
if(nvp.getValueDataType().equals(NameValuePair.DATA_TYPE_DATETIME))
{
System.out.println("Value:"+nvp.getValueAsDate());
}
else if(nvp.getValueDataType().equals(NameValuePair.DATA_TYPE_NUMERIC))
{
System.out.println("Value:"+nvp.getValueAsNumeric());
}
else
{
System.out.println("Value:"+nvp.getValueAsString());
}
}