|
||||||||||
| 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.
Allows to override the actual marshalling and un-marshalling of object to strings. In order to override
marshalling, override doToString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext)
and in order to override un-marshalling overrode
doFromString(String,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext).
| 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 abstract Object |
doFromString(String str,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Override the from String in order to un-marshall the String back into its object representation. |
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 |
doToString(Object o,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Allows to override to toString operation. |
Object |
fromString(String str,
ResourcePropertyMapping resourcePropertyMapping)
Calls fromString(String, org.compass.core.mapping.ResourcePropertyMapping, org.compass.core.marshall.MarshallingContext)
with a null value for the context. |
protected Object |
fromString(String str,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Performs null checks (by calling isNullValue(String, org.compass.core.mapping.ResourcePropertyMapping, org.compass.core.marshall.MarshallingContext))
and then calls doFromString(String, org.compass.core.mapping.ResourcePropertyMapping, org.compass.core.marshall.MarshallingContext)
if the value is not null. |
protected String |
getNullValue(ResourcePropertyMapping resourcePropertyMapping,
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(ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Should the converter handle nulls? |
protected boolean |
isNullValue(String value,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Does this value represents a null value. |
boolean |
marshall(Resource resource,
Object root,
Mapping mapping,
MarshallingContext context)
Marshall the given Object to the given Resource. |
Property.Index |
suggestIndex()
By default for all converters simply return null. |
Boolean |
suggestOmitNorms()
By default for all converters simply return null. |
Boolean |
suggestOmitTf()
By default for all converters simply return null. |
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)
Implementation calls toString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext)
with null value for the context parameter. |
protected String |
toString(Object o,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
Implementation handle nulls and if the object is not null, delegates to doToString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext). |
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 |
|---|
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(ResourcePropertyMapping resourcePropertyMapping,
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()).
If a specific null value is configured with the ResourcePropertyMapping
then the converter will always handle nulls and write it.
context - The marshalling context
true if the converter should handle null values
protected String getNullValue(ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
null values (during the marshall process). Uses
ResourcePropertyMapping.getNullValue().
resourcePropertyMapping - The resource proeprty mapping to get the null value fromcontext - The marshalling context
nulls.
protected boolean isNullValue(String value,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
ResourcePropertyMapping
is configured with a null value, then returns true if the null value equals the value read
from the index. If the resource property mapping is not configured with a null value, checks if this
it has the default value representing 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
public String toString(Object o,
ResourcePropertyMapping resourcePropertyMapping)
toString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext)
with null value for the context parameter.
Note, please don't override this method, please override doToString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext)
to change the how the object gets marshalled into a String.
toString in interface ResourcePropertyConvertero - The Object to convert fromresourcePropertyMapping - The resource proeprty mapping
protected String toString(Object o,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
doToString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext).
Note, please don't override this method, please override doToString(Object,org.compass.core.mapping.ResourcePropertyMapping,org.compass.core.marshall.MarshallingContext)
to change the how the object gets marshalled into a String.
protected String doToString(Object o,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
toString.
Note, the marshalling context might be null.
public Object fromString(String str,
ResourcePropertyMapping resourcePropertyMapping)
throws ConversionException
fromString(String, org.compass.core.mapping.ResourcePropertyMapping, org.compass.core.marshall.MarshallingContext)
with a null value for the context.
fromString in interface ResourcePropertyConverterstr - The string to convert fromresourcePropertyMapping - The resource property mapping
ConversionException
protected Object fromString(String str,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
throws ConversionException
isNullValue(String, org.compass.core.mapping.ResourcePropertyMapping, org.compass.core.marshall.MarshallingContext))
and then calls doFromString(String, org.compass.core.mapping.ResourcePropertyMapping, org.compass.core.marshall.MarshallingContext)
if the value is not null.
ConversionException
protected abstract Object doFromString(String str,
ResourcePropertyMapping resourcePropertyMapping,
MarshallingContext context)
throws ConversionException
ConversionExceptionpublic boolean canNormalize()
false. Specific parsers that can convert on query string should override this method
and return true.
canNormalize in interface ResourcePropertyConverterpublic Property.Index suggestIndex()
null.
suggestIndex in interface ResourcePropertyConverterpublic Property.TermVector suggestTermVector()
ResourcePropertyConverternull and will let global Compass defaults to be used.
suggestTermVector in interface ResourcePropertyConverterpublic Property.Store suggestStore()
ResourcePropertyConverternull and will let global Compass defaults to be used.
suggestStore in interface ResourcePropertyConverterpublic Boolean suggestOmitNorms()
null.
suggestOmitNorms in interface ResourcePropertyConverterpublic Boolean suggestOmitTf()
null.
suggestOmitTf in interface ResourcePropertyConverter
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||