org.compass.core.converter.mapping.osem
Class ClassMappingConverter

java.lang.Object
  extended by org.compass.core.converter.mapping.osem.ClassMappingConverter
All Implemented Interfaces:
Converter, ResourceMappingConverter

public class ClassMappingConverter
extends Object
implements ResourceMappingConverter

Author:
kimchy

Nested Class Summary
protected static class ClassMappingConverter.IdentityAliasedObjectKey
          An object key based on the alias and the object identity hash code
protected static class ClassMappingConverter.IdsAliasesObjectKey
          An object key based on the alias and its ids values
 
Field Summary
static String DISABLE_INTERNAL_MAPPINGS
          Disable internal mappings is a marker within the context if internal mappings should not be marshalled.
static String DISABLE_UID_MARSHALLING
           
static String ROOT_CLASS_MAPPING_KEY
          Under this key within the context the root class mapping can be found.
 
Constructor Summary
ClassMappingConverter()
           
 
Method Summary
protected  Object constructObjectForUnmarshalling(ClassMapping classMapping, Resource resource, MarshallingContext context)
          Constructs the object used for unmarshalling (no properties are set/unmarshalled) on it.
protected  boolean doMarshall(Resource resource, Object root, Mapping mapping, MarshallingContext context)
           
protected  void doSetBoost(Resource resource, Object root, ClassMapping classMapping, MarshallingContext context)
          A simple extension point that allows to set the boost value for the created Resource.
protected  String getPolyClassName(Object root)
          An extension point allowing to get the poly class name if need to be stored.
 boolean marshall(Resource resource, Object root, Mapping mapping, MarshallingContext context)
          Marshall the given Object to the given Resource.
 boolean marshallIds(Resource idResource, Object id, ResourceMapping resourceMapping, MarshallingContext context)
          Marshalls teh given Object id into the given resource.
protected  void storePolyClass(Resource resource, Object root, ClassMapping classMapping, MarshallingContext context)
          Stores the poly class name callback.
 Object unmarshall(Resource resource, Mapping mapping, MarshallingContext context)
          Unmarshall the given Resource to the appropiate Object.
 Object[] unmarshallIds(Object id, ResourceMapping resourceMapping, MarshallingContext context)
          Unamrshalls the given id into its id properties values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_CLASS_MAPPING_KEY

public static final String ROOT_CLASS_MAPPING_KEY
Under this key within the context the root class mapping can be found.

See Also:
Constant Field Values

DISABLE_INTERNAL_MAPPINGS

public static final String DISABLE_INTERNAL_MAPPINGS
Disable internal mappings is a marker within the context if internal mappings should not be marshalled.

Internal mappings are disabled for inner components (not root classes) when support unmarshall is set to false.

See Also:
Constant Field Values

DISABLE_UID_MARSHALLING

public static final String DISABLE_UID_MARSHALLING
See Also:
Constant Field Values
Constructor Detail

ClassMappingConverter

public ClassMappingConverter()
Method Detail

marshall

public boolean marshall(Resource resource,
                        Object root,
                        Mapping mapping,
                        MarshallingContext context)
                 throws ConversionException
Description copied from interface: Converter
Marshall the given Object to the given Resource. Will use the mapping definition as to how to marshall the object.

Returns true if data was saved in the index, and it can be read as well (i.e. stored).

Specified by:
marshall in interface Converter
Parameters:
resource - The resource to marhsall the object to
root - The Object to marshall to the resource
mapping - The mapping definition of how to marshall the Object to the resoruce
context - The context for the current marhslling process
Returns:
true if data was saved in the the index that can be read.
Throws:
ConversionException

doMarshall

protected boolean doMarshall(Resource resource,
                             Object root,
                             Mapping mapping,
                             MarshallingContext context)
                      throws ConversionException
Throws:
ConversionException

unmarshall

public Object unmarshall(Resource resource,
                         Mapping mapping,
                         MarshallingContext context)
                  throws ConversionException
Description copied from interface: Converter
Unmarshall the given Resource to the appropiate Object.

Specified by:
unmarshall in interface Converter
Parameters:
resource - The resource to unmarshall into an Object
mapping - The mapping definition of how to unmarshall the Resource into an Object
context - The context for the current marshalling process
Returns:
The object unmarshalled
Throws:
ConversionException

constructObjectForUnmarshalling

protected Object constructObjectForUnmarshalling(ClassMapping classMapping,
                                                 Resource resource,
                                                 MarshallingContext context)
                                          throws ConversionException
Constructs the object used for unmarshalling (no properties are set/unmarshalled) on it. null return value denotes no un-marshalling should be performed.

Throws:
ConversionException

marshallIds

public boolean marshallIds(Resource idResource,
                           Object id,
                           ResourceMapping resourceMapping,
                           MarshallingContext context)
                    throws ConversionException
Description copied from interface: ResourceMappingConverter
Marshalls teh given Object id into the given resource. Returns true if anything was was stored in the resource.

Specified by:
marshallIds in interface ResourceMappingConverter
Throws:
ConversionException

unmarshallIds

public Object[] unmarshallIds(Object id,
                              ResourceMapping resourceMapping,
                              MarshallingContext context)
                       throws ConversionException
Description copied from interface: ResourceMappingConverter
Unamrshalls the given id into its id properties values.

Specified by:
unmarshallIds in interface ResourceMappingConverter
Throws:
ConversionException

doSetBoost

protected void doSetBoost(Resource resource,
                          Object root,
                          ClassMapping classMapping,
                          MarshallingContext context)
                   throws ConversionException
A simple extension point that allows to set the boost value for the created Resource.

The default implemenation uses the statically defined boost value in the mapping definition (AbstractResourceMapping.getBoost()) to set the boost level using Resource.setBoost(float)

Note, that this method will only be called on a root level (root=true) mapping.

Parameters:
resource - The resource to set the boost on
root - The Object that is marshalled into the respective Resource
classMapping - The Class Mapping deifnition
context - The marshalling context
Throws:
ConversionException

storePolyClass

protected void storePolyClass(Resource resource,
                              Object root,
                              ClassMapping classMapping,
                              MarshallingContext context)
Stores the poly class name callback. Uses getPolyClassName(Object) in order to get the poly class and store it.


getPolyClassName

protected String getPolyClassName(Object root)
An extension point allowing to get the poly class name if need to be stored. By defaults uses Class.getName().



Copyright (c) 2004-2008 The Compass Project.