org.springframework.extensions.surf.types
Class AbstractModelObject

java.lang.Object
  extended by org.springframework.extensions.surf.types.AbstractModelObject
All Implemented Interfaces:
Serializable, ModelObject, ResourceProvider
Direct Known Subclasses:
AbstractRenderableModelObject, ComponentImpl, ConfigurationImpl, ContentAssociationImpl, ModelObjectCache.ModelObjectSentinel, PageAssociationImpl, PageImpl, PageTypeImpl, TemplateInstanceImpl, ThemeImpl

public abstract class AbstractModelObject
extends Object
implements ModelObject, ResourceProvider

Abstract base class that can be extended to introduce custom model objects into the framework. Custom model objects must be registered with the configuration file. Once done, they can be loaded and persisted along with other model objects. All model classes extending from this class are expected to have "id", "title" and "description" fields.

Author:
muzquiano
See Also:
Serialized Form

Field Summary
static String CONTAINER_PROPERTIES
           
static String CONTAINER_RESOURCES
           
protected  Map<String,Serializable> customProperties
           
protected  String description
           
protected  String descriptionId
           
protected  org.dom4j.Document document
           
protected  String id
           
protected  ModelPersisterInfo info
           
protected  Map<String,Serializable> modelProperties
           
protected  String modelVersion
           
protected  long modificationTime
           
protected  ResourceProvider resourceContainer
           
protected  String title
           
protected  String titleId
           
 
Fields inherited from interface org.springframework.extensions.surf.ModelObject
PROP_DESCRIPTION, PROP_DESCRIPTION_ID, PROP_ID, PROP_TITLE, PROP_TITLE_ID
 
Constructor Summary
protected AbstractModelObject()
          Constructor used by sentinel object
  AbstractModelObject(String id, ModelPersisterInfo info, org.dom4j.Document document)
          Constructs a new model object
 
Method Summary
 Resource addResource(String name, String resourceId)
          Adds/Creates a resource with the given name and resource id
 Resource addResource(String name, String protocolId, String endpointId, String objectId)
          Adds/Creates a resource with the given name, object id and endpoint id
 boolean getBooleanProperty(String propertyName)
           
 Map<String,Serializable> getCustomProperties()
           
 String getCustomProperty(String propertyName)
           
 String getDescription()
          Returns the description property of the model object
 String getDescriptionId()
          Returns the description id property of the model object
 org.dom4j.Document getDocument()
           
 String getId()
          Returns the id of the model object.
 ModelPersisterInfo getKey()
          Returns the model object key instance
 Map<String,Serializable> getModelProperties()
           
 String getModelProperty(String propertyName)
           
 String getModelVersion()
           
 long getModificationTime()
           
 String getPersisterId()
          Returns the ModelObjectPersister id that this object is bound to
 Map<String,Serializable> getProperties()
           
 String getProperty(String propertyName)
           
 Resource getResource(String name)
          Looks up a resource with the given name
protected  ResourceProvider getResourceContainer()
           
 Resource[] getResources()
          Returns the set of all resources
 Map<String,Resource> getResourcesMap()
          Returns the map of resources
 String getStoragePath()
          Returns the persistence storage path of this object
 String getTitle()
          Returns the title property of the model object.
 String getTitleId()
          Returns the title id property of the model object.
abstract  String getTypeId()
          Returns the type id of the model object.
protected  boolean isCustomProperty(String propertyName)
          Uses reflection to determine whether the given property name is a custom property.
protected  boolean isModelProperty(String propertyName)
          Uses reflection to determine whether the given property name is a model property.
 boolean isSaved()
          Indicates whether the object is currently persisted (saved) or not.
 void removeCustomProperty(String propertyName)
           
 void removeModelProperty(String propertyName)
           
 void removeProperty(String propertyName)
           
 void removeResource(String name)
          Removes a resource with the given name
 void setCustomProperty(String propertyName, String propertyValue)
           
 void setDescription(String value)
          Sets the description property of the model object
 void setDescriptionId(String value)
          Sets the description id property of the model object
 void setId(String id)
          Allows for reassignment of the id of the object
 void setModelProperty(String propertyName, String propertyValue)
           
 void setModificationTime(long modificationTime)
           
 void setProperty(String propertyName, String propertyValue)
           
 void setTitle(String title)
          Sets the title property of the model object
 void setTitleId(String titleId)
          Sets the title id property of the model object
 String toString()
           
 void touch()
           
 String toXML()
          Serializes the object to XML.
 void updateResource(String name, Resource resource)
          Updates a resource for the given name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONTAINER_PROPERTIES

