xref: /aosp_15_r20/external/apache-commons-lang/src/site/xdoc/article2_5.xml (revision 455610af95f3bf5f4bc8a9eda520f57e389a4c42)
1*455610afSAndroid Build Coastguard Worker<?xml version="1.0"?>
2*455610afSAndroid Build Coastguard Worker<!--
3*455610afSAndroid Build Coastguard WorkerLicensed to the Apache Software Foundation (ASF) under one or more
4*455610afSAndroid Build Coastguard Workercontributor license agreements.  See the NOTICE file distributed with
5*455610afSAndroid Build Coastguard Workerthis work for additional information regarding copyright ownership.
6*455610afSAndroid Build Coastguard WorkerThe ASF licenses this file to You under the Apache License, Version 2.0
7*455610afSAndroid Build Coastguard Worker(the "License"); you may not use this file except in compliance with
8*455610afSAndroid Build Coastguard Workerthe License.  You may obtain a copy of the License at
9*455610afSAndroid Build Coastguard Worker
10*455610afSAndroid Build Coastguard Worker     http://www.apache.org/licenses/LICENSE-2.0
11*455610afSAndroid Build Coastguard Worker
12*455610afSAndroid Build Coastguard WorkerUnless required by applicable law or agreed to in writing, software
13*455610afSAndroid Build Coastguard Workerdistributed under the License is distributed on an "AS IS" BASIS,
14*455610afSAndroid Build Coastguard WorkerWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15*455610afSAndroid Build Coastguard WorkerSee the License for the specific language governing permissions and
16*455610afSAndroid Build Coastguard Workerlimitations under the License.
17*455610afSAndroid Build Coastguard Worker-->
18*455610afSAndroid Build Coastguard Worker<document>
19*455610afSAndroid Build Coastguard Worker <properties>
20*455610afSAndroid Build Coastguard Worker  <title>What's new in Commons Lang 2.5?</title>
21*455610afSAndroid Build Coastguard Worker  <author email="[email protected]">Commons Documentation Team</author>
22*455610afSAndroid Build Coastguard Worker </properties>
23*455610afSAndroid Build Coastguard Worker<body>
24*455610afSAndroid Build Coastguard Worker
25*455610afSAndroid Build Coastguard Worker<section name="What's new in Commons Lang 2.5?">
26*455610afSAndroid Build Coastguard Worker<p>Commons Lang 2.5 is out, and the obvious question is: <em>"So what? What's changed?"</em>.</p>
27*455610afSAndroid Build Coastguard Worker<p>This article aims to briefly cover the changes and save you from having to dig through each JIRA
28*455610afSAndroid Build Coastguard Workerissue to see what went on in the two years of development between Lang 2.4 and 2.5.</p>
29*455610afSAndroid Build Coastguard Worker<p>Two years?!? Yes, it's true. The reason is that 2.5 represents the backwards compatible changes in the
30*455610afSAndroid Build Coastguard Workernearly complete Java-5 focused Lang 3.0. </p>
31*455610afSAndroid Build Coastguard Worker<section name="Deprecations">
32*455610afSAndroid Build Coastguard Worker<p>There were no new deprecations in 2.5. </p>
33*455610afSAndroid Build Coastguard Worker</section>
34*455610afSAndroid Build Coastguard Worker<section name="The build">
35*455610afSAndroid Build Coastguard Worker<p>2.5 was built using Sun's 1.6.0_17 JVM, but targets Java 1.3. </p>
36*455610afSAndroid Build Coastguard Worker</section>
37*455610afSAndroid Build Coastguard Worker<section name="New classes">
38*455610afSAndroid Build Coastguard Worker<p>A new org.apache.commons.lang.reflect package was added, accumulating common high-level uses of the java.lang.reflect APIs. The
39*455610afSAndroid Build Coastguard Workerclasses, hopefully self-evident in nature, were pulled together from the existing BeanUtils and the unreleased Reflect components.
40*455610afSAndroid Build Coastguard WorkerThe classes are: </p>
41*455610afSAndroid Build Coastguard Worker<ul>
42*455610afSAndroid Build Coastguard Worker<li>ConstructorUtils - primarily creating new instances of classes</li>
43*455610afSAndroid Build Coastguard Worker<li>FieldUtils - primarily reading and writing to Object/Class fields</li>
44*455610afSAndroid Build Coastguard Worker<li>MethodUtils - primarily methods to make invoking methods simpler</li>
45*455610afSAndroid Build Coastguard Worker</ul>
46*455610afSAndroid Build Coastguard Worker<p>You can read more about the classes in their
47*455610afSAndroid Build Coastguard Worker<a href="LANG_2_5/src/main/java/org/apache/commons/lang/reflect//MemberUtils.java">javadoc</a>. </p>
48*455610afSAndroid Build Coastguard Worker</section>
49*455610afSAndroid Build Coastguard Worker<section name="New fields">
50*455610afSAndroid Build Coastguard Worker<p>With both Java 7 and Windows 7 becoming a reality,
51*455610afSAndroid Build Coastguard Worker<a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/SystemUtils.html">SystemUtils</a> was updated to
52*455610afSAndroid Build Coastguard Workerprovide boolean fields for both versions. </p>
53*455610afSAndroid Build Coastguard Worker</section>
54*455610afSAndroid Build Coastguard Worker<section name="New methods">
55*455610afSAndroid Build Coastguard Worker<p>There were 66 new methods added to existing Commons Lang classes. </p>
56*455610afSAndroid Build Coastguard Worker<p>The <a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/ArrayUtils.html">ArrayUtils</a> class
57*455610afSAndroid Build Coastguard Workerreceived two new types of methods. Firstly, a boolean isNotEmpty(array) set of methods, identifying whether the particular
58*455610afSAndroid Build Coastguard Workerarray is null or an empty sized array. This makes it the inverse of the existing isEmpty(array) methods. Secondly, an array
59*455610afSAndroid Build Coastguard WorkernullToEmpty(array) set of methods that converts null or empty arrays to a singleton empty array already available from the
60*455610afSAndroid Build Coastguard WorkerArrayUtils class. Non-null/empty arrays are left untouched. </p>
61*455610afSAndroid Build Coastguard Worker
62*455610afSAndroid Build Coastguard Worker<p>The constructor for the
63*455610afSAndroid Build Coastguard Worker<a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/CharRange.html">CharRange</a> class is somewhat
64*455610afSAndroid Build Coastguard Workerconfusing. It takes a boolean parameter that when set to true means the CharRange is negated. To make code easier to read, the
65*455610afSAndroid Build Coastguard Workerfollowing static helper methods were added: </p>
66*455610afSAndroid Build Coastguard Worker<ul>
67*455610afSAndroid Build Coastguard Worker<li>public org.apache.commons.lang.CharRange is(char)</li>
68*455610afSAndroid Build Coastguard Worker<li>public org.apache.commons.lang.CharRange isIn(char, char)</li>
69*455610afSAndroid Build Coastguard Worker<li>public org.apache.commons.lang.CharRange isNot(char)</li>
70*455610afSAndroid Build Coastguard Worker<li>public org.apache.commons.lang.CharRange isNotIn(char, char)</li>
71*455610afSAndroid Build Coastguard Worker</ul>
72*455610afSAndroid Build Coastguard Worker<p>An iterator() method was also added to provide another way of walking the range. </p>
73*455610afSAndroid Build Coastguard Worker
74*455610afSAndroid Build Coastguard Worker<p>The <a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/builder/EqualsBuilder.html">EqualsBuilder</a>
75*455610afSAndroid Build Coastguard Workerobtained a new reset() method to allow for reuse, while the
76*455610afSAndroid Build Coastguard Worker<a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/builder/HashCodeBuilder.html">HashCodeBuilder</a>
77*455610afSAndroid Build Coastguard Workerreceived a hashCode() method that returns the built hash code instead of the natural hash code of the builder object itself. It
78*455610afSAndroid Build Coastguard Workerdoesn't really matter what the builder chooses to use as a hash code and this stops accidental use of the hashCode() instead of
79*455610afSAndroid Build Coastguard WorkertoHashCode() method from causing lots of pain. </p>
80*455610afSAndroid Build Coastguard Worker
81*455610afSAndroid Build Coastguard Worker<p>Helper isFalse(), isTrue() and toBoolean() methods were added to
82*455610afSAndroid Build Coastguard Worker<a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/mutable/MutableBoolean.html">MutableBoolean</a>,
83*455610afSAndroid Build Coastguard Workerwhile the other mutable classes received String argument constructors. </p>
84*455610afSAndroid Build Coastguard Worker
85*455610afSAndroid Build Coastguard Worker<p>Lastly, the <a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/time/DateUtils.html">DateUtils</a>
86*455610afSAndroid Build Coastguard Workerclass received a new ceiling set of methods to truncate upwards, and a parseDateStrictly method to parse a Date with the
87*455610afSAndroid Build Coastguard Workersupplied DateFormat classes leniency set to false. </p>
88*455610afSAndroid Build Coastguard Worker
89*455610afSAndroid Build Coastguard Worker</section>
90*455610afSAndroid Build Coastguard Worker
91*455610afSAndroid Build Coastguard Worker<section name="StringUtils methods">
92*455610afSAndroid Build Coastguard Worker<p>As with 2.4, the
93*455610afSAndroid Build Coastguard Worker<a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.5/org/apache/commons/lang/StringUtils.html">StringUtils</a> class has
94*455610afSAndroid Build Coastguard Workergrown and we cover its new methods in its own section. </p>
95*455610afSAndroid Build Coastguard Worker<ul>
96*455610afSAndroid Build Coastguard Worker<li>abbreviateMiddle(String, String, int);String - This method turns aRatherLongNameSuchAsAFileName into 'aRatherLo...AFileName'.
97*455610afSAndroid Build Coastguard WorkerThis is often desirable when you want to restrict the length of a name, but you can afford to have quite long names. </li>
98*455610afSAndroid Build Coastguard Worker<li>indexOfIgnoreCase(String, String);int - An indexOf method that ignores the case of what it's matching. Matching lastIndexOfIgnoreCase and 'start at index' variants were also added. </li>
99*455610afSAndroid Build Coastguard Worker<li>lastOrdinalIndexOf(String, String, int);int - A matching variant for the already existing ordinalIndexOf method - they
100*455610afSAndroid Build Coastguard Workersupport finding the Nth indexOf instead of the first time the search term is found. </li>
101*455610afSAndroid Build Coastguard Worker<li>isAllLowerCase(String);boolean - Is the String all lower case. </li>
102*455610afSAndroid Build Coastguard Worker<li>isAllUpperCase(String);boolean - Is the String all upper case. </li>
103*455610afSAndroid Build Coastguard Worker<li>lowerCase(String, Locale);String - Null protected toLowerCase methods for the platform independent inclined. </li>
104*455610afSAndroid Build Coastguard Worker<li>upperCase(String, Locale);String - Null protected toUpperCase methods for the platform independent inclined. </li>
105*455610afSAndroid Build Coastguard Worker<li>repeat(String, String, int);String - Repeat option that includes an optional separator. </li>
106*455610afSAndroid Build Coastguard Worker<li>startsWithAny(String, String[]);boolean - Does the specified String start with any of the supplied values. </li>
107*455610afSAndroid Build Coastguard Worker</ul>
108*455610afSAndroid Build Coastguard Worker</section>
109*455610afSAndroid Build Coastguard Worker
110*455610afSAndroid Build Coastguard Worker<section name="What's fixed in Lang 2.5?">
111*455610afSAndroid Build Coastguard Worker<p>Per the <a href="upgradeto2_5.html">release notes</a> there are 32 bugs fixed in Lang 2.5. Some highlights are: </p>
112*455610afSAndroid Build Coastguard Worker<ul>
113*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-477">LANG-477</a> - fixing an OutOfMemoryError in ExtendedMessageFormat. </li>
114*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-76">LANG-76</a> - EnumUtils.getEnum() doesn't work well in 1.5. </li>
115*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-204">LANG-204</a> and
116*455610afSAndroid Build Coastguard Worker<a href="https://issues.apache.org/jira/browse/LANG-506">LANG-506</a> - Multithreading improvements to the package private Entities
117*455610afSAndroid Build Coastguard Workerclass, used behind the scenes by StringEscapeUtils. </li>
118*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-511">LANG-511</a> - Improve performance by deferring LocaleUtils initialization. </li>
119*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-523">LANG-523</a> - Two orders of magnitude performance improvement in StrBuilder. </li>
120*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-467">LANG-467</a> - Reverted the change to EqualsBuilder in Lang 2.4 to
121*455610afSAndroid Build Coastguard Workerspecially handle BigDecimal. While useful, it put things out of sync with HashCodeBuilder. </li>
122*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-586">LANG-586</a> - Use of a ThreadLocal in HashCodeBuilder and
123*455610afSAndroid Build Coastguard WorkerToStringStyle meant that containers could end up with memory leaks. This was rewritten to avoid this. </li>
124*455610afSAndroid Build Coastguard Worker<li><a href="https://issues.apache.org/jira/browse/LANG-472">LANG-472</a> - RandomUtils.nextLong() was returning only even numbers. Fans of Java-based roulette wheels can breathe a sigh of relief. </li>
125*455610afSAndroid Build Coastguard Worker</ul>
126*455610afSAndroid Build Coastguard Worker</section>
127*455610afSAndroid Build Coastguard Worker
128*455610afSAndroid Build Coastguard Worker<section name="So long, farewell...">
129*455610afSAndroid Build Coastguard Worker<p>Hopefully that was all of interest. Don't forget to download <a href="https://commons.apache.org/lang/download_lang.cgi">Lang 2.5</a>, or, for the Maven repository users, upgrade your &lt;version&gt; tag to 2.5. Please feel free to raise any questions you might have on the <a href="mail-lists.html">mailing lists</a>, and report bugs or enhancements in the <a href="issue-tracking.html">issue tracker</a>.</p>
130*455610afSAndroid Build Coastguard Worker</section>
131*455610afSAndroid Build Coastguard Worker
132*455610afSAndroid Build Coastguard Worker</section>
133*455610afSAndroid Build Coastguard Worker
134*455610afSAndroid Build Coastguard Worker</body>
135*455610afSAndroid Build Coastguard Worker</document>
136