org.fuin.objects4j
Class LabelInfo

java.lang.Object
  extended by org.fuin.objects4j.LabelInfo
Direct Known Subclasses:
LabelClassInfo, LabelFieldInfo

@Immutable
public abstract class LabelInfo
extends Object

Label information for a concrete object.


Constructor Summary
LabelInfo(String text, String shortText)
          Constructor with text and short text.
 
Method Summary
static ResourceBundle getResourceBundle(Label label, Locale locale, Class<?> clasz)
          Returns the resource bundle for a given label.
 String getShortText()
          Returns the abbreviation of the text.
static String getShortText(ResourceBundle bundle, Label label, String defaultKey)
          Returns the short text for the label.
 String getText()
          Returns the text of the label.
static String getText(ResourceBundle bundle, Label label, String defaultKey)
          Returns the text for the label.
protected static String toNullableString(String value)
          Returns null if the argument is an empty string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelInfo

public LabelInfo(String text,
                 String shortText)
Constructor with text and short text.

Parameters:
text - Text.
shortText - Abbreviation of the text.
Method Detail

getText

public final String getText()
Returns the text of the label.

Returns:
Long text.

getShortText

public final String getShortText()
Returns the abbreviation of the text.

Returns:
Short text.

getText

@Requires(value="(bundle != null) && (label != null) && (field!=null)")
public static String getText(ResourceBundle bundle,
                                           Label label,
                                           String defaultKey)
Returns the text for the label. If no entry is found in the resource bundle for Label.key() then Label.value() will be returned instead. If Label.value() is also empty then null is returned. If Label.key() is empty defaultKey will be used as key in the properties file.

Parameters:
bundle - Resource bundle to use.
label - Label for the field.
defaultKey - Default key if Label.key() is empty.
Returns:
Text or null.

getShortText

@Requires(value="(bundle != null) && (label != null) && (field!=null)")
public static String getShortText(ResourceBundle bundle,
                                                Label label,
                                                String defaultKey)
Returns the short text for the label. If no entry is found in the resource bundle for Label.shortKey() then Label.shortText() will be returned instead. If Label.shortText() is also empty then null is returned. If Label.shortKey() is empty defaultKey will be used as key in the properties file.

Parameters:
bundle - Resource bundle to use.
label - Label for the field.
defaultKey - Default key if Label.shortKey() is empty.
Returns:
Text or null.

getResourceBundle

@Requires(value="(label != null) && (locale != null) && (clasz != null)")
@Ensures(value="\result != null")
public static ResourceBundle getResourceBundle(Label label,
                                                                          Locale locale,
                                                                          Class<?> clasz)
Returns the resource bundle for a given label. If label.bundle() is empty the clasz is used to create a path and filename information.

Parameters:
label - Label with bundle name.
locale - Locale to use.
clasz - Class to use if the label.bundle() is empty. Example: a.b.c.MyClass is used as a/b/c/MyClass.properties or a/b/c/MyClass_en.properties (with Locale.ENGLISH).
Returns:
Resource bundle.

toNullableString

protected static String toNullableString(String value)
Returns null if the argument is an empty string.

Parameters:
value - Argument to check.
Returns:
Argument or null.


Copyright © 2011 Future Invent Informationsmanagement GmbH. All Rights Reserved.