org.compass.core.converter.mapping.xsem
Class XmlContentMappingConverter

java.lang.Object
  extended by org.compass.core.converter.mapping.xsem.XmlContentMappingConverter
All Implemented Interfaces:
CompassConfigurable, Converter

public class XmlContentMappingConverter
extends Object
implements Converter, CompassConfigurable

Handles xml content mapping definition. Saves the raw xml content from XmlObject into the search engine, and unmarshalls raw xml content into XmlObject.

In order to perform the conversion between XmlObject and raw xml, the converter uses a XmlContentConverter implementation. There is no default one, and it must be cofigured for this converter to funtion using CompassEnvironment.Xsem.XmlContent#TYPE).

{@link XmlContentConverter} implementations are wrapped by one of the three built in strategies: {@link PrototypeXmlContentConverterWrapper}, {@link PoolXmlContentConverterWrapper}, {@link SingletonXmlContentConverterWrapper}, or a user provided fully qualified class name.

Author:
kimchy

Constructor Summary
XmlContentMappingConverter()
           
 
Method Summary
 void configure(CompassSettings settings)
          Configure using the given settings.
 XmlContentConverter getXmlContentConverter()
           
protected  boolean handleNulls(MarshallingContext context)
          Should the converter handle nulls?
protected  boolean isNullValue(MarshallingContext context, String value)
          Is the value read from the search engine is a null value during the unmarshall process.
 boolean marshall(Resource resource, Object root, Mapping mapping, MarshallingContext context)
          Marshall the given Object to the given Resource.
 Object unmarshall(Resource resource, Mapping mapping, MarshallingContext context)
          Unmarshall the given Resource to the appropiate Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlContentMappingConverter

public XmlContentMappingConverter()
Method Detail

configure

public void configure(CompassSettings settings)
               throws CompassException
Description copied from interface: CompassConfigurable
Configure using the given settings.

Specified by:
configure in interface CompassConfigurable
Parameters:
settings - The settings for the configured object
Throws:
CompassException

getXmlContentConverter

public XmlContentConverter getXmlContentConverter()

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

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

handleNulls

protected boolean handleNulls(MarshallingContext context)
Should the converter handle nulls? Handling nulls means should the converter process nulls or not. Usually the converter will not persist null values, but sometimes it might be needed (MarshallingContext.handleNulls()).

Extracted to a method so special converters can control null handling.

Parameters:
context - The marshalling context
Returns:
true if the converter should handle null values

isNullValue

protected boolean isNullValue(MarshallingContext context,
                              String value)
Is the value read from the search engine is a null value during the unmarshall process.

Parameters:
context - The marshalling context
value - The value to check for null value.
Returns:
true if the value represents a null value.


Copyright (c) 2004-2009 The Compass Project.