org.compass.core.converter.basic
Class AbstractFormatConverter<T>

java.lang.Object
  extended by org.compass.core.converter.basic.AbstractBasicConverter<T>
      extended by org.compass.core.converter.basic.AbstractFormatConverter<T>
All Implemented Interfaces:
CompassConfigurable, FormatConverter<T>, Converter<T>, ContextResourcePropertyConverter<T>, ResourcePropertyConverter<T>
Direct Known Subclasses:
AbstractNumberConverter, DataTimeConverter, DateConverter

public abstract class AbstractFormatConverter<T>
extends AbstractBasicConverter<T>
implements CompassConfigurable, FormatConverter<T>

A base class that can handle ThreadSafeFormat and provide formatting support. The format is read from a configuration setting CompassEnvironment.Converter.Format#FORMAT. Uses a pool of formatters for better performance, using CompassEnvironment.Converter.Format#MIN_POOL_SIZE, and CompassEnvironment.Converter.Format#MAX_POOL_SIZE as configuration settings for the pool size.

If specific locale is required for the formatted, the CompassEnvironment.Converter.Format#LOCALE can be used to specify the required locale.

Allows to specify the default format if none is provided by overriding doGetDefaultFormat().

Author:
kimchy

Field Summary
protected  Formatter[] formatters
           
protected  boolean hasFormatter
           
protected  Locale locale
           
 
Constructor Summary
AbstractFormatConverter()
           
 
Method Summary
 boolean canNormalize()
          Format based converters should can be used (and should) when using query parser notation.
 void configure(CompassSettings settings)
          Configure using the given settings.
 FormatConverter copy()
          Returns a copy of the format converter.
protected abstract  FormatterFactory doCreateFormatterFactory()
           
protected  String doGetDefaultFormat()
           
 void setFormat(String format)
          Sets the format for the Converter.
 Property.Index suggestIndex()
          Formattable types should usually be Property.Index.NOT_ANALYZED.
 
Methods inherited from class org.compass.core.converter.basic.AbstractBasicConverter
createProperty, doFromString, doSetBoost, doToString, 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.converter.mapping.ResourcePropertyConverter
fromString, suggestOmitNorms, suggestOmitTf, suggestStore, suggestTermVector, toString
 
Methods inherited from interface org.compass.core.converter.Converter
marshall, unmarshall
 

Field Detail

formatters

protected Formatter[] formatters

hasFormatter

protected boolean hasFormatter

locale

protected Locale locale
Constructor Detail

AbstractFormatConverter

public AbstractFormatConverter()
Method Detail

configure

public void configure(CompassSettings settings)
               throws CompassException
Description copied from interface: CompassConfigurable
Configure using the given settings.

Specified by:
configure in interface CompassConfigurable
Parameters:
settings - The settings for the configured object
Throws:
CompassException

setFormat

public void setFormat(String format)
Description copied from interface: FormatConverter
Sets the format for the Converter.

Specified by:
setFormat in interface FormatConverter<T>

copy

public FormatConverter copy()
Description copied from interface: FormatConverter
Returns a copy of the format converter.

Specified by:
copy in interface FormatConverter<T>

doCreateFormatterFactory

protected abstract FormatterFactory doCreateFormatterFactory()

doGetDefaultFormat

protected String doGetDefaultFormat()

canNormalize

public boolean canNormalize()
Format based converters should can be used (and should) when using query parser notation. Returns true.

Specified by:
canNormalize in interface ResourcePropertyConverter<T>
Overrides:
canNormalize in class AbstractBasicConverter<T>

suggestIndex

public Property.Index suggestIndex()
Formattable types should usually be Property.Index.NOT_ANALYZED.

Specified by:
suggestIndex in interface ResourcePropertyConverter<T>
Overrides:
suggestIndex in class AbstractBasicConverter<T>


Copyright (c) 2004-2009 The Compass Project.