Version 4.10.0

hirondelle.web4j.ui.translate
Class Translation.LookupResult

Object
  extended by hirondelle.web4j.ui.translate.Translation.LookupResult
Enclosing class:
Translation

public static final class Translation.LookupResult
extends Object

The result of Translation.lookUp(String, Locale, Map).

Encapsulates both the species of success/fail and the actual text of the translation, if any.

Example of a typical use case :

    String text = null;
    LookupResult lookup = Translation.lookUp(aBaseText, aLocale, fTranslations);
    if( lookup.hasSucceeded() ){ 
      text = lookup.getText();
    }
    else {
      text = aBaseText;
      if(LookupResult.UNKNOWN_BASE_TEXT == lookup){
        addToListOfUnknowns(aBaseText);
      }
      else if (LookupResult.UNKNOWN_LOCALE == lookup){
        //do nothing in this implementation
      }
    }
  


Field Summary
static Translation.LookupResult UNKNOWN_BASE_TEXT
          BaseText is unknown.
static Translation.LookupResult UNKNOWN_LOCALE
          BaseText is known, but no translation exists for the specified Locale
 
Method Summary
 String getText()
          Return the text of the successful translation.
 boolean hasSucceeded()
          Returns true only if a specific translation exists for BaseText and Locale.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_BASE_TEXT

public static final Translation.LookupResult UNKNOWN_BASE_TEXT
BaseText is unknown.


UNKNOWN_LOCALE

public static final Translation.LookupResult UNKNOWN_LOCALE
BaseText is known, but no translation exists for the specified Locale

Method Detail

hasSucceeded

public boolean hasSucceeded()
Returns true only if a specific translation exists for BaseText and Locale.


getText

public String getText()
Return the text of the successful translation. Returns null only if hasSucceeded() is false.


Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.