net.sf.mmm.util.nls.impl.formatter
Class NlsMessageFormatterImpl

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.nls.base.AbstractNlsFormatter<Void>
              extended by net.sf.mmm.util.nls.base.AbstractNlsMessageFormatter
                  extended by net.sf.mmm.util.nls.impl.formatter.NlsMessageFormatterImpl
All Implemented Interfaces:
NlsFormatter<Void>, NlsMessageFormatter

public class NlsMessageFormatterImpl
extends AbstractNlsMessageFormatter

This is the implementation of the NlsMessageFormatter interface.
NOTE:
This is more or less a rewrite of MessageFormat and is syntax-compatible with the MessageFormat-pattern -format. Some special (and somewhat sick) features as modifying internal Formats or FieldPosition are NOT supported. Currently also parsing is NOT supported.
Instead this implementation is immutable and thread-safe. Further it works on any Appendable rather than only on StringBuffer. It also uses the same Appendable for recursive invocations.

Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Nested Class Summary
protected static class NlsMessageFormatterImpl.PatternSegment
          This inner class represents a segment out of the parsed message-pattern.
 
Field Summary
private  NlsDependencies nlsDependnecies
          The NlsDependencies to use.
private  NlsMessageFormatterImpl.PatternSegment[] segments
          The parsed segments of the message pattern.
private  String suffix
          The suffix (last segment) of the pattern.
 
Fields inherited from class net.sf.mmm.util.nls.base.AbstractNlsMessageFormatter
SYNTAX
 
Constructor Summary
NlsMessageFormatterImpl(String pattern, NlsDependencies nlsDependencies)
          The constructor.
 
Method Summary
 void format(Void nothing, Locale locale, Map<String,Object> arguments, NlsTemplateResolver resolver, Appendable buffer)
          This method formats the underlying pattern by filling in the given arguments and writing the result into the given buffer.
 
Methods inherited from class net.sf.mmm.util.nls.base.AbstractNlsFormatter
format
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
doInitialize, getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.util.nls.api.NlsFormatter
format
 

Field Detail

segments

private final NlsMessageFormatterImpl.PatternSegment[] segments
The parsed segments of the message pattern.


suffix

private final String suffix
The suffix (last segment) of the pattern.


nlsDependnecies

private final NlsDependencies nlsDependnecies
The NlsDependencies to use.

Constructor Detail

NlsMessageFormatterImpl

public NlsMessageFormatterImpl(String pattern,
                               NlsDependencies nlsDependencies)
The constructor.

Parameters:
pattern - is the pattern of the message to format. It is syntax-compatible with MessageFormat.
nlsDependencies - are the NlsDependencies.
Method Detail

format

public final void format(Void nothing,
                         Locale locale,
                         Map<String,Object> arguments,
                         NlsTemplateResolver resolver,
                         Appendable buffer)
                  throws IOException
This method formats the underlying pattern by filling in the given arguments and writing the result into the given buffer. This method formats the given object according to the given locale.

Parameters:
nothing - has to be null. Only for generic compatibility.
locale - is the locale used for localized formatting.
arguments - is the Map of arguments.
resolver - is the NlsTemplateResolver.
buffer - is where to append the formatted object.
Throws:
IOException - if the given Appendable caused such exception.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.