[LANG-1461] Add null-safe StringUtils APIs to wrap

String#getBytes([Charset|String]).</action>

Also fix Javadoc on Java 13 EA 23.
This commit is contained in:
Gary Gregory 2019-06-03 12:20:56 -04:00
parent e5e1339e44
commit 465e6becd8
5 changed files with 14 additions and 15 deletions

View File

@ -1951,7 +1951,7 @@ public class StringUtils {
/**
* Calls {@link String#getBytes(Charset)} in a null-safe manner.
*
* @param string
* @param string input string
* @param charset The {@link Charset} to encode the {@code String}. If null, then use the default Charset.
* @return The empty byte[] if {@code string} is null, the result of {@link String#getBytes(Charset)} otherwise.
* @see String#getBytes(Charset)
@ -1964,7 +1964,7 @@ public class StringUtils {
/**
* Calls {@link String#getBytes(String)} in a null-safe manner.
*
* @param string
* @param string input string
* @param charset The {@link Charset} name to encode the {@code String}. If null, then use the default Charset.
* @return The empty byte[] if {@code string} is null, the result of {@link String#getBytes(String)} otherwise.
* @throws UnsupportedEncodingException Thrown when the named charset is not supported.

View File

@ -19,8 +19,6 @@
* This package is intended to be an extension to {@link java.util.concurrent}.
* These classes are thread-safe.</p>
*
* <h3></h3>
*
* <p> A group of classes deals with the correct creation and initialization of objects that are accessed by multiple threads.
* All these classes implement the {@link org.apache.commons.lang3.concurrent.ConcurrentInitializer} interface which provides just a
* single method:
@ -236,7 +234,7 @@
* It is also possible to pass in an <code>ExecutorService</code> when the initializer is constructed.
* That way client code can configure the <code>ExecutorService</code> according to its specific needs; for instance, the number of threads available could be limited.</p>
*
* <h3>Utility Classes</h3>
* <h2>Utility Classes</h2>
*
* <p>Another group of classes in the new <code>concurrent</code> package offers some generic functionality related to concurrency.
* There is the {@link org.apache.commons.lang3.concurrent.ConcurrentUtils} class with a bunch of static utility methods.
@ -334,7 +332,7 @@
* This factory is then used for creating new threads; after that the specific attributes are applied to the new thread.
* If no wrapped factory is set, the default factory provided by the JDK is used.</p>
*
* <h3>Synchronization objects</h3>
* <h2>Synchronization objects</h2>
*
* <p>The <code>concurrent</code> package also provides some support for specific synchronization problems with threads.</p>
*

View File

@ -35,7 +35,7 @@
* This may seem an odd thing to do, but it allows tools like Velocity to access the class as if it were a bean.
* In other words, yes we know about private constructors and have chosen not to use them.</p>
*
* <h3>String manipulation - StringUtils, StringEscapeUtils, RandomStringUtils</h3>
* <h2>String manipulation - StringUtils, StringEscapeUtils, RandomStringUtils</h2>
*
* <p>Lang has a series of String utilities.
* The first is {@link org.apache.commons.lang3.StringUtils}, oodles and oodles of functions which tweak, transform, squeeze and cuddle {@link java.lang.String java.lang.Strings}.
@ -47,7 +47,7 @@
* <p>These are ideal classes to start using if you're looking to get into Lang.
* StringUtils' {@link org.apache.commons.lang3.StringUtils#capitalize(String)}, {@link org.apache.commons.lang3.StringUtils#substringBetween(String, String)}/{@link org.apache.commons.lang3.StringUtils#substringBefore(String, String) Before}/{@link org.apache.commons.lang3.StringUtils#substringAfter(String, String) After}, {@link org.apache.commons.lang3.StringUtils#split(String)} and {@link org.apache.commons.lang3.StringUtils#join(Object[])} are good methods to begin with.</p>
*
* <h3>Character handling - CharSetUtils, CharSet, CharRange, CharUtils</h3>
* <h2>Character handling - CharSetUtils, CharSet, CharRange, CharUtils</h2>
*
* <p>In addition to dealing with Strings, it's also important to deal with chars and Characters.
* {@link org.apache.commons.lang3.CharUtils} exists for this purpose, while {@link org.apache.commons.lang3.CharSetUtils} exists for set-manipulation of Strings.
@ -56,7 +56,7 @@
*
* <p>{@link org.apache.commons.lang3.CharRange} and {@link org.apache.commons.lang3.CharSet} are both used internally by CharSetUtils, and will probably rarely be used.</p>
*
* <h3>JVM interaction - SystemUtils, CharEncoding</h3>
* <h2>JVM interaction - SystemUtils, CharEncoding</h2>
*
* <p>SystemUtils is a simple little class which makes it easy to find out information about which platform you are on.
* For some, this is a necessary evil. It was never something I expected to use myself until I was trying to ensure that Commons Lang itself compiled under JDK 1.2.
@ -65,7 +65,7 @@
*
* <p>The {@link org.apache.commons.lang3.CharEncoding} class is also used to interact with the Java environment and may be used to see which character encodings are supported in a particular environment. </p>
*
* <h3>Serialization - SerializationUtils, SerializationException</h3>
* <h2>Serialization - SerializationUtils, SerializationException</h2>
*
* <p>Serialization doesn't have to be that hard!
* A simple util class can take away the pain, plus it provides a method to clone an object by unserializing and reserializing, an old Java trick.</p>
@ -114,7 +114,7 @@
* <p>Our final util class is {@link org.apache.commons.lang3.BooleanUtils}.
* It contains various Boolean acting methods, probably of most interest is the {@link org.apache.commons.lang3.BooleanUtils#toBoolean(String)} method which turns various positive/negative Strings into a Boolean object, and not just true/false as with Boolean.valueOf.</p>
*
* <h3>Flotsam - BitField, Validate</h3>
* <h2>Flotsam - BitField, Validate</h2>
* <p>On reaching the end of our package, we are left with a couple of classes that haven't fit any of the topics so far. </p>
* <p>The {@link org.apache.commons.lang3.BitField} class provides a wrapper class around the classic bitmask integer, whilst the {@link org.apache.commons.lang3.Validate} class may be used for assertions (remember, we support Java 1.2). </p>
*

View File

@ -28,8 +28,9 @@ import org.apache.commons.lang3.Validate;
* <p> Utility reflection methods focused on constructors, modeled after
* {@link MethodUtils}. </p>
*
* <h3>Known Limitations</h3> <h4>Accessing Public Constructors In A Default
* Access Superclass</h4> <p>There is an issue when invoking {@code public} constructors
* <h2>Known Limitations</h2>
* <h3>Accessing Public Constructors In A Default Access Superclass</h3>
* <p>There is an issue when invoking {@code public} constructors
* contained in a default access superclass. Reflection correctly locates these
* constructors and assigns them as {@code public}. However, an
* {@link IllegalAccessException} is thrown if the constructor is

View File

@ -43,8 +43,8 @@ import org.apache.commons.lang3.Validate;
* already existed within Lang.
* </p>
*
* <h3>Known Limitations</h3>
* <h4>Accessing Public Methods In A Default Access Superclass</h4>
* <h2>Known Limitations</h2>
* <h3>Accessing Public Methods In A Default Access Superclass</h3>
* <p>There is an issue when invoking {@code public} methods contained in a default access superclass on JREs prior to 1.4.
* Reflection locates these methods fine and correctly assigns them as {@code public}.
* However, an {@link IllegalAccessException} is thrown if the method is invoked.</p>