public static String CONTAINER_PROPERTIES

CONTAINER_RESOURCES

public static String CONTAINER_RESOURCES

document

protected final org.dom4j.Document document

info

protected final ModelPersisterInfo info

id

protected String id

modificationTime

protected long modificationTime

modelVersion

protected String modelVersion

modelProperties

protected Map<String,Serializable> modelProperties

customProperties

protected Map<String,Serializable> customProperties

title

protected String title

titleId

protected String titleId

description

protected String description

descriptionId

protected String descriptionId

resourceContainer

protected ResourceProvider resourceContainer
Constructor Detail

AbstractModelObject

public AbstractModelObject(String id,
                           ModelPersisterInfo info,
                           org.dom4j.Document document)
Constructs a new model object

Parameters:
document - the document

AbstractModelObject

protected AbstractModelObject()
Constructor used by sentinel object

Method Detail

getKey

public final ModelPersisterInfo getKey()
Description copied from interface: ModelObject
Returns the model object key instance

Specified by:
getKey in interface ModelObject
Returns:
the structure that represents the persistence information for this model object

getModelVersion

public final String getModelVersion()
Specified by:
getModelVersion in interface ModelObject

getId

public final String getId()
Description copied from interface: ModelObject
Returns the id of the model object.

Specified by:
getId in interface ModelObject
Returns:
The id

getTitle

public final String getTitle()
Description copied from interface: ModelObject
Returns the title property of the model object.

Specified by:
getTitle in interface ModelObject
Returns:
The title

getTitleId

public final String getTitleId()
Description copied from interface: ModelObject
Returns the title id property of the model object.

Specified by:
getTitleId in interface ModelObject
Returns:
The title id

setTitle

public final void setTitle(String title)
Description copied from interface: ModelObject
Sets the title property of the model object

Specified by:
setTitle in interface ModelObject

setTitleId

public final void setTitleId(String titleId)
Description copied from interface: ModelObject
Sets the title id property of the model object

Specified by:
setTitleId in interface ModelObject

getDescription

public final String getDescription()
Description copied from interface: ModelObject
Returns the description property of the model object

Specified by:
getDescription in interface ModelObject
Returns:
The description

getDescriptionId

public final String getDescriptionId()
Description copied from interface: ModelObject
Returns the description id property of the model object

Specified by:
getDescriptionId in interface ModelObject
Returns:
The description id

setDescription

public final void setDescription(String value)
Description copied from interface: ModelObject
Sets the description property of the model object

Specified by:
setDescription in interface ModelObject

setDescriptionId

public final void setDescriptionId(String value)
Description copied from interface: ModelObject
Sets the description id property of the model object

Specified by:
setDescriptionId in interface ModelObject

isSaved

public final boolean isSaved()
Description copied from interface: ModelObject
Indicates whether the object is currently persisted (saved) or not. A new object will have this flag set to false prior to a save and true once the save operation has completed.

Specified by:
isSaved in interface ModelObject
Returns:
Whether the object is currently saved

getDocument

public final org.dom4j.Document getDocument()
Specified by:
getDocument in interface ModelObject

toXML

public final String toXML()
Description copied from interface: ModelObject
Serializes the object to XML. By default, this uses a pretty XML renderer so that the resulting XML is human readable.

Specified by:
toXML in interface ModelObject
Returns:
The XML string

getBooleanProperty

public final boolean getBooleanProperty(String propertyName)
Specified by:
getBooleanProperty in interface ModelObject

getProperty

public final String getProperty(String propertyName)
Specified by:
getProperty in interface ModelObject

setProperty

public final void setProperty(String propertyName,
                              String propertyValue)
Specified by:
setProperty in interface ModelObject

