net.sf.mmm.util.nls.base
Class NlsWriter

java.lang.Object
  extended by java.io.Writer
      extended by net.sf.mmm.util.io.base.AppendableWriter
          extended by net.sf.mmm.util.nls.base.NlsWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable

public class NlsWriter
extends AppendableWriter

An NlsWriter is a Writer, that writes the localized message of the given text. In other words everything that is written here (except via printRaw(CharSequence) and printlnRaw(CharSequence)) gets translated via NlsMessage.

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

Field Summary
private  Map<String,Object> arguments
           
private  Locale locale
          The Locale to translate to.
private  NlsMessageFactory messageFactory
          The NlsMessageFactory.
private  String newline
          The string used to terminate a line.
private  NlsTemplateResolver resolver
          The NlsTemplateResolver.
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
NlsWriter(Appendable appendable)
          The constructor.
NlsWriter(Appendable appendable, Map<String,Object> arguments)
          The constructor.
NlsWriter(Appendable appendable, Map<String,Object> arguments, Locale locale)
          The constructor.
NlsWriter(Appendable appendable, Map<String,Object> arguments, Locale locale, String newline)
          The constructor.
NlsWriter(Appendable appendable, Map<String,Object> arguments, Locale locale, String newline, NlsMessageFactory messageFactory)
          The constructor.
NlsWriter(Appendable appendable, Map<String,Object> arguments, Locale locale, String newline, NlsMessageFactory messageFactory, NlsTemplateResolver resolver)
          The constructor.
 
Method Summary
 NlsWriter append(CharSequence csq)
          
 NlsWriter append(CharSequence csq, int start, int end)
          
 Map<String,Object> getArguments()
          This method gets the arguments for the created NlsMessages.
 void print(CharSequence csq)
          This method is the same as append(CharSequence) or AppendableWriter.write(String).
 void print(NlsMessage message)
          This method writes an NlsMessage.
 void println()
          This method writes a newline (line-separator).
 void println(CharSequence csq)
          This method is like append(CharSequence) or AppendableWriter.write(String) but additionally adds a newline (line-separator) after the message.
 void printlnRaw(CharSequence text)
          This method writes the raw text without internationalization.
 void printRaw(CharSequence text)
          This method writes the raw text without internationalization.
 void setArguments(Map<String,Object> arguments)
          This method sets the arguments.
 
Methods inherited from class net.sf.mmm.util.io.base.AppendableWriter
append, close, flush, getAppendable, write, write, write, write
 
Methods inherited from class java.io.Writer
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageFactory

private final NlsMessageFactory messageFactory
The NlsMessageFactory.


locale

private final Locale locale
The Locale to translate to.


newline

private final String newline
The string used to terminate a line.


resolver

private final NlsTemplateResolver resolver
The NlsTemplateResolver.


arguments

private Map<String,Object> arguments
See Also:
getArguments()
Constructor Detail

NlsWriter

public NlsWriter(Appendable appendable)
The constructor.

Parameters:
appendable - is the Appendable to delegate to.

NlsWriter

public NlsWriter(Appendable appendable,
                 Map<String,Object> arguments)
The constructor.

Parameters:
appendable - is the Appendable to delegate to.
arguments - are the arguments.

NlsWriter

public NlsWriter(Appendable appendable,
                 Map<String,Object> arguments,
                 Locale locale)
The constructor.

Parameters:
appendable - is the Appendable to delegate to.
arguments - are the arguments.
locale - is the Locale.

NlsWriter

public NlsWriter(Appendable appendable,
                 Map<String,Object> arguments,
                 Locale locale,
                 String newline)
The constructor.

Parameters:
appendable - is the Appendable to delegate to.
arguments - are the arguments.
locale - is the Locale.
newline - is the line-separator.

NlsWriter

public NlsWriter(Appendable appendable,
                 Map<String,Object> arguments,
                 Locale locale,
                 String newline,
                 NlsMessageFactory messageFactory)
The constructor.

Parameters:
appendable - is the Appendable to delegate to.
arguments - are the arguments.
locale - is the Locale.
newline - is the line-separator.
messageFactory - is the NlsMessageFactory.

NlsWriter

public NlsWriter(Appendable appendable,
                 Map<String,Object> arguments,
                 Locale locale,
                 String newline,
                 NlsMessageFactory messageFactory,
                 NlsTemplateResolver resolver)
The constructor.

Parameters:
appendable - is the Appendable to delegate to.
arguments - are the arguments.
locale - is the Locale.
newline - is the line-separator.
messageFactory - is the NlsMessageFactory.
resolver - is the NlsTemplateResolver to use.
Method Detail

append

public NlsWriter append(CharSequence csq,
                        int start,
                        int end)
                 throws RuntimeIoException

Specified by:
append in interface Appendable
Overrides:
append in class AppendableWriter
Throws:
RuntimeIoException

append

public NlsWriter append(CharSequence csq)
                 throws RuntimeIoException

Specified by:
append in interface Appendable
Overrides:
append in class AppendableWriter
Throws:
RuntimeIoException

print

public void print(CharSequence csq)
           throws RuntimeIoException
This method is the same as append(CharSequence) or AppendableWriter.write(String).

Parameters:
csq - is the internationalized message to write.
Throws:
RuntimeIoException - if an error occurred while writing.

print

public void print(NlsMessage message)
           throws RuntimeIoException
This method writes an NlsMessage.

Parameters:
message - is the NlsMessage to write.
Throws:
RuntimeIoException - if an error occurred while writing.

println

public void println()
             throws RuntimeIoException
This method writes a newline (line-separator).

Throws:
RuntimeIoException - if an error occurred while writing.

println

public void println(CharSequence csq)
             throws RuntimeIoException
This method is like append(CharSequence) or AppendableWriter.write(String) but additionally adds a newline (line-separator) after the message.

Parameters:
csq - is the internationalized message to write.
Throws:
RuntimeIoException - if an error occurred while writing.

printRaw

public void printRaw(CharSequence text)
              throws RuntimeIoException
This method writes the raw text without internationalization. It may be used for text that is language independent or already internationalized.

Parameters:
text - is the raw text to write.
Throws:
RuntimeIoException - if an IOException occurred while writing to the underlying Appendable.

printlnRaw

public void printlnRaw(CharSequence text)
                throws RuntimeIoException
This method writes the raw text without internationalization. It may be used for text that is language independent or already internationalized.

Parameters:
text - is the raw text to write.
Throws:
RuntimeIoException - if an IOException occurred while writing to the underlying Appendable.

getArguments

public Map<String,Object> getArguments()
This method gets the arguments for the created NlsMessages. The arguments may be modified or replaced before the next message is written.

Returns:
the arguments.

setArguments

public void setArguments(Map<String,Object> arguments)
This method sets the arguments. This allows to replace them before writing another message.

Parameters:
arguments - is the arguments to set


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