public class Model
extends org.json.simple.JSONObject
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
Model() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addTemplateParameter(String name,
String value)
Adds a new template parameter with the specified name and value.
|
protected void |
addToListField(String fieldName,
Object item)
Adds the passed Object to the list field with the specified name.
|
Object |
getField(String fieldName)
Returns the value of the specified field as an Object.
|
List |
getFieldAsList(String fieldName)
Returns the value of the specified field as a
List. |
Map |
getFieldAsMap(String fieldName)
Returns the value of the specified field as a
Map. |
String |
getFieldAsString(String fieldName)
Returns the value of the specified field as a
String. |
String[] |
getFieldNames()
Returns the complete set of properties associated with the model instance.
|
protected String |
getTemplateParameter(String name)
Returns the template parameter with the specified name.
|
boolean |
hasField(String fieldName)
Returns
true if a value is associated with the specified field
name, false otherwise. |
boolean |
isFieldMultikeyed(String fieldName)
|
boolean |
isFieldMultivalued(String fieldName)
|
void |
setField(String fieldName,
Object value)
Sets the value of the specified field to the passed Object.
|
escape, toJSONString, toJSONString, toString, toString, writeJSONString, writeJSONStringclear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, valuesequals, hashCodepublic String[] getFieldNames()
public boolean hasField(String fieldName)
true if a value is associated with the specified field
name, false otherwise.fieldName - name of field to look uppublic Object getField(String fieldName)
fieldName - name of field whose value is to be returnedpublic Map getFieldAsMap(String fieldName)
Map. Equivalent to
(Map) getField(fieldName), hence this method will throw a
ClassCastException if the field does not implement Map.fieldName - name of field whose value is to be returnedClassCastExceptionpublic List getFieldAsList(String fieldName)
List. Equivalent to
(List) getField(fieldName), hence this method will throw a
ClassCastException if the field does not implement List.fieldName - name of field whose value is to be returnedClassCastExceptionpublic String getFieldAsString(String fieldName)
String. Equivalent
to (String) getField(fieldName), hence this method will throw a
ClassCastException if the field is not of type String.fieldName - name of field whose value is to be returnedClassCastExceptionprotected String getTemplateParameter(String name)
name - name of template parameter whose value is to be returnedpublic boolean isFieldMultikeyed(String fieldName)
fieldName - name of field to look uppublic boolean isFieldMultivalued(String fieldName)
fieldName - name of field to look uppublic void setField(String fieldName, Object value)
fieldName - name of field to setvalue - object to associate with passed field nameprotected void addToListField(String fieldName, Object item)
fieldName - name of list field for which the passed item should be
addeditem - item to addCopyright © 2012. All Rights Reserved.