org.compass.core.converter.basic
Class AbstractFormatConverter

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

public abstract class AbstractFormatConverter
extends AbstractBasicConverter
implements CompassConfigurable, FormatConverter

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

copy

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

Specified by:
copy in interface FormatConverter

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
Overrides:
canNormalize in class AbstractBasicConverter

suggestIndex

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

Specified by:
suggestIndex in interface ResourcePropertyConverter
Overrides:
suggestIndex in class AbstractBasicConverter


Copyright (c) 2004-2008 The Compass Project.