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
           
static String ROOT_CLASS_MAPPING_KEY
           
 
Constructor Summary
ClassMappingConverter()
           
 
Method Summary
protected  Object constructObjectForUnmarshalling(ClassMapping classMapping, Resource resource)
          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)
           
protected  void storePolyClass(Resource resource, Object root, SearchEngine searchEngine, ClassMapping classMapping)
          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)
           
 
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
See Also:
Constant Field Values

DISABLE_INTERNAL_MAPPINGS

public static final String DISABLE_INTERNAL_MAPPINGS
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)
                                          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
Specified by:
marshallIds in interface ResourceMappingConverter
Throws:
ConversionException

unmarshallIds

public Object[] unmarshallIds(Object id,
                              ResourceMapping resourceMapping,
                              MarshallingContext context)
                       throws ConversionException
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,
                              SearchEngine searchEngine,
                              ClassMapping classMapping)
Stores the poly class name callback. Uses getPolyClassName(Object) in order to get the poly class and store it.

Parameters:
resource - The resource to add the poly class to
root - The root class to write its class name
searchEngine - The search engine to use
classMapping - The class mapping to use

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-2006 The Compass Project.