removeProperty

public final void removeProperty(String propertyName)
Specified by:
removeProperty in interface ModelObject

isCustomProperty

protected final boolean isCustomProperty(String propertyName)
Uses reflection to determine whether the given property name is a custom property. A custom property is a non-model-specific property. Custom properties are written under the container element in the XML.

Parameters:
propertyName - the property name
Returns:
true, if checks if is custom property

isModelProperty

protected final boolean isModelProperty(String propertyName)
Uses reflection to determine whether the given property name is a model property. Model properties are written directly under the root element of the XML document.

Parameters:
propertyName - the property name
Returns:
true, if checks if is model property

getModelProperty

public final String getModelProperty(String propertyName)
Specified by:
getModelProperty in interface ModelObject

setModelProperty

public final void setModelProperty(String propertyName,
                                   String propertyValue)
Specified by:
setModelProperty in interface ModelObject

removeModelProperty

public final void removeModelProperty(String propertyName)
Specified by:
removeModelProperty in interface ModelObject

getCustomProperty

public final String getCustomProperty(String propertyName)
Specified by:
getCustomProperty in interface ModelObject

setCustomProperty

public final void setCustomProperty(String propertyName,
                                    String propertyValue)
Specified by:
setCustomProperty in interface ModelObject

removeCustomProperty

public final void removeCustomProperty(String propertyName)
Specified by:
removeCustomProperty in interface ModelObject

getProperties

public final Map<String,Serializable> getProperties()
Specified by:
getProperties in interface ModelObject

getModelProperties

public final Map<String,Serializable> getModelProperties()
Specified by:
getModelProperties in interface ModelObject

getCustomProperties

public final Map<String,Serializable> getCustomProperties()
Specified by:
getCustomProperties in interface ModelObject

getModificationTime

public final long getModificationTime()
Specified by:
getModificationTime in interface ModelObject

setModificationTime

public final void setModificationTime(long modificationTime)

touch

public final void touch()
Specified by:
touch in interface ModelObject

getTypeId

public abstract String getTypeId()
Description copied from interface: ModelObject
Returns the type id of the model object.

Specified by:
getTypeId in interface ModelObject
Returns:
The type id

toString

public String toString()
Overrides:
toString in class Object

getPersisterId

public final String getPersisterId()
Returns the ModelObjectPersister id that this object is bound to

Specified by:
getPersisterId in interface ModelObject

getStoragePath

public final String getStoragePath()
Returns the persistence storage path of this object

Specified by:
getStoragePath in interface ModelObject

getResource

public Resource getResource(String name)
Description copied from interface: ResourceProvider
Looks up a resource with the given name

Specified by:
getResource in interface ResourceProvider
Returns:

getResources

public Resource[] getResources()
Description copied from interface: ResourceProvider
Returns the set of all resources

Specified by:
getResources in interface ResourceProvider
Returns:

getResourcesMap

public Map<String,Resource> getResourcesMap()
Description copied from interface: ResourceProvider
Returns the map of resources

Specified by:
getResourcesMap in interface ResourceProvider
Returns:

addResource

public Resource addResource(String name,
                            String resourceId)
Description copied from interface: ResourceProvider
Adds/Creates a resource with the given name and resource id

Specified by:
addResource in interface ResourceProvider
Returns:
resource

addResource

public Resource addResource(String name,
                            String protocolId,
                            String endpointId,
                            String objectId)
Description copied from interface: ResourceProvider
Adds/Creates a resource with the given name, object id and endpoint id

Specified by:
addResource in interface ResourceProvider
Returns:
resource

updateResource

public void updateResource(String name,
                           Resource resource)
Description copied from interface: ResourceProvider
Updates a resource for the given name

Specified by:
updateResource in interface ResourceProvider

removeResource

public void removeResource(String name)
Description copied from interface: ResourceProvider
Removes a resource with the given name

Specified by:
removeResource in interface ResourceProvider

getResourceContainer

protected ResourceProvider getResourceContainer()

setId

public void setId(String id)
Allows for reassignment of the id of the object

Parameters:
id -


Copyright © 2009 SpringSource, Inc. All Rights Reserved.