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