You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Commons Lang 2.4 is out, and the obvious question is: <em>"So what? What's changed?"</em>.</p>
27
29
<p>This article aims to briefly cover the changes and save you from having to dig through each JIRA
28
30
issue to see what went on in the year of development between Lang 2.3 and 2.4.</p>
31
+
</section>
29
32
<sectionname="Deprecations">
30
33
<p>First, let us start with a couple of deprecations. As you can see in the release notes, we chose
31
34
to deprecate the <ahref="https://commons.apache.org/proper/commons-lang/javadocs/api-2.4/org/apache/commons/lang/ObjectUtils.html#appendIdentityToString(java.lang.StringBuffer,%20java.lang.Object)"><code>ObjectUtils.appendIdentityToString(StringBuffer, Object)</code></a> method as its
@@ -60,7 +63,7 @@ followed by a four-digit number, and that it is customary within our organizatio
60
63
with a hyphen following the department identifier. Here we'll represent the EIN as a simple
61
64
String (of course in real life we would likely create a class composed of department and number).
62
65
We can create a custom <code>Format</code> class:
63
-
<pre><code>
66
+
<source>
64
67
public class EINFormat extends Format {
65
68
private char[] idMask;
66
69
@@ -92,10 +95,10 @@ public class EINFormat extends Format {
Our custom EIN format is made available for <code>MessageFormat</code>-style processing by a
97
100
<code>FormatFactory</code> implementation:
98
-
<pre><code>
101
+
<source>
99
102
public class EINFormatFactory implements FormatFactory {
100
103
public static final String EIN_FORMAT = "ein";
101
104
public Format getFormat(String name, String arguments, Locale locale) {
@@ -108,19 +111,19 @@ public class EINFormatFactory implements FormatFactory {
108
111
return null;
109
112
}
110
113
}
111
-
</code></pre>
114
+
</source>
112
115
113
116
Now you simply provide a <code>java.util.Map<String, FormatFactory></code> registry (keyed
114
117
by format type) to <code>ExtendedMessageFormat</code>:
115
-
<pre><code>
118
+
<source>
116
119
new ExtendedMessageFormat("EIN: {0,ein}", Collections.singletonMap(EINFormatFactory.EIN_FORMAT, new EINFormatFactory()));
117
-
</code></pre>
120
+
</source>
118
121
As expected, this will render a String EIN "AA9999" as: <code>"EIN: AA-9999"</code>.
119
122
<br /> <br />
120
123
If we wanted to trigger the EIN masking code, we could trigger that in the format pattern:
121
-
<pre><code>
124
+
<source>
122
125
new ExtendedMessageFormat("EIN: {0,ein,#}", Collections.singletonMap(EINFormatFactory.EIN_FORMAT, new EINFormatFactory()));
123
-
</code></pre>
126
+
</source>
124
127
This should render "AA9999" as: <code>"EIN: AA-####"</code>.
125
128
<br /> <br />
126
129
You can also use <code>ExtendedMessageFormat</code> to override any or all of the built-in
@@ -189,7 +192,5 @@ and fortunately there are some nice groupings that we can discuss instead:</p>
189
192
<p>Hopefully that was all of interest. Don't forget to download <ahref="https://commons.apache.org/lang/download_lang.cgi">Lang 2.4</a>, or, for the Maven repository users, upgrade your <version> tag to 2.4. Please feel free to raise any questions you might have on the <ahref="mail-lists.html">mailing lists</a>, and report bugs or enhancements in the <ahref="issue-tracking.html">issue tracker</a>.</p>
issue to see what went on in the two years of development between Lang 2.4 and 2.5.</p>
29
31
<p>Two years?!? Yes, it's true. The reason is that 2.5 represents the backwards compatible changes in the
30
32
nearly complete Java-5 focused Lang 3.0. </p>
33
+
</section>
31
34
<sectionname="Deprecations">
32
35
<p>There were no new deprecations in 2.5. </p>
33
36
</section>
@@ -129,7 +132,5 @@ ToStringStyle meant that containers could end up with memory leaks. This was rew
129
132
<p>Hopefully that was all of interest. Don't forget to download <ahref="https://commons.apache.org/lang/download_lang.cgi">Lang 2.5</a>, or, for the Maven repository users, upgrade your <version> tag to 2.5. Please feel free to raise any questions you might have on the <ahref="mail-lists.html">mailing lists</a>, and report bugs or enhancements in the <ahref="issue-tracking.html">issue tracker</a>.</p>
0 commit comments