com.flexive.shared.value.renderer
Class FxValueRendererImpl

java.lang.Object
  extended by com.flexive.shared.value.renderer.FxValueRendererImpl
All Implemented Interfaces:
FxValueRenderer

 class FxValueRendererImpl
extends java.lang.Object
implements FxValueRenderer

Default FxValue renderer implementation for a specific language. Forwards requests to an internal map of FxValueFormatter instances.

This renderer stores the target language and a map of FxValueFormatter instances that can be used to override the default formatters. The renderers returned by the FxValueRendererFactory do not use this functionality, but use the standard formatters for all instances.

Note:: this class is deliberately not public, since this would allow static renderer instances to be manipulated through the put(java.lang.Class, com.flexive.shared.value.renderer.FxValueFormatter) method.

Version:
$Rev: 662 $
Author:
Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Constructor Summary
FxValueRendererImpl()
          Create a new renderer in the calling user's language.
FxValueRendererImpl(FxLanguage language)
          Create a new renderer for the given language.
 
Method Summary
 java.lang.String format(FxValue value)
          Formats the given value in the renderer's locale.
 java.lang.String format(FxValue value, FxLanguage translationLanguage)
          Formats the given value in the renderer's locale.
(package private)  FxValueFormatter get(java.lang.Class valueType)
           
(package private)
<DT,T extends FxValue<DT,T>>
void
put(java.lang.Class<T> type, FxValueFormatter<DT,T> formatter)
           
 FxValueRenderer render(java.io.Writer out, FxValue value)
          Renders the given value in the renderer's locale to the output writer.
 FxValueRenderer render(java.io.Writer out, FxValue value, FxLanguage translationLanguage)
          Renders the given value in the renderer's locale to the output writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FxValueRendererImpl

FxValueRendererImpl(FxLanguage language)
Create a new renderer for the given language.

Parameters:
language - the language

FxValueRendererImpl

FxValueRendererImpl()
Create a new renderer in the calling user's language.

Method Detail

format

public java.lang.String format(FxValue value)
Formats the given value in the renderer's locale. If value is multi-lingual, then the translation in the renderer's locale is used. If no translation is available, the default translation is used (see FxValue.getBestTranslation() }).

Specified by:
format in interface FxValueRenderer
Parameters:
value - the value to be formatted
Returns:
the formatted value

format

public java.lang.String format(FxValue value,
                               FxLanguage translationLanguage)
Formats the given value in the renderer's locale. If value is multi-lingual, then the translation for the given translationLanguage is used. If no translation is available, the default translation is used (see FxValue.getBestTranslation() }).

Specified by:
format in interface FxValueRenderer
Parameters:
value - the value to be formatted
translationLanguage - the translation which should be retrieved from the value
Returns:
the formatted value

render

public FxValueRenderer render(java.io.Writer out,
                              FxValue value)
                       throws java.io.IOException
Renders the given value in the renderer's locale to the output writer. If value is multi-lingual, then the translation in the renderer's locale is used. If no translation is available, the default translation is used (see FxValue.getBestTranslation() }).

Specified by:
render in interface FxValueRenderer
Parameters:
out - the output writer
value - the value to be rendered
Returns:
the FxValueRenderer instance
Throws:
java.io.IOException - if the value could not be written

render

public FxValueRenderer render(java.io.Writer out,
                              FxValue value,
                              FxLanguage translationLanguage)
                       throws java.io.IOException
Renders the given value in the renderer's locale to the output writer. If value is multi-lingual, then the translation for the given translationLanguage is used. If no translation is available, the default translation is used (see FxValue.getBestTranslation() }).

Specified by:
render in interface FxValueRenderer
Parameters:
out - the output writer
value - the value to be rendered
translationLanguage - the translation which should be retrieved from the value
Returns:
the FxValueRenderer instance
Throws:
java.io.IOException - if the value could not be written

put

<DT,T extends FxValue<DT,T>> void put(java.lang.Class<T> type,
                                      FxValueFormatter<DT,T> formatter)

get

FxValueFormatter get(java.lang.Class valueType)