org.apache.sling.jcr.ocm
Class DefaultMappedObject

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

public class DefaultMappedObject
extends java.util.HashMap<java.lang.String,java.lang.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

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
DefaultMappedObject()
           
 
Method Summary
 boolean containsKey(java.lang.String key)
          Returns true if this map contains the named property.
 java.lang.Object get(java.lang.String key)
          Returns the value of the indexed property.
 java.util.ArrayList<java.lang.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.
 java.lang.String getPath()
          Returns the path of this mapped object.
 java.lang.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.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Sets the value of the indexed property.
 void setMixinTypes(java.util.ArrayList<java.lang.String> mixinTypes)
          Sets the mixin node types of the underlying node.
 void setPath(java.lang.String path)
          Sets the path of this mapped object.
 void setPrimaryType(java.lang.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 java.lang.Object get(java.lang.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 java.lang.Object put(java.lang.String key,
                            java.lang.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 java.util.Map<java.lang.String,java.lang.Object>
Overrides:
put in class java.util.HashMap<java.lang.String,java.lang.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:
java.lang.ClassCastException - If the type of the value is ManagedHashMap for the properties property.

containsKey

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


setPath

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


getPath

public java.lang.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(java.lang.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 java.lang.String getPrimaryType()
Returns the primary node type of the underlying node or null for new objects.


setMixinTypes

public void setMixinTypes(java.util.ArrayList<java.lang.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 java.util.ArrayList<java.lang.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-2009. All Rights Reserved.