litesoft
Diff Revisions
947
vs
948
for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/util/externalization/ExternalizedText.java
|
@@ -1,37 +1,31 @@ |
1 |
1 |
|
package org.litesoft.GWT.client.util.externalization; |
2 |
2 |
|
|
3 |
3 |
|
import org.litesoft.commonfoundation.typeutils.*; |
4 |
|
- |
|
5 |
|
- |
import java.util.*; |
6 |
|
- |
|
7 |
4 |
|
import org.litesoft.core.util.*; |
8 |
5 |
|
|
9 |
6 |
|
import com.google.gwt.i18n.client.Dictionary; |
10 |
7 |
|
|
11 |
|
- |
public class ExternalizedText implements TemplateSource |
12 |
|
- |
{ |
|
8 |
+ |
import java.util.*; |
|
9 |
+ |
|
|
10 |
+ |
public class ExternalizedText implements TemplateSource { |
13 |
11 |
|
private static ExternalizedText instance; |
14 |
12 |
|
|
15 |
13 |
|
private final Dictionary dictionary; |
16 |
14 |
|
private final Set<String> keys; |
17 |
15 |
|
|
18 |
|
- |
public static ExternalizedText getInstance() |
19 |
|
- |
{ |
20 |
|
- |
if ( instance == null ) |
21 |
|
- |
{ |
|
16 |
+ |
public static ExternalizedText getInstance() { |
|
17 |
+ |
if ( instance == null ) { |
22 |
18 |
|
instance = new ExternalizedText( Dictionary.getDictionary( "ExternalTemplateText" ) ); |
23 |
19 |
|
} |
24 |
20 |
|
return instance; |
25 |
21 |
|
} |
26 |
22 |
|
|
27 |
|
- |
private ExternalizedText( Dictionary dictionary ) |
28 |
|
- |
{ |
|
23 |
+ |
private ExternalizedText( Dictionary dictionary ) { |
29 |
24 |
|
this.dictionary = dictionary; |
30 |
25 |
|
this.keys = dictionary.keySet(); |
31 |
26 |
|
} |
32 |
27 |
|
|
33 |
|
- |
private String safeGet( String key ) |
34 |
|
- |
{ |
|
28 |
+ |
private String safeGet( String key ) { |
35 |
29 |
|
return keys.contains( key ) ? dictionary.get( key ) : null; |
36 |
30 |
|
} |
37 |
31 |
|
|
|
@@ -42,8 +36,7 @@ |
42 |
36 |
|
* |
43 |
37 |
|
* @return null or the Template value associated with the key |
44 |
38 |
|
*/ |
45 |
|
- |
public String get( String key ) |
46 |
|
- |
{ |
|
39 |
+ |
public String get( String key ) { |
47 |
40 |
|
key = Strings.noEmpty( key ); |
48 |
41 |
|
return (key != null) ? Strings.noEmpty( safeGet( key ) ) : null; |
49 |
42 |
|
} |
|
@@ -55,10 +48,9 @@ |
55 |
48 |
|
* @param key Leading and trailing spaces are ignored |
56 |
49 |
|
* |
57 |
50 |
|
* @return The Template value associated with the key or the defaultValue if |
58 |
|
- |
* the key was not found or its value was empty |
|
51 |
+ |
* the key was not found or its value was empty |
59 |
52 |
|
*/ |
60 |
|
- |
public String get( String key, String defaultValue ) |
61 |
|
- |
{ |
|
53 |
+ |
public String get( String key, String defaultValue ) { |
62 |
54 |
|
return Strings.deNull( get( key ), defaultValue ); |
63 |
55 |
|
} |
64 |
56 |
|
} |