|
@@ -1,17 +1,22 @@ |
1 |
1 |
|
package com.temp.shared.externalization; |
2 |
2 |
|
|
3 |
|
- |
import java.util.*; |
|
3 |
+ |
import java.util.Collections; |
|
4 |
+ |
import java.util.HashMap; |
|
5 |
+ |
import java.util.Map; |
4 |
6 |
|
|
5 |
|
- |
import com.temp.shared.utils.*; |
|
7 |
+ |
import com.temp.shared.utils.Assert; |
|
8 |
+ |
import com.temp.shared.utils.StringUtils; |
6 |
9 |
|
|
7 |
10 |
|
/** |
8 |
|
- |
* Externalization Data to be used with an Externally Sourced String keyed template system that supports |
9 |
|
- |
* substitutions within any specific template by "named" values. |
|
11 |
+ |
* Externalization Data to be used with an Externally Sourced String keyed |
|
12 |
+ |
* template system that supports substitutions within any specific template by |
|
13 |
+ |
* "named" values. |
10 |
14 |
|
*/ |
11 |
15 |
|
public class E13nData { |
12 |
16 |
|
|
13 |
17 |
|
/** |
14 |
|
- |
* Substitution Value w/ a flag indicating if it is User Data, or another Template Id Code to be used as a Sub-Template. |
|
18 |
+ |
* Substitution Value w/ a flag indicating if it is User Data, or another |
|
19 |
+ |
* Template Id Code to be used as a Sub-Template. |
15 |
20 |
|
*/ |
16 |
21 |
|
public static class SubstitutionValue { |
17 |
22 |
|
private final boolean userData; |
|
@@ -23,7 +28,8 @@ |
23 |
28 |
|
} |
24 |
29 |
|
|
25 |
30 |
|
/** |
26 |
|
- |
* Flag indicating if the "vale" is User Data, or another Template Id Code to be used as a Sub-Template. |
|
31 |
+ |
* Flag indicating if the "value" is User Data, or another Template Id |
|
32 |
+ |
* Code to be used as a Sub-Template. |
27 |
33 |
|
*/ |
28 |
34 |
|
public boolean isUserData() { |
29 |
35 |
|
return userData; |
|
@@ -46,14 +52,18 @@ |
46 |
52 |
|
private Map<String, SubstitutionValue> templateSubstitutionNamedValues; |
47 |
53 |
|
|
48 |
54 |
|
/** |
49 |
|
- |
* @param templateIdCode Template Identifying Code |
|
55 |
+ |
* Convert the templateIdCode (parameter) into an acceptable string form for |
|
56 |
+ |
* the templateIdCode. |
|
57 |
+ |
* |
|
58 |
+ |
* @param templateIdCode |
|
59 |
+ |
* Template Identifying Code |
50 |
60 |
|
*/ |
51 |
|
- |
public E13nData(String templateIdCode) { |
52 |
|
- |
this.templateIdCode = Validate.noEmpty("templateIdCode", templateIdCode); |
|
61 |
+ |
public E13nData(Object templateIdCode) { |
|
62 |
+ |
this.templateIdCode = Assert.noEmptyToString("templateIdCode", templateIdCode); |
53 |
63 |
|
} |
54 |
64 |
|
|
55 |
65 |
|
private synchronized E13nData addPair(boolean userData, String name, String value) { |
56 |
|
- |
name = Validate.noEmpty("name", name); |
|
66 |
+ |
name = Assert.noEmpty("name", name); |
57 |
67 |
|
if (templateSubstitutionNamedValues == null) { |
58 |
68 |
|
templateSubstitutionNamedValues = new HashMap<String, SubstitutionValue>(); |
59 |
69 |
|
} |
|
@@ -64,8 +74,10 @@ |
64 |
74 |
|
/** |
65 |
75 |
|
* Add a User Substitution Named Value. |
66 |
76 |
|
* |
67 |
|
- |
* @param name Not allowed to be empty |
68 |
|
- |
* @param userData null converted to "" |
|
77 |
+ |
* @param name |
|
78 |
+ |
* Not allowed to be empty |
|
79 |
+ |
* @param userData |
|
80 |
+ |
* null converted to "" |
69 |
81 |
|
*/ |
70 |
82 |
|
public E13nData addSubstitutionNamedUserData(String name, String userData) { |
71 |
83 |
|
return addPair(true, name, StringUtils.deNull(userData)); |
|
@@ -74,11 +86,13 @@ |
74 |
86 |
|
/** |
75 |
87 |
|
* Add a User Substitution Named Value. |
76 |
88 |
|
* |
77 |
|
- |
* @param name Not allowed to be empty |
78 |
|
- |
* @param subTemplateIdCode Not allowed to be empty |
|
89 |
+ |
* @param name |
|
90 |
+ |
* Not allowed to be empty |
|
91 |
+ |
* @param subTemplateIdCode |
|
92 |
+ |
* Not allowed to be empty |
79 |
93 |
|
*/ |
80 |
94 |
|
public E13nData addSubstitutionNamedSubTemplateIdCode(String name, String subTemplateIdCode) { |
81 |
|
- |
return addPair(false, name, Validate.noEmpty("subTemplateIdCode", subTemplateIdCode)); |
|
95 |
+ |
return addPair(false, name, Assert.noEmpty("subTemplateIdCode", subTemplateIdCode)); |
82 |
96 |
|
} |
83 |
97 |
|
|
84 |
98 |
|
/** |