org.apache.sling.jcr.ocm
Class DefaultMappedObject

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by org.apache.sling.jcr.ocm.DefaultMappedObject
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class DefaultMappedObject
extends HashMap<String,Object>

The DefaultMappedObject is used by the JCR based resource manager implemented by this bundle as a default to map JCR nodes. This class has the following features:

Reserved Properties

The following is a list of reserved properties and their meanings. These properties should not be modified through the getters and setters.

path
The path of the node underlying this instance.
primaryType
The primary node type of the node underlying this instance. This property is read-only. Any modifications will not be stored in the node (of course). For newly created objects, this property is not used to indicate the desired node type.
mixinTypes
The list of mixin node types of the node underlying this instance. This property is read-only. Any modifications will not be stored in the node. For newly created objects, this property is not used to indicate the desired mixin node types.
properties
The map representing the properties of this content object itself.

Mapping JCR Property types

Property type to Java types
JCR Type Java Type
STRING String
DATE String
BINARY java.io.InputStream
DOUBLE java.lang.Double
LONG java.lang.Long
BOOLEAN java.lang.Boolean
NAME String
PATH String
REFERENCE String
Java type to Property type
Java Type JCR Type
String STRING
java.util.Date DATE
java.util.Calendar DATE
java.util.GregorianCalendar DATE
java.io.InputStream BINARY
java.lang.Double DOUBLE
java.lang.Long LONG
java.lang.Integer LONG
java.lang.Boolean BOOLEAN

See Also:
Serialized Form

Constructor Summary
DefaultMappedObject()
           
 
Method Summary
 boolean containsKey(String key)
          Returns true if this map contains the named property.
 Object get(String key)
          Returns the value of the indexed property.
 ArrayList<String> getMixinTypes()
          Returns a list of the mixin node typse of the underlying node or null for new objects or if the node has no mixin node types.
 String getPath()
          Returns the path of this mapped object.
 String getPrimaryType()
          Returns the primary node type of the underlying node or null for new objects.
 org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap getProperties()
          Returns the properties of this content to be written to the properties of the repository node.
 Object put(String key, Object value)
          Sets the value of the indexed property.
 void setMixinTypes(ArrayList<String> mixinTypes)
          Sets the mixin node types of the underlying node.
 void setPath(String path)
          Sets the path of this mapped object.
 void setPrimaryType(String type)
          Sets the primary node type of the underlying node.
 void setProperties(org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap contents)
          Sets the properties of this content object as read from the properties of the repository node.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

DefaultMappedObject

public DefaultMappedObject()
Method Detail

get

public Object get(String key)
Returns the value of the indexed property.

For the special property properties the getProperties() method is called to return a copy of this map instead of looking in the map itself.

Parameters:
key - The index of the property to return.
Returns:
the indicated property or null if the map does not contain it.

put

public Object put(String key,
                  Object value)
Sets the value of the indexed property.

For the special property properties the #setProperties(ManagedHashMap) method is called to insert all elements of the value which must be a Map into this map.

Specified by:
put in interface Map<String,Object>
Overrides:
put in class HashMap<String,Object>
Parameters:
key - The index of the property to set
value - The value of the property to set.
Returns:
The former value of the property or null if the property is new.
Throws:
ClassCastException - If the type of the value is ManagedHashMap for the properties property.

containsKey

public boolean containsKey(String key)
Returns true if this map contains the named property.


setPath

public void setPath(String path)
Sets the path of this mapped object.


getPath

public String getPath()
Returns the path of this mapped object.


setProperties

public void setProperties(org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap contents)
Sets the properties of this content object as read from the properties of the repository node.

This method copies the properties of the contents map into this map instance.


getProperties

public org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap getProperties()
Returns the properties of this content to be written to the properties of the repository node.

The contents of the returned map replace all non-protected properties of the repository. That is, existing properties not contained in the map will be removed.

This method returns a new instance of a ManagedHashMap containing a copy of the current properties on each call.


setPrimaryType

public void setPrimaryType(String type)
Sets the primary node type of the underlying node.

This method should only be called by the Graffito Mapper to set the type read from the node.


getPrimaryType

public String getPrimaryType()
Returns the primary node type of the underlying node or null for new objects.


setMixinTypes

public void setMixinTypes(ArrayList<String> mixinTypes)
Sets the mixin node types of the underlying node.

This method should only be called by the Graffito Mapper to set the types read from the node.


getMixinTypes

public ArrayList<String> getMixinTypes()
Returns a list of the mixin node typse of the underlying node or null for new objects or if the node has no mixin node types.



Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.