litesoft
@ 950
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
package org.litesoft.GWT.client.util.externalization; import org.litesoft.commonfoundation.base.*; import org.litesoft.core.util.*; import com.google.gwt.i18n.client.Dictionary; import java.util.*; public class ExternalizedText implements TemplateSource { private static ExternalizedText instance; private final Dictionary dictionary; private final Set<String> keys; public static ExternalizedText getInstance() { if ( instance == null ) { instance = new ExternalizedText( Dictionary.getDictionary( "ExternalTemplateText" ) ); } return instance; } private ExternalizedText( Dictionary dictionary ) { this.dictionary = dictionary; this.keys = dictionary.keySet(); } private String safeGet( String key ) { return keys.contains( key ) ? dictionary.get( key ) : null; } /** * Get the Template value associated with the key * * @param key Leading and trailing spaces are ignored * * @return null or the Template value associated with the key */ @Override public String get( String key ) { key = ConstrainTo.significantOrNull( key ); return (key != null) ? ConstrainTo.significantOrNull( safeGet( key ) ) : null; } /** * Get the Template value associated with the key or the defaultValue if the * key was not found or its value was empty * * @param key Leading and trailing spaces are ignored * * @return The Template value associated with the key or the defaultValue if * the key was not found or its value was empty */ @Override public String get( String key, String defaultValue ) { return ConstrainTo.firstNonNull( get( key ), defaultValue ); } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/util/externalization/ExternalizedText.java
Revision | Author | Commited | Message |
---|---|---|---|
950 Diff | GeorgeS | Thu 19 Jun, 2014 17:57:04 +0000 | New Lines |
948 Diff | GeorgeS | Sat 07 Jun, 2014 23:42:39 +0000 | Jusefuls Formatter Updated to New Code Format |
939 Diff | GeorgeS | Mon 02 Jun, 2014 21:30:31 +0000 | Extracting commonfoundation |
802 Diff | GeorgeS | Wed 15 Aug, 2012 04:04:47 +0000 | |
801 Diff | GeorgeS | Wed 15 Aug, 2012 03:59:02 +0000 | |
729 | GeorgeS | Sun 17 Jun, 2012 17:17:32 +0000 |