org.compass.core.converter.basic
Class AbstractNumberConverter<N extends Number>

java.lang.Object
  extended by org.compass.core.converter.basic.AbstractBasicConverter<T>
      extended by org.compass.core.converter.basic.AbstractFormatConverter<N>
          extended by org.compass.core.converter.basic.AbstractNumberConverter<N>
All Implemented Interfaces:
CompassConfigurable, FormatConverter<N>, Converter<N>, ContextResourcePropertyConverter<N>, ResourcePropertyConverter<N>
Direct Known Subclasses:
AtomicIntConverter, AtomicLongConverter, BigDecimalConverter, BigIntegerConverter, DoubleConverter, FloatConverter, IntConverter, LongConverter, ShortConverter

public abstract class AbstractNumberConverter<N extends Number>
extends AbstractFormatConverter<N>
implements CompassConfigurable

A base class for number based converters. Allows for formatting (if specified) and for default behaviour handling if none is provided.

Author:
kimchy

Field Summary
static String SORTABLE_FORMAT
           
 
Fields inherited from class org.compass.core.converter.basic.AbstractFormatConverter
formatters, hasFormatter, locale
 
Constructor Summary
AbstractNumberConverter()
           
 
Method Summary
protected abstract  Formatter createSortableFormatter()
           
protected abstract  N defaultFromString(String str, ResourcePropertyMapping resourcePropertyMapping)
           
protected  String defaultToString(N o, ResourcePropertyMapping resourcePropertyMapping, MarshallingContext context)
           
protected  FormatterFactory doCreateFormatterFactory()
           
protected  N doFromString(String str, ResourcePropertyMapping resourcePropertyMapping, MarshallingContext context)
          Override the from String in order to un-marshall the String back into its object representation.
protected  String doToString(N o, ResourcePropertyMapping resourcePropertyMapping, MarshallingContext context)
          Allows to override to toString operation.
protected abstract  N fromNumber(Number number)
           
 
Methods inherited from class org.compass.core.converter.basic.AbstractFormatConverter
canNormalize, configure, copy, doGetDefaultFormat, setFormat, suggestIndex
 
Methods inherited from class org.compass.core.converter.basic.AbstractBasicConverter
createProperty, doSetBoost, fromString, fromString, getNullValue, handleNulls, isNullValue, marshall, suggestOmitNorms, suggestOmitTf, suggestStore, suggestTermVector, toString, toString, unmarshall
 
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.config.CompassConfigurable
configure
 
Methods inherited from interface org.compass.core.converter.mapping.ResourcePropertyConverter
fromString, suggestOmitNorms, suggestOmitTf, suggestStore, suggestTermVector, toString
 
Methods inherited from interface org.compass.core.converter.Converter
marshall, unmarshall
 

Field Detail

SORTABLE_FORMAT

public static final String SORTABLE_FORMAT
See Also:
Constant Field Values
Constructor Detail

AbstractNumberConverter

public AbstractNumberConverter()
Method Detail

doCreateFormatterFactory

protected FormatterFactory doCreateFormatterFactory()
Specified by:
doCreateFormatterFactory in class AbstractFormatConverter<N extends Number>

defaultFromString

protected abstract N defaultFromString(String str,
                                       ResourcePropertyMapping resourcePropertyMapping)

fromNumber

protected abstract N fromNumber(Number number)

createSortableFormatter

protected abstract Formatter createSortableFormatter()

doFromString

protected N doFromString(String str,
                         ResourcePropertyMapping resourcePropertyMapping,
                         MarshallingContext context)
                                 throws ConversionException
Description copied from class: AbstractBasicConverter
Override the from String in order to un-marshall the String back into its object representation.

Specified by:
doFromString in class AbstractBasicConverter<N extends Number>
Throws:
ConversionException

doToString

protected String doToString(N o,
                            ResourcePropertyMapping resourcePropertyMapping,
                            MarshallingContext context)
Description copied from class: AbstractBasicConverter
Allows to override to toString operation. Default implementation calls the object toString.

Note, the marshalling context might be null.

Overrides:
doToString in class AbstractBasicConverter<N extends Number>

defaultToString

protected String defaultToString(N o,
                                 ResourcePropertyMapping resourcePropertyMapping,
                                 MarshallingContext context)


Copyright (c) 2004-2009 The Compass Project.