|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.compass.core.converter.basic.AbstractBasicConverter
public abstract class AbstractBasicConverter
An easy to use abstact class for Basic converters. Handles converters that usually deals with String as a result of the conversion.
This base class will create a simple Property when marshalling,
calling toString(Object,org.compass.core.mapping.ResourcePropertyMapping) as the Property
value. And will use the ResourcePropertyConverter.fromString(String,org.compass.core.mapping.ResourcePropertyMapping) when
unmarhslling.
If special null values handling is required, the
handleNulls(org.compass.core.marshall.MarshallingContext), and
getNullValue(org.compass.core.marshall.MarshallingContext) can be overriden. Note, that it is best
to call base implementations and extend the base funtionallity, since the base class takes special care
when using collections.
| Constructor Summary | |
|---|---|
AbstractBasicConverter()
|
|
| Method Summary | |
|---|---|
boolean |
canNormalize()
Return false. |
protected Property |
createProperty(String value,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Creates a new property to be added to the resource during the marshalling process. |
protected void |
doSetBoost(Property property,
Object root,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
A simple extension point that allows to set the boost value for the created Property. |
protected Object |
fromString(String str,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
An override option default to calling ResourcePropertyConverter.fromString(String,org.compass.core.mapping.ResourcePropertyMapping). |
protected String |
getNullValue(MarshallingContext context)
If the converter handle nulls, the value that will be stored in the search engine for null values (during the marshall process). |
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. |
String |
toString(Object o,
ResourcePropertyMapping resourcePropertyMapping)
Default implementation of toString, simply calls the Object toString. |
protected String |
toString(Object o,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Override option of toString, simply calls toString(Object,org.compass.core.mapping.ResourcePropertyMapping)
(without the marshalling context). |
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 |
| Methods inherited from interface org.compass.core.converter.ResourcePropertyConverter |
|---|
fromString |
| Constructor Detail |
|---|
public AbstractBasicConverter()
| Method Detail |
|---|
public boolean marshall(Resource resource,
Object root,
Mapping mapping,
MarshallingContext context)
throws ConversionException
ConverterObject 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).
marshall in interface Converterresource - The resource to marhsall the object toroot - The Object to marshall to the resourcemapping - The mapping definition of how to marshall the Object to the resorucecontext - The context for the current marhslling process
true if data was saved in the the index that can be read.
ConversionException
public Object unmarshall(Resource resource,
Mapping mapping,
MarshallingContext context)
throws ConversionException
ConverterResource to the appropiate Object.
unmarshall in interface Converterresource - The resource to unmarshall into an Objectmapping - The mapping definition of how to unmarshall the Resource into an Objectcontext - The context for the current marshalling process
ConversionException
protected Property createProperty(String value,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
value - The value of the propertyresourcePropertyMapping - The resource mapping definition of the propertycontext - The context (allows to get the search engine from it)
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.
context - The marshalling context
true if the converter should handle null valuesprotected String getNullValue(MarshallingContext context)
null values (during the marshall process).
context - The marshalling context
nulls.
protected boolean isNullValue(MarshallingContext context,
String value)
null value
during the unmarshall process.
context - The marshalling contextvalue - The value to check for null value.
true if the value represents a null value.
protected void doSetBoost(Property property,
Object root,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
throws ConversionException
A simple extension point that allows to set the boost value for the created Property.
The default implemenation uses the statically defined boost value in the mapping definition
(ResourcePropertyMapping.getBoost()) to set the boost level
using Property.setBoost(float)
property - The property to set the boost onroot - The object that is marshalled into a propertyresourcePropertyMapping - The Resource Property Mapping definition
ConversionException
protected String toString(Object o,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
toString(Object,org.compass.core.mapping.ResourcePropertyMapping)
(without the marshalling context).
public String toString(Object o,
ResourcePropertyMapping resourcePropertyMapping)
toString in interface ResourcePropertyConvertero - The Object to convert fromresourcePropertyMapping - The resource proeprty mapping
protected Object fromString(String str,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
throws ConversionException
ResourcePropertyConverter.fromString(String,org.compass.core.mapping.ResourcePropertyMapping).
Allows to use the marshalling context.
ConversionExceptionpublic boolean canNormalize()
false. Specific parsers that can convert on query string should override this method
and return true.
canNormalize in interface ResourcePropertyConverter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||