org.exoplatform.social.client.api.model
Interface Model

All Superinterfaces:
org.json.simple.JSONAware, org.json.simple.JSONStreamAware, Map
All Known Subinterfaces:
RestActivity, RestComment, RestIdentity, RestLike, RestProfile
All Known Implementing Classes:
ModelImpl, RestActivityImpl, RestActivityStreamImpl, RestCommentImpl, RestIdentityImpl, RestLikeImpl, RestProfileImpl

public interface Model
extends Map, org.json.simple.JSONAware, org.json.simple.JSONStreamAware

The general model extends JSONObject's interfaces.

Inspiration taken from: http://code.google.com/p/opensocial-java-client/source/browse/trunk/java/src/org/opensocial/models/Model.java

Since:
May 19, 2011
Author:
hoatle (hoatlevan at gmail dot com)

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
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 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
 

Method Detail

getFieldNames

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

Returns:
a string array

hasField

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

Parameters:
fieldName - name of field to look up
Returns:
a boolean value

getField

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

Parameters:
fieldName - name of field whose value is to be returned
Returns:
an object associated with fieldName

getFieldAsMap

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.

Parameters:
fieldName - name of field whose value is to be returned
Returns:
a map associated with fieldName
See Also:
ClassCastException

getFieldAsList

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.

Parameters:
fieldName - name of field whose value is to be returned
Returns:
a list associated with fieldName
See Also:
ClassCastException

getFieldAsString

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.

Parameters:
fieldName - name of field whose value is to be returned
Returns:
a string associated with fieldName
See Also:
ClassCastException

isFieldMultikeyed

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

Parameters:
fieldName - name of field to look up
Returns:
a boolean value

isFieldMultivalued

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

Parameters:
fieldName - name of field to look up
Returns:
a boolean value

setField

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

Parameters:
fieldName - name of field to set
value - object to associate with passed field name

addToListField

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

Parameters:
fieldName - name of list field for which the passed item should be added
item - item to add

addPropertyChangeListener

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

Parameters:
listener - The listener to be added

removePropertyChangeListener

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

Parameters:
listener - The listener to be removed.

findPropertyChangeListeners

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.

Returns:
an array of listeners


Copyright © 2011 eXo Platform. All Rights Reserved.