Skip to content
Commits on Source (2)
......@@ -17,3 +17,4 @@ site-content
.classpath
.project
.externalToolBuilders
.checkstyle
......@@ -17,9 +17,12 @@ language: java
sudo: false
jdk:
- openjdk6
- openjdk7
- oraclejdk8
- oraclejdk9
script:
- mvn
after_success:
- mvn clean cobertura:cobertura coveralls:report
- mvn clean cobertura:cobertura coveralls:report -Ptravis-cobertura
Apache Commons Lang
Copyright 2001-2016 The Apache Software Foundation
Copyright 2001-2017 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
......
......@@ -46,7 +46,7 @@ Apache Commons Lang
[![Build Status](https://travis-ci.org/apache/commons-lang.svg?branch=master)](https://travis-ci.org/apache/commons-lang)
[![Coverage Status](https://coveralls.io/repos/apache/commons-lang/badge.svg?branch=master)](https://coveralls.io/r/apache/commons-lang)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-lang3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-lang3/)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
[![Javadocs](https://javadoc.io/badge/org.apache.commons/commons-lang3/3.6.svg)](https://javadoc.io/doc/org.apache.commons/commons-lang3/3.6)
Apache Commons Lang, a package of Java utility classes for the
classes that are in java.lang's hierarchy, or are considered to be so
......@@ -69,7 +69,7 @@ Alternatively you can pull it from the central Maven repositories:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
<version>3.6</version>
</dependency>
```
......@@ -97,8 +97,8 @@ You like Apache Commons Lang? Then [donate back to the ASF](https://www.apache.o
Additional Resources
--------------------
+ [Apache Commons Homepage](https://commons.apache.org/)
+ [Apache Bugtracker (JIRA)](https://issues.apache.org/jira/)
+ [Apache Commons Lang Homepage](https://commons.apache.org/proper/commons-lang)
+ [Apache Commons Lang Bugtracker (JIRA)](https://issues.apache.org/jira/browse/LANG)
+ [Apache Commons Twitter Account](https://twitter.com/ApacheCommons)
+ #apachecommons IRC channel on freenode.org
......
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache Commons Lang
Version 3.5
Version 3.7
Release Notes
INTRODUCTION:
This document contains the release notes for the 3.5 version of
This document contains the release notes for the 3.7 version of Apache Commons Lang.
Commons Lang is a set of utility functions and reusable components that should be of use in any
Java environment.
Lang 3.0 and onwards now targets Java 5.0, making use of features that arrived with Java 5.0 such as generics,
variable arguments, autoboxing, concurrency and formatted output.
For the advice on upgrading from 2.x to 3.x, see the following page:
http://commons.apache.org/lang/article3_0.html
Apache Commons Lang, a package of Java utility classes for the
classes that are in java.lang's hierarchy, or are considered to be so
standard as to justify existence in java.lang.
New features and bug fixes. Requires Java 7, supports Java 8, 9, 10.
Changes in this version include:
New features:
o LANG-1355: TimeZone.getTimeZone() in FastDateParser causes resource contention (PR #296.) Thanks to Chas Honton.
o LANG-1360: Add methods to ObjectUtils to get various forms of class names in a null-safe manner Thanks to Gary Gregory.
Fixed Bugs:
o LANG-1362: Fix tests DateUtilsTest for Java 9 with en_GB locale Thanks to Stephen Colebourne.
o LANG-1365: Fix NullPointerException in isJavaVersionAtLeast on Java 10, add SystemUtils.IS_JAVA_10, add JavaVersion.JAVA_10 Thanks to Gary Gregory.
o LANG-1348: StackOverflowError on TypeUtils.toString(...) for a generic return type of Enum.valueOf Thanks to mbusso.
o LANG-1350: ConstructorUtils.invokeConstructor(Class, Object...) regression Thanks to Brett Kail.
o LANG-1349: EqualsBuilder#isRegistered: swappedPair construction bug Thanks to Naman Nigam.
o LANG-1357: org.apache.commons.lang3.time.FastDateParser should use toUpperCase(Locale) Thanks to BruceKuiLiu.
Changes:
o LANG-1358: Improve StringUtils#replace throughput Thanks to Stephane Landelle.
o LANG-1346: Remove deprecation from RandomStringUtils
o LANG-1361: ExceptionUtils.getThrowableList() is using deprecated ExceptionUtils.getCause() Thanks to Ana.
Historical list of changes: http://commons.apache.org/proper/commons-lang/changes-report.html
For complete information on Apache Commons Lang, including instructions on how to submit bug reports,
patches, or suggestions for improvement, see the Apache Apache Commons Lang website:
http://commons.apache.org/proper/commons-lang/
=============================================================================
Apache Commons Lang
Version 3.6
Release Notes
INTRODUCTION:
This document contains the release notes for the 3.6 version of
Apache Commons Lang as well as a history all changes in the Commons Lang 3.x
release line. Commons Lang is a set of utility functions and reusable
components that should be of use in any Java environment. Commons Lang 3.5 at
least requires Java 6.0.
components that should be of use in any Java environment. Commons Lang 3.6 at
least requires Java 7.0. Note that this has changed from Commons Lang 3.5, which
only required Java 1.6.
For the advice on upgrading from 2.x to 3.x, see the following page:
......@@ -20,6 +91,175 @@ HIGHLIGHTS
Some of the highlights in this release include:
o The class org.apache.commons.lang3.concurrent.Memoizer is an implementation
of the Memoizer pattern as shown in
Goetz, Brian et al. (2006) - Java Concurrency in Practice, p. 108.
o The class org.apache.commons.lang3.ArchUtils has been added. ArchUtils is
a utility class for the "os.arch" system property.
DEPRECATIONS
============
The Apache Commons Community has recently set up the Commons Text component
as a home for algorithms working on strings. For this reason most of the string
focused functionality in Commons Lang has been deprecated and moved to
Commons Text. This includes:
o All classes in the org.apache.commons.lang3.text and the
org.apache.commons.lang3.text.translate packages
o org.apache.commons.lang3.StringEscapeUtils
o org.apache.commons.lang3.RandomStringUtils
o The methods org.apache.commons.lang3.StringUtils.getJaroWinklerDistance and
org.apache.commons.lang3.StringUtils.getLevenshteinDistance
For more information see the Commons Text website:
http://commons.apache.org/text
The class org.apache.commons.lang3.CharEncoding has been deprecated in favor of
java.nio.charset.StandardCharsets.
The following methods have been deprecated in
org.apache.commons.lang3.ArrayUtils in favor of the corresponding insert
methods. Note that the handling for null inputs differs between add and insert.
o add(boolean[], int, boolean) -> insert(int, boolean[], boolean...)
o add(byte[], int, boolean) -> insert(int, byte[], byte...)
o add(char[], int, boolean) -> insert(int, char[], char...)
o add(double[], int, boolean) -> insert(int, double[], double...)
o add(float[], int, boolean) -> insert(int, float[], float...)
o add(int[], int, boolean) -> insert(int, int[], int...)
o add(long[], int, boolean) -> insert(int, long[], long...)
o add(short[], int, boolean) -> insert(int, short[], short...)
o add(T[], int, boolean) -> insert(int, T[], T...)
COMPATIBILITY WITH JAVA 9
==================
The MANIFEST.MF now contains an additional entry:
Automatic-Module-Name: org.apache.commons.lang3
This should make it possible to use Commons Lang 3.6 as a module in the Java 9
module system. For more information see the corresponding issue and the
referenced mailing list discussions:
https://issues.apache.org/jira/browse/LANG-1338
The build problems present in the 3.5 release have been resolved. Building
Commons Lang 3.6 should work out of the box with the latest Java 9 EA build.
Please report any Java 9 related issues at:
https://issues.apache.org/jira/browse/LANG
NEW FEATURES
============
o LANG-1336: Add NUL Byte To CharUtils. Thanks to Beluga Behr.
o LANG-1304: Add method in StringUtils to determine if string contains both
mixed cased characters. Thanks to Andy Klimczak.
o LANG-1325: Increase test coverage of ToStringBuilder class to 100%.
Thanks to Arshad Basha.
o LANG-1307: Add a method in StringUtils to extract only digits out of input
string. Thanks to Arshad Basha.
o LANG-1256: Add JMH maven dependencies. Thanks to C0rWin.
o LANG-1167: Add null filter to ReflectionToStringBuilder.
Thanks to Mark Dacek.
o LANG-1299: Add method for converting string to an array of code points.
o LANG-660: Add methods to insert arrays into arrays at an index.
o LANG-1034: Add support for recursive comparison to
EqualsBuilder#reflectionEquals. Thanks to Yathos UG.
o LANG-1067: Add a reflection-based variant of DiffBuilder.
o LANG-740: Implementation of a Memomizer. Thanks to James Sawle.
o LANG-1258: Add ArrayUtils#toStringArray method.
Thanks to IG, Grzegorz Rożniecki.
o LANG-1160: StringUtils#abbreviate should support 'custom ellipses' parameter.
o LANG-1293: Add StringUtils#isAllEmpty and #isAllBlank methods.
Thanks to Pierre Templier, Martin Tarjanyi.
o LANG-1313: Add ArchUtils - An utility class for the "os.arch" system property.
Thanks to Tomschi.
o LANG-1272: Add shuffle methods to ArrayUtils.
o LANG-1317: Add MethodUtils#findAnnotation and extend
MethodUtils#getMethodsWithAnnotation for non-public, super-class
and interface methods. Thanks to Yasser Zamani.
o LANG-1331: Add ImmutablePair.nullPair().
o LANG-1332: Add ImmutableTriple.nullTriple().
FIXED BUGS
==========
o LANG-1337: Fix test failures in IBM JDK 8 for ToStringBuilderTest.
o LANG-1319: MultilineRecursiveToStringStyle StackOverflowError when object is
an array.
o LANG-1320: LocaleUtils#toLocale does not support language followed by UN M.49
numeric-3 area code followed by variant.
o LANG-1300: Clarify or improve behaviour of int-based indexOf methods in
StringUtils. Thanks to Mark Dacek.
o LANG-1286: RandomStringUtils random method can overflow and return characters
outside of specified range.
o LANG-1292: WordUtils.wrap throws StringIndexOutOfBoundsException.
o LANG-1287: RandomStringUtils#random can enter infinite loop if end parameter
is to small. Thanks to Ivan Morozov.
o LANG-1285: NullPointerException in FastDateParser$TimeZoneStrategy.
Thanks to Francesco Chicchiriccò.
o LANG-1281: Javadoc of StringUtils.ordinalIndexOf is contradictory.
Thanks to Andreas Lundblad.
o LANG-1188: StringUtils#join(T...): warning: [unchecked] Possible heap
pollution from parameterized vararg type T.
o LANG-1144: Multiple calls of
org.apache.commons.lang3.concurrent.LazyInitializer.initialize()
are possible. Thanks to Waldemar Maier, Gary Gregory.
o LANG-1276: StrBuilder#replaceAll ArrayIndexOutOfBoundsException.
Thanks to Andy Klimczak.
o LANG-1278: BooleanUtils javadoc issues. Thanks to Duke Yin.
o LANG-1070: ArrayUtils#add confusing example in javadoc.
Thanks to Paul Pogonyshev.
o LANG-1271: StringUtils#isAnyEmpty and #isAnyBlank should return false for an
empty array. Thanks to Pierre Templier.
o LANG-1155: Add StringUtils#unwrap. Thanks to Saif Asif, Thiago Andrade.
o LANG-1311: TypeUtils.toString() doesn't handle primitive and Object arrays
correctly. Thanks to Aaron Digulla.
o LANG-1312: LocaleUtils#toLocale does not support language followed by UN M.49
numeric-3 area code.
o LANG-1265: Build failures when building with Java 9 EA.
o LANG-1314: javadoc creation broken with Java 8. Thanks to Allon Murienik.
o LANG-1310: MethodUtils.invokeMethod throws ArrayStoreException if using
varargs arguments and smaller types than the method defines.
Thanks to Don Jeba.
CHANGES
=======
o LANG-1338: Add Automatic-Module-Name MANIFEST entry for Java 9
compatibility.
o LANG-1334: Deprecate CharEncoding in favour of
java.nio.charset.StandardCharsets.
o LANG-1110: Implement HashSetvBitSetTest using JMH.
Thanks to Bruno P. Kinoshita.
o LANG-1290: Increase test coverage of org.apache.commons.lang3.ArrayUtils.
Thanks to Andrii Abramov.
o LANG-1274: StrSubstitutor should state its thread safety.
o LANG-1277: StringUtils#getLevenshteinDistance reduce memory consumption.
Thanks to yufcuy.
o LANG-1279: Update Java requirement from Java 6 to 7.
o LANG-1143: StringUtils should use toXxxxCase(int) rather than
toXxxxCase(char). Thanks to sebb.
o LANG-1297: Add SystemUtils.getHostName() API.
o LANG-1301: Moving apache-rat-plugin configuration into pluginManagement.
Thanks to Karl Heinz Marbaise.
o LANG-1316: Deprecate classes/methods moved to commons-text.
=============================================================================
Release Notes for version 3.5
HIGHLIGHTS
==========
Some of the highlights in this release include:
o Added Java 9 detection to org.apache.commons.lang3.SystemUtils.
o Support for shifting and swapping elements in
org.apache.commons.lang3.ArrayUtils.
......@@ -41,7 +281,7 @@ COMPATIBILITY
=============
Apache Commons Lang 3.5 is binary compatible with the 3.4 release. Users
should not experience any problems when upgrading vom 3.4 to 3.5.
should not experience any problems when upgrading from 3.4 to 3.5.
There has been an addition to the org.apache.commons.lang3.time.DatePrinter
interface:
......@@ -309,6 +549,8 @@ o LANG-1107: Fix parsing edge cases in FastDateParser.
o LANG-1273: Added new property IS_OS_MAC_OSX_EL_CAPITAN in SystemUtils. Thanks
to Jake Wang.
=============================================================================
Release Notes for version 3.4
......@@ -443,6 +685,8 @@ o LANG-1003: DurationFormatUtils are not able to handle negative
o LANG-998: Javadoc is not clear on preferred pattern to instantiate
FastDateParser / FastDatePrinter
=============================================================================
Release Notes for version 3.3.2
NEW FEATURES
......@@ -455,6 +699,8 @@ FIXED BUGS
o LANG-992: NumberUtils#isNumber() returns false for "0.0", "0.4790", et al
=============================================================================
Release Notes for version 3.3.1
FIXED BUGS
......@@ -469,6 +715,8 @@ o LANG-982: DurationFormatUtils.formatDuration(61999, "s.SSSS") - ms field
size should be 4 digits
o LANG-978: Failing tests with Java 8 b128
=============================================================================
Release Notes for version 3.3
NEW FEATURES
......@@ -534,6 +782,8 @@ o LANG-953: Convert package.html files to package-info.java files
o LANG-940: Fix deprecation warnings
o LANG-819: EnumUtils.generateBitVector needs a "? extends"
=============================================================================
Release Notes for version 3.2.1
BUG FIXES
......@@ -546,6 +796,8 @@ o LANG-942: Test failure in FastDateParserTest and FastDateFormat_ParserTest
Henri Yandell.
o LANG-938: Build fails with test failures when building with JDK 8
=============================================================================
Release Notes for version 3.2
COMPATIBILITY WITH 3.1
......@@ -706,6 +958,7 @@ CHANGES WITHOUT TICKET
o Fixed URLs in javadoc to point to new oracle.com pages
=============================================================================
Release Notes for version 3.1
......@@ -740,6 +993,7 @@ o LANG-748: Deprecating chomp(String, String)
o LANG-736: CharUtils static final array CHAR_STRING is not needed to compute
CHAR_STRING_ARRAY
=============================================================================
Release Notes for version 3.0
......
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN" "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="JavadocMethod" files=".*[/\\]test[/\\].*"/>
<suppress checks="JavadocPackage" files=".*[/\\]test[/\\].*"/>
<!-- exclude generated JMH classes from all checks -->
<suppress checks="[a-zA-Z0-9]*" files=".*[/\\]generated-test-sources[/\\].*"/>
<suppress checks="RedundantModifier" files="ConstructorUtilsTest" lines="0-99999"/>
</suppressions>
......@@ -23,24 +23,37 @@ limitations under the License.
<!-- commons lang customization of default Checkstyle behavior -->
<module name="Checker">
<property name="localeLanguage" value="en"/>
<module name="JavadocPackage">
<!-- setting allowLegacy means it will check for package.html instead of just package-info.java -->
<property name="allowLegacy" value="true"/>
<module name="JavadocPackage"/>
<module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf" />
</module>
<module name="FileTabCharacter">
<property name="fileExtensions" value="java,xml"/>
</module>
<module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. -->
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="SuppressionFilter">
<property name="file" value="checkstyle-suppressions.xml"/>
</module>
<module name="TreeWalker">
<property name="cacheFile" value="target/cachefile"/>
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<module name="NeedBraces"/>
<module name="RedundantThrows">
<property name="allowUnchecked" value="true"/>
</module>
<module name="JavadocMethod">
<property name="allowUndeclaredRTE" value="true"/>
<property name="scope" value="public" />
</module>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="UpperEll" />
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
</module>
</module>
......@@ -58,7 +58,11 @@
<!-- Reason: Optimization to use == -->
<Match>
<Class name="org.apache.commons.lang3.StringUtils" />
<Or>
<Method name="indexOfDifference"/>
<Method name="compare" params="java.lang.String,java.lang.String,boolean"/>
<Method name="compareIgnoreCase" params="java.lang.String,java.lang.String,boolean"/>
</Or>
<Bug pattern="ES_COMPARING_PARAMETER_STRING_WITH_EQ" />
</Match>
......@@ -76,34 +80,6 @@
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
</Match>
<!-- Reason: hashCode is lazily loaded in Range classes -->
<!-- TODO: Work out why regex didn't work here -->
<Match>
<Class name="org.apache.commons.lang3.math.DoubleRange" />
<Field name="hashCode" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.lang3.math.FloatRange" />
<Field name="hashCode" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.lang3.math.IntRange" />
<Field name="hashCode" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.lang3.math.LongRange" />
<Field name="hashCode" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<Match>
<Class name="org.apache.commons.lang3.math.NumberRange" />
<Field name="hashCode" />
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED" />
</Match>
<!-- Reason: toProperString is lazily loaded -->
<Match>
<Class name="org.apache.commons.lang3.math.Fraction" />
......@@ -135,12 +111,32 @@
<Method name="insertFormats" />
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
</Match>
<!-- Reason: FindBugs does not correctly recognize default branches in switch statements without break statements.
See, e.g., the report at https://sourceforge.net/p/findbugs/bugs/1298 -->
<Match>
<Class name="org.apache.commons.lang3.time.FastDateParser"/>
<Or>
<Method name="getStrategy" />
<Method name="simpleQuote" params="java.lang.StringBuilder, java.lang.String"/>
</Or>
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
</Match>
<!-- Reason: FindBugs cannot correctly recognize default branches in switch statements without break statements.
See, e.g., the report at https://sourceforge.net/p/findbugs/bugs/1298 -->
<Match>
<Class name="org.apache.commons.lang3.time.FastDatePrinter"/>
<Method name="appendFullDigits" params="java.lang.Appendable, int, int"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
</Match>
<!-- Reason: The fallthrough on the swich statement is intentional -->
<Match>
<Class name="org.apache.commons.lang3.time.FastDatePrinter"/>
<Method name="appendFullDigits" params="java.lang.Appendable, int, int"/>
<Bug pattern="SF_SWITCH_FALLTHROUGH" />
</Match>
<!-- Reason: Internal class that is used only as a key for an internal FormatCache. For this reason we can
be sure, that equals will never be called with null or types other than MultipartKey.
-->
......
......@@ -22,12 +22,11 @@
<parent>
<groupId>org.apache.commons</groupId>
<artifactId>commons-parent</artifactId>
<version>41</version>
<version>42</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
<version>3.7</version>
<name>Apache Commons Lang</name>
<inceptionYear>2001</inceptionYear>
......@@ -48,7 +47,7 @@
<connection>scm:git:http://git-wip-us.apache.org/repos/asf/commons-lang.git</connection>
<developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/commons-lang.git</developerConnection>
<url>https://git-wip-us.apache.org/repos/asf?p=commons-lang.git</url>
<tag>LANG_3_5</tag>
<tag>LANG_3_6</tag>
</scm>
<developers>
......@@ -503,6 +502,9 @@
<contributor>
<name>Adrian Ber</name>
</contributor>
<contributor>
<name>Mark Dacek</name>
</contributor>
</contributors>
<!-- Lang should depend on very little -->
......@@ -521,18 +523,26 @@
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.4</version>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
......@@ -547,8 +557,8 @@
<argLine>-Xmx512m</argLine>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<!--
This is also used to generate download_xxx file name.
To override this when generating the download page:
......@@ -559,9 +569,10 @@
properties that depend on the componentid.
-->
<commons.componentid>lang3</commons.componentid>
<commons.module.name>org.apache.commons.lang3</commons.module.name>
<!-- Current 3.x release series -->
<commons.release.version>3.5</commons.release.version>
<commons.release.desc>(Java 6.0+)</commons.release.desc>
<commons.release.version>3.7</commons.release.version>
<commons.release.desc>(Java 7.0+)</commons.release.desc>
<!-- Previous 2.x release series -->
<commons.release.2.version>2.6</commons.release.2.version>
<commons.release.2.desc>(Requires Java 1.2 or later)</commons.release.2.desc>
......@@ -577,10 +588,33 @@
<!-- Override clirr version to be able to build the site on Java 8 -->
<commons.clirr.version>2.8</commons.clirr.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<!-- JMH Benchmark related properties, version, target compiler and name of the benchmarking uber jar. -->
<jmh.version>1.19</jmh.version>
<uberjar.name>benchmarks</uberjar.name>
</properties>
<build>
<defaultGoal>clean verify apache-rat:check clirr:check checkstyle:check findbugs:check javadoc:javadoc</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
<excludes>
<exclude>site-content/**</exclude>
<exclude>src/site/resources/.htaccess</exclude>
<exclude>src/site/resources/download_lang.cgi</exclude>
<exclude>src/site/resources/release-notes/RELEASE-NOTES-*.txt</exclude>
<exclude>src/test/resources/lang-708-input.txt</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -620,6 +654,14 @@
</goals>
</execution>
</executions>
<!-- Temporary fix for LANG-1338, remove this after this has implemented in parent pom -->
<configuration>
<archive combine.children="append">
<manifestEntries>
<Automatic-Module-Name>org.apache.commons.lang3</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
......@@ -630,6 +672,24 @@
</ignorePathsToDelete>
</configuration>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<enableRulesSummary>false</enableRulesSummary>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<!-- Use version from parent pom as that is adjusted according to the Java version used to run Maven -->
<version>${commons.findbugs.version}</version>
<configuration>
<excludeFilterFile>${basedir}/findbugs-exclude-filter.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>
......@@ -638,9 +698,10 @@
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<version>${checkstyle.plugin.version}</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<enableRulesSummary>false</enableRulesSummary>
</configuration>
<reportSets>
......@@ -663,7 +724,7 @@
</plugin>
<plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.5</version>
<version>3.8</version>
<configuration>
<targetJdk>${maven.compiler.target}</targetJdk>
</configuration>
......@@ -718,19 +779,6 @@
<artifactId>javancss-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
<excludes>
<exclude>site-content/**</exclude>
<exclude>src/site/resources/.htaccess</exclude>
<exclude>src/site/resources/download_lang.cgi</exclude>
<exclude>src/site/resources/release-notes/RELEASE-NOTES-*.txt</exclude>
<exclude>src/test/resources/lang-708-input.txt</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</reporting>
......@@ -780,33 +828,58 @@
</profile>
<profile>
<id>travis</id>
<id>java9</id>
<activation>
<property>
<name>env.TRAVIS</name>
<value>true</value>
</property>
<jdk>9</jdk>
</activation>
<properties>
<!-- LANG-1265: allow tests to access private fields/methods of java.base classes via reflection -->
<argLine>-Xmx512m --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
<!-- versions below 3.0.0 do not work with java 9 -->
<commons.javadoc.version>3.0.0-M1</commons.javadoc.version>
<!-- coverall version 4.3.0 does not work with java 9, see https://github.com/trautonen/coveralls-maven-plugin/issues/112 -->
<coveralls.skip>true</coveralls.skip>
</properties>
</profile>
<profile>
<id>benchmark</id>
<properties>
<skipTests>true</skipTests>
<benchmark>org.apache</benchmark>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${commons.cobertura.version}</version>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>benchmark</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<formats>
<format>xml</format>
</formats>
<classpathScope>test</classpathScope>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>org.openjdk.jmh.Main</argument>
<argument>-rf</argument>
<argument>json</argument>
<argument>-rff</argument>
<argument>target/jmh-result.${benchmark}.json</argument>
<argument>${benchmark}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.1.0</version>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
......@@ -26,6 +26,7 @@
<includes>
<include>.travis.yml</include>
<include>checkstyle.xml</include>
<include>checkstyle-suppressions.xml</include>
<include>findbugs-exclude-filter.xml</include>
<include>LICENSE.txt</include>
<include>NOTICE.txt</include>
......
......@@ -45,7 +45,75 @@ The <action> type attribute can be add,update,fix,remove.
</properties>
<body>
<release version="3.5" date="2014-10-13" description="New features including Java 9 detection">
<release version="3.7" date="2017-11-04" description="New features and bug fixes. Requires Java 7, supports Java 8, 9, 10.">
<action issue="LANG-1362" type="fix" dev="ggregory" due-to="Stephen Colebourne">Fix tests DateUtilsTest for Java 9 with en_GB locale</action>
<action issue="LANG-1365" type="fix" dev="ggregory" due-to="Gary Gregory">Fix NullPointerException in isJavaVersionAtLeast on Java 10, add SystemUtils.IS_JAVA_10, add JavaVersion.JAVA_10</action>
<action issue="LANG-1348" type="fix" dev="pschumacher" due-to="mbusso">StackOverflowError on TypeUtils.toString(...) for a generic return type of Enum.valueOf</action>
<action issue="LANG-1350" type="fix" dev="ggregory" due-to="Brett Kail">ConstructorUtils.invokeConstructor(Class, Object...) regression</action>
<action issue="LANG-1349" type="fix" dev="pschumacher" due-to="Naman Nigam">EqualsBuilder#isRegistered: swappedPair construction bug</action>
<action issue="LANG-1357" type="fix" dev="ggregory" due-to="BruceKuiLiu">org.apache.commons.lang3.time.FastDateParser should use toUpperCase(Locale)</action>
<action issue="LANG-1358" type="update" dev="pschumacher" due-to="Stephane Landelle">Improve StringUtils#replace throughput</action>
<action issue="LANG-1346" type="update" dev="pschumacher">Remove deprecation from RandomStringUtils</action>
<action issue="LANG-1361" type="update" dev="ggregory" due-to="Ana">ExceptionUtils.getThrowableList() is using deprecated ExceptionUtils.getCause()</action>
<action issue="LANG-1355" type="add" dev="ggregory" due-to="Chas Honton">TimeZone.getTimeZone() in FastDateParser causes resource contention (PR #296.)</action>
<action issue="LANG-1360" type="add" dev="ggregory" due-to="Gary Gregory">Add methods to ObjectUtils to get various forms of class names in a null-safe manner</action>
</release>
<release version="3.6" date="2017-06-08" description="New features and bug fixes. Requires Java 7.">
<action issue="LANG-1338" type="update" dev="britter">Add Automatic-Module-Name MANIFEST entry for Java 9 compatibility</action>
<action issue="LANG-1336" type="add" dev="britter" due-to="Beluga Behr">Add NUL Byte To CharUtils</action>
<action issue="LANG-1337" type="fix" dev="kinow">Fix test failures in IBM JDK 8 for ToStringBuilderTest</action>
<action issue="LANG-1304" type="add" dev="pschumacher" due-to="Andy Klimczak">Add method in StringUtils to determine if string contains both mixed cased characters</action>
<action issue="LANG-1334" type="update" dev="djones">Deprecate CharEncoding in favour of java.nio.charset.StandardCharsets</action>
<action issue="LANG-1319" type="fix" dev="djones">MultilineRecursiveToStringStyle StackOverflowError when object is an array</action>
<action issue="LANG-1325" type="add" dev="kinow" due-to="Arshad Basha">Increase test coverage of ToStringBuilder class to 100%</action>
<action issue="LANG-1307" type="add" dev="pschumacher" due-to="Arshad Basha">Add a method in StringUtils to extract only digits out of input string</action>
<action issue="LANG-1110" type="update" dev="pschumacher" due-to="Bruno P. Kinoshita">Implement HashSetvBitSetTest using JMH</action>
<action issue="LANG-1256" type="add" dev="pschumacher" due-to="C0rWin">Add JMH maven dependencies</action>
<action issue="LANG-1167" type="add" dev="chtompki" due-to="Mark Dacek">Add null filter to ReflectionToStringBuilder</action>
<action issue="LANG-1320" type="fix" dev="britter">LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code followed by variant</action>
<action issue="LANG-1300" type="fix" dev="chtompki" due-to="Mark Dacek">Clarify or improve behaviour of int-based indexOf methods in StringUtils</action>
<action issue="LANG-1299" type="add" dev="djones">Add method for converting string to an array of code points</action>
<action issue="LANG-1286" type="fix" dev="djones">RandomStringUtils random method can overflow and return characters outside of specified range</action>
<action issue="LANG-660" type="add" dev="djones">Add methods to insert arrays into arrays at an index</action>
<action issue="LANG-1292" type="fix" dev="djones">WordUtils.wrap throws StringIndexOutOfBoundsException</action>
<action issue="LANG-1287" type="fix" dev="pschumacher" due-to="Ivan Morozov">RandomStringUtils#random can enter infinite loop if end parameter is to small</action>
<action issue="LANG-1285" type="fix" dev="pschumacher" due-to="Francesco Chicchiriccò">NullPointerException in FastDateParser$TimeZoneStrategy</action>
<action issue="LANG-1281" type="fix" dev="pschumacher" due-to="Andreas Lundblad">Javadoc of StringUtils.ordinalIndexOf is contradictory.</action>
<action issue="LANG-1188" type="fix" dev="pschumacher">StringUtils#join(T...): warning: [unchecked] Possible heap pollution from parameterized vararg type T</action>
<action issue="LANG-1144" type="fix" dev="ggregory" due-to="Waldemar Maier, Gary Gregory">Multiple calls of org.apache.commons.lang3.concurrent.LazyInitializer.initialize() are possible.</action>
<action issue="LANG-1276" type="fix" dev="pschumacher" due-to="Andy Klimczak">StrBuilder#replaceAll ArrayIndexOutOfBoundsException</action>
<action issue="LANG-1278" type="fix" dev="pschumacher" due-to="Duke Yin">BooleanUtils javadoc issues</action>
<action issue="LANG-1070" type="fix" dev="pschumacher" due-to="Paul Pogonyshev">ArrayUtils#add confusing example in javadoc</action>
<action issue="LANG-1271" type="fix" dev="pschumacher" due-to="Pierre Templier">StringUtils#isAnyEmpty and #isAnyBlank should return false for an empty array</action>
<action issue="LANG-1155" type="fix" dev="pschumacher" due-to="Saif Asif, Thiago Andrade">Add StringUtils#unwrap</action>
<action issue="LANG-1034" type="add" dev="pschumacher" due-to="Yathos UG">Add support for recursive comparison to EqualsBuilder#reflectionEquals</action>
<action issue="LANG-1067" type="add" dev="pschumacher">Add a reflection-based variant of DiffBuilder</action>
<action issue="LANG-740" type="add" dev="pschumacher" due-to="James Sawle">Implementation of a Memomizer</action>
<action issue="LANG-1258" type="add" dev="pschumacher" due-to="IG, Grzegorz Rożniecki">Add ArrayUtils#toStringArray method</action>
<action issue="LANG-1160" type="add" dev="kinow">StringUtils#abbreviate should support 'custom ellipses' parameter</action>
<action issue="LANG-1293" type="add" dev="pschumacher" due-to="Pierre Templier, Martin Tarjanyi">Add StringUtils#isAllEmpty and #isAllBlank methods</action>
<action issue="LANG-1290" type="update" dev="pschumacher" due-to="Andrii Abramov">Increase test coverage of org.apache.commons.lang3.ArrayUtils</action>
<action issue="LANG-1274" type="update" dev="pschumacher">StrSubstitutor should state its thread safety</action>
<action issue="LANG-1277" type="update" dev="pschumacher" due-to="yufcuy">StringUtils#getLevenshteinDistance reduce memory consumption</action>
<action issue="LANG-1279" type="update" dev="ggregory">Update Java requirement from Java 6 to 7.</action>
<action issue="LANG-1143" type="update" dev="pschumacher" due-to="sebb">StringUtils should use toXxxxCase(int) rather than toXxxxCase(char)</action>
<action issue="LANG-1297" type="update" dev="ggregory">Add SystemUtils.getHostName() API.</action>
<action issue="LANG-1301" type="update" dev="pschumacher" due-to="Karl Heinz Marbaise">Moving apache-rat-plugin configuration into pluginManagement</action>
<action issue="LANG-1311" type="fix" dev="pschumacher" due-to="Aaron Digulla">TypeUtils.toString() doesn't handle primitive and Object arrays correctly</action>
<action issue="LANG-1312" type="fix" dev="pschumacher">LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code</action>
<action issue="LANG-1265" type="fix" dev="pschumacher">Build failures when building with Java 9 EA</action>
<action issue="LANG-1314" type="fix" dev="pschumacher" due-to="Allon Murienik">javadoc creation broken with Java 8</action>
<action issue="LANG-1316" type="update" dev="pschumacher">Deprecate classes/methods moved to commons-text</action>
<action issue="LANG-1310" type="fix" dev="pschumacher" due-to="Don Jeba">MethodUtils.invokeMethod throws ArrayStoreException if using varargs arguments and smaller types than the method defines</action>
<action issue="LANG-1313" type="add" dev="pschumacher" due-to="Tomschi">Add ArchUtils - An utility class for the "os.arch" system property</action>
<action issue="LANG-1272" type="add" dev="ebourg">Add shuffle methods to ArrayUtils</action>
<action issue="LANG-1317" type="add" dev="pschumacher" due-to="Yasser Zamani">Add MethodUtils#findAnnotation and extend MethodUtils#getMethodsWithAnnotation for non-public, super-class and interface methods</action>
<action issue="LANG-1331" type="add" dev="ggregory">Add ImmutablePair.nullPair()</action>
<action issue="LANG-1332" type="add" dev="ggregory">Add ImmutableTriple.nullTriple()</action>
</release>
<release version="3.5" date="2016-10-13" description="New features including Java 9 detection">
<action issue="LANG-1275" type="add" dev="oheger">Added a tryAcquire() method to TimedSemaphore.</action>
<action issue="LANG-1273" type="add" dev="ebourg" due-to="Jake Wang">Added a new property IS_OS_MAC_OSX_EL_CAPITAN in SystemUtils</action>
<action issue="LANG-1255" type="add" dev="britter" due-to="Kaiyuan Wang">Add DateUtils.toCalendar(Date, TimeZone)</action>
......
......@@ -143,9 +143,7 @@ && isValidAnnotationMemberType(m.getReturnType())) {
}
}
}
} catch (final IllegalAccessException ex) {
return false;
} catch (final InvocationTargetException ex) {
} catch (final IllegalAccessException | InvocationTargetException ex) {
return false;
}
return true;
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.lang3;
import org.apache.commons.lang3.arch.Processor;
import java.util.HashMap;
import java.util.Map;
/**
* An utility class for the os.arch System Property. The class defines methods for
* identifying the architecture of the current JVM.
* <p>
* Important: The os.arch System Property returns the architecture used by the JVM
* not of the operating system.
* </p>
* @since 3.6
*/
public class ArchUtils {
private static final Map<String, Processor> ARCH_TO_PROCESSOR;
static {
ARCH_TO_PROCESSOR = new HashMap<>();
init();
}
private static void init() {
init_X86_32Bit();
init_X86_64Bit();
init_IA64_32Bit();
init_IA64_64Bit();
init_PPC_32Bit();
init_PPC_64Bit();
}
private static void init_X86_32Bit() {
final Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.X86);
addProcessors(processor, "x86", "i386", "i486", "i586", "i686", "pentium");
}
private static void init_X86_64Bit() {
final Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.X86);
addProcessors(processor, "x86_64", "amd64", "em64t", "universal");
}
private static void init_IA64_32Bit() {
final Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.IA_64);
addProcessors(processor, "ia64_32", "ia64n");
}
private static void init_IA64_64Bit() {
final Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.IA_64);
addProcessors(processor, "ia64", "ia64w");
}
private static void init_PPC_32Bit() {
final Processor processor = new Processor(Processor.Arch.BIT_32, Processor.Type.PPC);
addProcessors(processor, "ppc", "power", "powerpc", "power_pc", "power_rs");
}
private static void init_PPC_64Bit() {
final Processor processor = new Processor(Processor.Arch.BIT_64, Processor.Type.PPC);
addProcessors(processor, "ppc64", "power64", "powerpc64", "power_pc64", "power_rs64");
}
/**
* Adds the given {@link Processor} with the given key {@link String} to the map.
*
* @param key The key as {@link String}.
* @param processor The {@link Processor} to add.
* @throws IllegalStateException If the key already exists.
*/
private static void addProcessor(final String key, final Processor processor) throws IllegalStateException {
if (!ARCH_TO_PROCESSOR.containsKey(key)) {
ARCH_TO_PROCESSOR.put(key, processor);
} else {
final String msg = "Key " + key + " already exists in processor map";
throw new IllegalStateException(msg);
}
}
/**
* Adds the given {@link Processor} with the given keys to the map.
*
* @param keys The keys.
* @param processor The {@link Processor} to add.
* @throws IllegalStateException If the key already exists.
*/
private static void addProcessors(final Processor processor, final String... keys) throws IllegalStateException {
for (final String key : keys) {
addProcessor(key, processor);
}
}
/**
* Returns a {@link Processor} object of the current JVM.
*
* <p>
* Important: The os.arch System Property returns the architecture used by the JVM
* not of the operating system.
* </p>
*
* @return A {@link Processor} when supported, else <code>null</code>.
*/
public static Processor getProcessor() {
return getProcessor(SystemUtils.OS_ARCH);
}
/**
* Returns a {@link Processor} object the given value {@link String}. The {@link String} must be
* like a value returned by the os.arch System Property.
*
* @param value A {@link String} like a value returned by the os.arch System Property.
* @return A {@link Processor} when it exists, else <code>null</code>.
*/
public static Processor getProcessor(final String value) {
return ARCH_TO_PROCESSOR.get(value);
}
}
......@@ -48,7 +48,7 @@ public BooleanUtils() {
*
* <p>If {@code null} is passed in, {@code null} will be returned.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
* <p>NOTE: This returns null and will throw a NullPointerException if unboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.negate(Boolean.TRUE) = Boolean.FALSE;
......@@ -222,7 +222,7 @@ public static Boolean toBooleanObject(final int value) {
*
* <p>{@code null} will be converted to {@code null}.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
* <p>NOTE: This returns null and will throw a NullPointerException if unboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.toBoolean(Integer.valueOf(0)) = Boolean.FALSE
......@@ -305,7 +305,7 @@ public static boolean toBoolean(final Integer value, final Integer trueValue, fi
/**
* <p>Converts an int to a Boolean specifying the conversion values.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
* <p>NOTE: This returns null and will throw a NullPointerException if unboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.toBooleanObject(0, 0, 2, 3) = Boolean.TRUE
......@@ -337,7 +337,7 @@ public static Boolean toBooleanObject(final int value, final int trueValue, fina
/**
* <p>Converts an Integer to a Boolean specifying the conversion values.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
* <p>NOTE: This returns null and will throw a NullPointerException if unboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.toBooleanObject(Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.TRUE
......@@ -518,7 +518,7 @@ public static Integer toIntegerObject(final Boolean bool, final Integer trueValu
* (case insensitive) will return {@code false}.
* Otherwise, {@code null} is returned.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
* <p>NOTE: This returns null and will throw a NullPointerException if unboxed to a boolean. </p>
*
* <pre>
* // N.B. case is not significant
......@@ -636,7 +636,7 @@ public static Boolean toBooleanObject(final String str) {
/**
* <p>Converts a String to a Boolean throwing an exception if no match.</p>
*
* <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
* <p>NOTE: This returns null and will throw a NullPointerException if unboxed to a boolean. </p>
*
* <pre>
* BooleanUtils.toBooleanObject("true", "true", "false", "null") = Boolean.TRUE
......@@ -1026,9 +1026,6 @@ public static Boolean or(final Boolean... array) {
* BooleanUtils.xor(true, true) = false
* BooleanUtils.xor(false, false) = false
* BooleanUtils.xor(true, false) = true
* BooleanUtils.xor(true, true) = false
* BooleanUtils.xor(false, false) = false
* BooleanUtils.xor(true, false) = true
* </pre>
*
* @param array an array of {@code boolean}s
......@@ -1094,7 +1091,7 @@ public static Boolean xor(final Boolean... array) {
* a value greater than {@code 0} if {@code x && !y}
* @since 3.4
*/
public static int compare(boolean x, boolean y) {
public static int compare(final boolean x, final boolean y) {
if (x == y) {
return 0;
}
......
......@@ -32,7 +32,11 @@
*
* @see <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html">JRE character encoding names</a>
* @since 2.1
* @deprecated Java 7 introduced {@link java.nio.charset.StandardCharsets}, which defines these constants as
* {@link Charset} objects. Use {@link Charset#name()} to get the string values provided in this class.
* This class will be removed in a future release.
*/
@Deprecated
public class CharEncoding {
/**
......@@ -88,7 +92,10 @@ public class CharEncoding {
*
* @param name the name of the requested charset; may be either a canonical name or an alias, null returns false
* @return {@code true} if the charset is available in the current Java virtual machine
* @deprecated Please use {@link Charset#isSupported(String)} instead, although be aware that {@code null}
* values are not accepted by that method and an {@link IllegalCharsetNameException} may be thrown.
*/
@Deprecated
public static boolean isSupported(final String name) {
if (name == null) {
return false;
......
......@@ -179,9 +179,7 @@ public boolean contains(final char ch) {
* @throws IllegalArgumentException if {@code null} input
*/
public boolean contains(final CharRange range) {
if (range == null) {
throw new IllegalArgumentException("The Range must not be null");
}
Validate.isTrue(range != null, "The Range must not be null");
if (negated) {
if (range.negated) {
return start >= range.start && end <= range.end;
......@@ -208,7 +206,7 @@ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof CharRange == false) {
if (!(obj instanceof CharRange)) {
return false;
}
final CharRange other = (CharRange) obj;
......@@ -337,7 +335,7 @@ public boolean hasNext() {
*/
@Override
public Character next() {
if (hasNext == false) {
if (!hasNext) {
throw new NoSuchElementException();
}
final char cur = current;
......
......@@ -59,13 +59,42 @@ public static CharSequence subSequence(final CharSequence cs, final int start) {
//-----------------------------------------------------------------------
/**
* <p>Finds the first index in the {@code CharSequence} that matches the
* specified character.</p>
* Returns the index within <code>cs</code> of the first occurrence of the
* specified character, starting the search at the specified index.
* <p>
* If a character with value <code>searchChar</code> occurs in the
* character sequence represented by the <code>cs</code>
* object at an index no smaller than <code>start</code>, then
* the index of the first such occurrence is returned. For values
* of <code>searchChar</code> in the range from 0 to 0xFFFF (inclusive),
* this is the smallest value <i>k</i> such that:
* <blockquote><pre>
* (this.charAt(<i>k</i>) == searchChar) &amp;&amp; (<i>k</i> &gt;= start)
* </pre></blockquote>
* is true. For other values of <code>searchChar</code>, it is the
* smallest value <i>k</i> such that:
* <blockquote><pre>
* (this.codePointAt(<i>k</i>) == searchChar) &amp;&amp; (<i>k</i> &gt;= start)
* </pre></blockquote>
* is true. In either case, if no such character occurs inm <code>cs</code>
* at or after position <code>start</code>, then
* <code>-1</code> is returned.
*
* <p>
* There is no restriction on the value of <code>start</code>. If it
* is negative, it has the same effect as if it were zero: the entire
* <code>CharSequence</code> may be searched. If it is greater than
* the length of <code>cs</code>, it has the same effect as if it were
* equal to the length of <code>cs</code>: <code>-1</code> is returned.
*
* <p>All indices are specified in <code>char</code> values
* (Unicode code units).
*
* @param cs the {@code CharSequence} to be processed, not null
* @param searchChar the char to be searched for
* @param start the start index, negative starts at the string start
* @return the index where the search char was found, -1 if not found
* @since 3.6 updated to behave more like <code>String</code>
*/
static int indexOf(final CharSequence cs, final int searchChar, int start) {
if (cs instanceof String) {
......@@ -75,11 +104,24 @@ static int indexOf(final CharSequence cs, final int searchChar, int start) {
if (start < 0) {
start = 0;
}
if (searchChar < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
for (int i = start; i < sz; i++) {
if (cs.charAt(i) == searchChar) {
return i;
}
}
}
//supplementary characters (LANG1300)
if (searchChar <= Character.MAX_CODE_POINT) {
final char[] chars = Character.toChars(searchChar);
for (int i = start; i < sz - 1; i++) {
final char high = cs.charAt(i);
final char low = cs.charAt(i + 1);
if (high == chars[0] && low == chars[1]) {
return i;
}
}
}
return NOT_FOUND;
}
......@@ -105,13 +147,30 @@ static int indexOf(final CharSequence cs, final CharSequence searchChar, final i
}
/**
* <p>Finds the last index in the {@code CharSequence} that matches the
* specified character.</p>
* Returns the index within <code>cs</code> of the last occurrence of
* the specified character, searching backward starting at the
* specified index. For values of <code>searchChar</code> in the range
* from 0 to 0xFFFF (inclusive), the index returned is the largest
* value <i>k</i> such that:
* <blockquote><pre>
* (this.charAt(<i>k</i>) == searchChar) &amp;&amp; (<i>k</i> &lt;= start)
* </pre></blockquote>
* is true. For other values of <code>searchChar</code>, it is the
* largest value <i>k</i> such that:
* <blockquote><pre>
* (this.codePointAt(<i>k</i>) == searchChar) &amp;&amp; (<i>k</i> &lt;= start)
* </pre></blockquote>
* is true. In either case, if no such character occurs in <code>cs</code>
* at or before position <code>start</code>, then <code>-1</code> is returned.
*
* <p>All indices are specified in <code>char</code> values
* (Unicode code units).
*
* @param cs the {@code CharSequence} to be processed
* @param searchChar the char to be searched for
* @param start the start index, negative returns -1, beyond length starts at end
* @return the index where the search char was found, -1 if not found
* @since 3.6 updated to behave more like <code>String</code>
*/
static int lastIndexOf(final CharSequence cs, final int searchChar, int start) {
if (cs instanceof String) {
......@@ -124,11 +183,29 @@ static int lastIndexOf(final CharSequence cs, final int searchChar, int start) {
if (start >= sz) {
start = sz - 1;
}
if (searchChar < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
for (int i = start; i >= 0; --i) {
if (cs.charAt(i) == searchChar) {
return i;
}
}
}
//supplementary characters (LANG1300)
//NOTE - we must do a forward traversal for this to avoid duplicating code points
if (searchChar <= Character.MAX_CODE_POINT) {
final char[] chars = Character.toChars(searchChar);
//make sure it's not the last index
if (start == sz - 1) {
return NOT_FOUND;
}
for (int i = start; i >= 0; i--) {
final char high = cs.charAt(i);
final char low = cs.charAt(i + 1);
if (chars[0] == high && chars[1] == low) {
return i;
}
}
}
return NOT_FOUND;
}
......
......@@ -175,9 +175,8 @@ public static CharSet getInstance(final String... setStrs) {
*/
protected CharSet(final String... set) {
super();
final int sz = set.length;
for (int i = 0; i < sz; i++) {
add(set[i]);
for (final String s : set) {
add(s);
}
}
......@@ -264,7 +263,7 @@ public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof CharSet == false) {
if (!(obj instanceof CharSet)) {
return false;
}
final CharSet other = (CharSet) obj;
......