|
||||||||||
| 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 simpleProperty 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 | |
|---|---|
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 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. |
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
ConversionExceptionprotected boolean handleNulls(MarshallingContext context)
MarshallingContext.handleNulls()).
Extracted to a method so special converters can control null handling.
context -
true if the converter should handle null valuesprotected String getNullValue(MarshallingContext context)
null values (during the marshall process).
context -
nulls.
protected boolean isNullValue(MarshallingContext context,
String value)
null value
during the unmarshall process.
context - value - 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
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
public String toString(Object o,
ResourcePropertyMapping resourcePropertyMapping)
toString in interface ResourcePropertyConvertero - The Object to convert fromresourcePropertyMapping - The resource proeprty mapping
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||