org.exoplatform.social.client.core.model
Class ModelImpl

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by org.json.simple.JSONObject
              extended by org.exoplatform.social.client.core.model.ModelImpl
All Implemented Interfaces:
Serializable, Cloneable, Map, Model, org.json.simple.JSONAware, org.json.simple.JSONStreamAware
Direct Known Subclasses:
RestActivityImpl, RestActivityStreamImpl, RestCommentImpl, RestIdentityImpl, RestLikeImpl, RestProfileImpl

public class ModelImpl
extends org.json.simple.JSONObject
implements Model

ModelImpl implements Model.

Since:
May 20, 2011
Author:
hoatle (hoatlevan at gmail dot com)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  PropertyChangeSupport propertyChanges
          The property change event support for this model.
 
Constructor Summary
ModelImpl()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a property change event listener to this model
 void addToListField(String fieldName, Object item)
          Adds the passed Object to the list field with the specified name.
 PropertyChangeListener[] findPropertyChangeListeners()
          Gets the property change listeners registered and associated with this property change listener.
 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.
 boolean hasField(String fieldName)
          Returns true if a value is associated with the specified field name, false otherwise.
 boolean isFieldMultikeyed(String fieldName)
          Returns true if the value of the specified field implements Map, false otherwise.
 boolean isFieldMultivalued(String fieldName)
          Returns true if the value of the specified field implements List, false otherwise.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a property change event listener which was added to this model.
 void setField(String fieldName, Object value)
          Sets the value of the specified field to the passed Object.
 
Methods inherited from class org.json.simple.JSONObject
escape, toJSONString, toJSONString, toString, toString, writeJSONString, writeJSONString
 
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
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from interface org.json.simple.JSONAware
toJSONString
 
Methods inherited from interface org.json.simple.JSONStreamAware
writeJSONString
 

Field Detail

propertyChanges

protected PropertyChangeSupport propertyChanges
The property change event support for this model.

Constructor Detail

ModelImpl

public ModelImpl()
Method Detail

getFieldNames

public String[] getFieldNames()
Returns the complete set of properties associated with the model instance.

Specified by:
getFieldNames in interface Model
Returns:
a string array

hasField

public boolean hasField(String fieldName)
Returns true if a value is associated with the specified field name, false otherwise.

Specified by:
hasField in interface Model
Parameters:
fieldName - name of field to look up
Returns:
a boolean value

getField

public Object getField(String fieldName)
Returns the value of the specified field as an Object.

Specified by:
getField in interface Model
Parameters:
fieldName - name of field whose value is to be returned
Returns:
an object associated with fieldName

getFieldAsMap

public Map getFieldAsMap(String fieldName)
Returns the value of the specified field as a Map. Equivalent to (Map) getField(fieldName), hence this method will throw a ClassCastException if the field does not implement Map.

Specified by:
getFieldAsMap in interface Model
Parameters:
fieldName - name of field whose value is to be returned
Returns:
a map associated with fieldName
See Also:
ClassCastException

getFieldAsList

public List getFieldAsList(String fieldName)
Returns the value of the specified field as a List. Equivalent to (List) getField(fieldName), hence this method will throw a ClassCastException if the field does not implement List.

Specified by:
getFieldAsList in interface Model
Parameters:
fieldName - name of field whose value is to be returned
Returns:
a list associated with fieldName
See Also:
ClassCastException

getFieldAsString

public String getFieldAsString(String fieldName)
Returns the value of the specified field as a String. Equivalent to (String) getField(fieldName), hence this method will throw a ClassCastException if the field is not of type String.

Specified by:
getFieldAsString in interface Model
Parameters:
fieldName - name of field whose value is to be returned
Returns:
a string associated with fieldName
See Also:
ClassCastException

isFieldMultikeyed

public boolean isFieldMultikeyed(String fieldName)
Returns true if the value of the specified field implements Map, false otherwise.

Specified by:
isFieldMultikeyed in interface Model
Parameters:
fieldName - name of field to look up
Returns:
a boolean value

isFieldMultivalued

public boolean isFieldMultivalued(String fieldName)
Returns true if the value of the specified field implements List, false otherwise.

Specified by:
isFieldMultivalued in interface Model
Parameters:
fieldName - name of field to look up
Returns:
a boolean value

setField

public void setField(String fieldName,
                     Object value)
Sets the value of the specified field to the passed Object.

Specified by:
setField in interface Model
Parameters:
fieldName - name of field to set
value - object to associate with passed field name

addToListField

public void addToListField(String fieldName,
                           Object item)
Adds the passed Object to the list field with the specified name.

Specified by:
addToListField in interface Model
Parameters:
fieldName - name of list field for which the passed item should be added
item - item to add

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change event listener to this model

Specified by:
addPropertyChangeListener in interface Model
Parameters:
listener - The listener to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change event listener which was added to this model.

Specified by:
removePropertyChangeListener in interface Model
Parameters:
listener - The listener to be removed.

findPropertyChangeListeners

public PropertyChangeListener[] findPropertyChangeListeners()
Gets the property change listeners registered and associated with this property change listener. If this property change has no listeners registered, a zero-length array is returned.

Specified by:
findPropertyChangeListeners in interface Model
Returns:
an array of listeners


Copyright © 2011-2012 eXo Platform. All Rights Reserved.