de.smartics.maven.util.report
Class MessageHelper

Package class diagram package MessageHelper
java.lang.Object
  extended by de.smartics.maven.util.report.MessageHelper

public class MessageHelper
     
     
extends Object

Helps to fetch labels to render reports. Labels are taken from two resource bundles: a standard and a default one. If a key is not found in the standard bundle, it is fetched from the default bundle. If it is not found there either the key is returned verbatim.

Author:
Robert Reiner

Constructor Summary
MessageHelper(String reportTitleId, String reportDescriptionId, ResourceBundle messages, ResourceBundle defaultMessages)
          Default constructor.
 
Method Summary
 String getLabel(String key)
          Returns the label for the given key.
 String getLabel(String key, String defaultLabel)
          Returns the label for the given key.
 Locale getLocale()
          Returns the locale the message helper provides messages for.
 String getReportDescriptionId()
          Returns the localized report description.
 String getReportTitleId()
          Returns the localized report title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageHelper

public MessageHelper(String reportTitleId,
                     String reportDescriptionId,
                     ResourceBundle messages,
                     ResourceBundle defaultMessages)
              throws NullPointerException
Default constructor.

Parameters:
reportTitleId - the localized report title.
reportDescriptionId - the localized report description.
messages - the primary message bundle to use.
defaultMessages - the default messages that are used if the messages contain no value for a given key.
Throws:
NullPointerException - if defaultMessages is null.
Method Detail

getReportTitleId

public String getReportTitleId()
Returns the localized report title.

Returns:
the localized report title.

getReportDescriptionId

public String getReportDescriptionId()
Returns the localized report description.

Returns:
the localized report description.

getLocale

public Locale getLocale()
Returns the locale the message helper provides messages for.

Returns:
the locale of the resource bundles.

getLabel

public String getLabel(String key)
Returns the label for the given key.

Parameters:
key - the key to the requested label.
Returns:
the label to the key or the key, if no label is found for that key.

getLabel

public String getLabel(String key,
                       String defaultLabel)
Returns the label for the given key.

Parameters:
key - the key to the requested label.
defaultLabel - the label to return if no label is found by the key.
Returns:
the label to the key or the defaultLabel, if no label is found for that key.


Copyright © 2006-2012 Kronseder & Reiner GmbH - smartics. All Rights Reserved.