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 java.lang.Object

Label information for a concrete object.


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

Constructor Detail

LabelInfo

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

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

getText

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

Returns:
Long text.

getShortText

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

Returns:
Short text.

getText

@Requires(value="(bundle != null) && (label != null) && (field!=null)")
public static java.lang.String getText(java.util.ResourceBundle bundle,
                                                     Label label,
                                                     java.lang.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 java.lang.String getShortText(java.util.ResourceBundle bundle,
                                                          Label label,
                                                          java.lang.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 java.util.ResourceBundle getResourceBundle(Label label,
                                                                                    java.util.Locale locale,
                                                                                    java.lang.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 java.lang.String toNullableString(java.lang.String value)


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