org.compass.core.converter.mapping.support
Class FormatDelegateConverter

java.lang.Object
  extended by org.compass.core.converter.mapping.support.FormatDelegateConverter
All Implemented Interfaces:
Converter, DelegateConverter, ResourcePropertyConverter

public class FormatDelegateConverter
extends Object
implements DelegateConverter, ResourcePropertyConverter

A format delegate converter, that creates its own intenral format converter based on the format that it is initalized with.

Author:
kimchy

Constructor Summary
FormatDelegateConverter(String format)
           
 
Method Summary
 boolean canNormalize()
          Returns true if this converter should be used to convert query parser related values.
 Object fromString(String str, ResourcePropertyMapping resourcePropertyMapping)
          Converts from a String and into it's Object representation.
 Converter getDelegatedConverter()
           
 boolean marshall(Resource resource, Object root, Mapping mapping, MarshallingContext context)
          Marshall the given Object to the given Resource.
 void setDelegatedConverter(Converter delegatedConverter)
          Sets a delegated format converter.
 Property.Index suggestIndex()
          The converter can suggest what type of index will be used in case no index is configured.
 Boolean suggestOmitNorms()
          The converter can suggest if norms should be saved for this type in case no explicit one is configured.
 Boolean suggestOmitTf()
          The converter can suggest if tf should be saved for this type in case no explicit one is configured.
 Property.Store suggestStore()
          The converter can suggest the store type for this type in case no explicit one is configured.
 Property.TermVector suggestTermVector()
          The converter can suggest if term vectors should be saved for this type in case no explicit one is configured.
 String toString(Object o, ResourcePropertyMapping resourcePropertyMapping)
          Converts the Object into a String.
 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

FormatDelegateConverter

public FormatDelegateConverter(String format)
Method Detail

setDelegatedConverter

public void setDelegatedConverter(Converter delegatedConverter)
Sets a delegated format converter. Will not use the actual passed converter, but will use FormatConverter.copy() to create a new format converter.

Specified by:
setDelegatedConverter in interface DelegateConverter

getDelegatedConverter

public Converter getDelegatedConverter()
Specified by:
getDelegatedConverter in interface DelegateConverter

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

fromString

public Object fromString(String str,
                         ResourcePropertyMapping resourcePropertyMapping)
                  throws ConversionException
Description copied from interface: ResourcePropertyConverter
Converts from a String and into it's Object representation.

Specified by:
fromString in interface ResourcePropertyConverter
Parameters:
str - The string to convert from
resourcePropertyMapping - The resource property mapping
Returns:
Theh object converterd from the String
Throws:
ConversionException

toString

public String toString(Object o,
                       ResourcePropertyMapping resourcePropertyMapping)
                throws ConversionException
Description copied from interface: ResourcePropertyConverter
Converts the Object into a String.

Note that toString must be able to handle a null resourcePropertyMapping.

Specified by:
toString in interface ResourcePropertyConverter
Parameters:
o - The Object to convert from
resourcePropertyMapping - The resource proeprty mapping
Returns:
The String converted from the Object
Throws:
ConversionException

canNormalize

public boolean canNormalize()
Description copied from interface: ResourcePropertyConverter
Returns true if this converter should be used to convert query parser related values. Conversion is done by calling ResourcePropertyConverter.fromString(String, org.compass.core.mapping.ResourcePropertyMapping) and then ResourcePropertyConverter.toString(Object, org.compass.core.mapping.ResourcePropertyMapping).

Specified by:
canNormalize in interface ResourcePropertyConverter

suggestIndex

public Property.Index suggestIndex()
Description copied from interface: ResourcePropertyConverter
The converter can suggest what type of index will be used in case no index is configured. Can return null and will let global Compass defaults to be used.

Specified by:
suggestIndex in interface ResourcePropertyConverter

suggestTermVector

public Property.TermVector suggestTermVector()
Description copied from interface: ResourcePropertyConverter
The converter can suggest if term vectors should be saved for this type in case no explicit one is configured. Can return null and will let global Compass defaults to be used.

Specified by:
suggestTermVector in interface ResourcePropertyConverter

suggestStore

public Property.Store suggestStore()
Description copied from interface: ResourcePropertyConverter
The converter can suggest the store type for this type in case no explicit one is configured. Can return null and will let global Compass defaults to be used.

Specified by:
suggestStore in interface ResourcePropertyConverter

suggestOmitNorms

public Boolean suggestOmitNorms()
Description copied from interface: ResourcePropertyConverter
The converter can suggest if norms should be saved for this type in case no explicit one is configured. Can return null and will let global Compass defaults to be used.

Specified by:
suggestOmitNorms in interface ResourcePropertyConverter

suggestOmitTf

public Boolean suggestOmitTf()
Description copied from interface: ResourcePropertyConverter
The converter can suggest if tf should be saved for this type in case no explicit one is configured. Can return null and will let global Compass defaults to be used.

Specified by:
suggestOmitTf in interface ResourcePropertyConverter


Copyright (c) 2004-2008 The Compass Project.