Modified:
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/RandomUtils.java.html
==============================================================================
---
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/RandomUtils.java.html
(original)
+++
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/RandomUtils.java.html
Thu Aug 29 19:59:17 2024
@@ -28,45 +28,61 @@ import org.apache.commons.lang3.exceptio
/**
* Supplements the standard {@link Random} class.
* <p>
- * Use {@link #secure()} to get the singleton instance based on {@link
SecureRandom#getInstanceStrong()} which uses an
- * algorithms/providers specified in the {@code securerandom.strongAlgorithms}
{@link Security} property.
+ * Use {@link #secure()} to get the singleton instance based on {@link
SecureRandom#SecureRandom()} which uses a secure random number generator
implementing the
+ * default random number algorithm.
* </p>
* <p>
- * Use {@link #insecure()} to get the singleton instance based on {@link
ThreadLocalRandom#current()}; <b>which is not
- * cryptographically secure</b>.
+ * Use {@link #secureStrong()} to get the singleton instance based on {@link
SecureRandom#getInstanceStrong()} which uses an instance that was selected by
using
+ * the algorithms/providers specified in the {@code
securerandom.strongAlgorithms} {@link Security} property.
* </p>
* <p>
- * Starting in version 3.15.0, this class uses {@link
SecureRandom#getInstanceStrong()} for static methods.
+ * Use {@link #insecure()} to get the singleton instance based on {@link
ThreadLocalRandom#current()} <b>which is not cryptographically
secure</b>. In addition,
+ * instances do not use a cryptographically random seed unless the {@linkplain
System#getProperty system property} {@code java.util.secureRandomSeed} is set to
+ * {@code true}.
+ * </p>
+ * <p>
+ * Starting in version 3.17.0, the method {@link #secure()} uses {@link
SecureRandom#SecureRandom()} instead of {@link
SecureRandom#getInstanceStrong()}, and
+ * adds {@link #secureStrong()}.
* </p>
* <p>
* Starting in version 3.16.0, this class uses {@link #secure()} for static
methods and adds {@link #insecure()}.
* </p>
* <p>
- * Before version 3.15.0, this class used {@link ThreadLocalRandom#current()}
for static methods, which is not
- * cryptographically secure.
+ * Starting in version 3.15.0, this class uses {@link
SecureRandom#getInstanceStrong()} for static methods.
+ * </p>
+ * <p>
+ * Before version 3.15.0, this class used {@link ThreadLocalRandom#current()}
for static methods, which is not cryptographically secure.
* </p>
* <p>
* Please note that the Apache Commons project provides a component dedicated
to pseudo-random number generation, namely
- * <a
href="https://commons.apache.org/proper/commons-rng/">Commons
RNG</a>, that may be a better choice for
- * applications with more stringent requirements (performance and/or
correctness).
+ * <a
href="https://commons.apache.org/proper/commons-rng/">Commons
RNG</a>, that may be a better choice for applications with more stringent
requirements
+ * (performance and/or correctness).
* </p>
*
+ * @see #secure()
+ * @see #secureStrong()
+ * @see #insecure()
+ * @see SecureRandom#SecureRandom()
+ * @see SecureRandom#getInstanceStrong()
+ * @see ThreadLocalRandom#current()
* @see RandomStringUtils
* @since 3.3
*/
public class RandomUtils {
-<span class="fc" id="L59"> private static RandomUtils INSECURE = new
RandomUtils(ThreadLocalRandom::current);</span>
+<span class="fc" id="L73"> private static RandomUtils INSECURE = new
RandomUtils(ThreadLocalRandom::current);</span>
-<span class="fc" id="L61"> private static final Supplier<Random>
SECURE_SUPPLIER = () -> RandomUtils.SECURE_RANDOM.get();</span>
+<span class="fc" id="L75"> private static RandomUtils SECURE = new
RandomUtils(SecureRandom::new);</span>
-<span class="fc" id="L63"> private static RandomUtils SECURE = new
RandomUtils(SECURE_SUPPLIER);</span>
+<span class="fc" id="L77"> private static final Supplier<Random>
SECURE_STRONG_SUPPLIER = () -> RandomUtils.SECURE_RANDOM_STRONG.get();</span>
-<span class="fc" id="L65"> private static final
ThreadLocal<SecureRandom> SECURE_RANDOM = ThreadLocal.withInitial(()
-> {</span>
+<span class="fc" id="L79"> private static RandomUtils SECURE_STRONG = new
RandomUtils(SECURE_STRONG_SUPPLIER);</span>
+
+<span class="fc" id="L81"> private static final
ThreadLocal<SecureRandom> SECURE_RANDOM_STRONG =
ThreadLocal.withInitial(() -> {</span>
try {
-<span class="fc" id="L67"> return
SecureRandom.getInstanceStrong();</span>
-<span class="nc" id="L68"> } catch (final NoSuchAlgorithmException e)
{</span>
-<span class="nc" id="L69"> throw new UncheckedException(e);</span>
+<span class="fc" id="L83"> return
SecureRandom.getInstanceStrong();</span>
+<span class="nc" id="L84"> } catch (final NoSuchAlgorithmException e)
{</span>
+<span class="nc" id="L85"> throw new UncheckedException(e);</span>
}
});
@@ -74,7 +90,6 @@ public class RandomUtils {
* Gets the singleton instance based on {@link
ThreadLocalRandom#current()}; <b>which is not cryptographically
* secure</b>; use {@link #secure()} to use an algorithms/providers
specified in the
* {@code securerandom.strongAlgorithms} {@link Security} property.
- * </p>
* <p>
* The method {@link ThreadLocalRandom#current()} is called on-demand.
* </p>
@@ -82,10 +97,10 @@ public class RandomUtils {
* @return the singleton instance based on {@link
ThreadLocalRandom#current()}.
* @see ThreadLocalRandom#current()
* @see #secure()
- * @since 3.16.0
+ * @since 3.17.0
*/
- static RandomUtils insecure() {
-<span class="fc" id="L88"> return INSECURE;</span>
+ public static RandomUtils insecure() {
+<span class="fc" id="L103"> return INSECURE;</span>
}
/**
@@ -93,9 +108,11 @@ public class RandomUtils {
*
* @return the random boolean
* @since 3.5
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static boolean nextBoolean() {
-<span class="fc" id="L98"> return secure().randomBoolean();</span>
+<span class="fc" id="L115"> return secure().randomBoolean();</span>
}
/**
@@ -104,9 +121,11 @@ public class RandomUtils {
* @param count the size of the returned array
* @return the random byte array
* @throws IllegalArgumentException if {@code count} is negative
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static byte[] nextBytes(final int count) {
-<span class="fc" id="L109"> return secure().randomBytes(count);</span>
+<span class="fc" id="L128"> return secure().randomBytes(count);</span>
}
/**
@@ -115,9 +134,11 @@ public class RandomUtils {
* @return the random double
* @see #nextDouble(double, double)
* @since 3.5
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static double nextDouble() {
-<span class="fc" id="L120"> return secure().randomDouble();</span>
+<span class="fc" id="L141"> return secure().randomDouble();</span>
}
/**
@@ -128,9 +149,11 @@ public class RandomUtils {
* @throws IllegalArgumentException if {@code startInclusive >
endExclusive} or if {@code startInclusive} is
* negative
* @return the random double
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static double nextDouble(final double startInclusive, final double
endExclusive) {
-<span class="fc" id="L133"> return
secure().randomDouble(startInclusive, endExclusive);</span>
+<span class="fc" id="L156"> return
secure().randomDouble(startInclusive, endExclusive);</span>
}
/**
@@ -139,9 +162,11 @@ public class RandomUtils {
* @return the random float
* @see #nextFloat(float, float)
* @since 3.5
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static float nextFloat() {
-<span class="fc" id="L144"> return secure().randomFloat();</span>
+<span class="fc" id="L169"> return secure().randomFloat();</span>
}
/**
@@ -152,9 +177,11 @@ public class RandomUtils {
* @throws IllegalArgumentException if {@code startInclusive >
endExclusive} or if {@code startInclusive} is
* negative
* @return the random float
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static float nextFloat(final float startInclusive, final float
endExclusive) {
-<span class="fc" id="L157"> return secure().randomFloat(startInclusive,
endExclusive);</span>
+<span class="fc" id="L184"> return secure().randomFloat(startInclusive,
endExclusive);</span>
}
/**
@@ -163,9 +190,11 @@ public class RandomUtils {
* @return the random integer
* @see #nextInt(int, int)
* @since 3.5
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static int nextInt() {
-<span class="fc" id="L168"> return secure().randomInt();</span>
+<span class="fc" id="L197"> return secure().randomInt();</span>
}
/**
@@ -176,9 +205,11 @@ public class RandomUtils {
* @throws IllegalArgumentException if {@code startInclusive >
endExclusive} or if {@code startInclusive} is
* negative
* @return the random integer
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static int nextInt(final int startInclusive, final int
endExclusive) {
-<span class="fc" id="L181"> return secure().randomInt(startInclusive,
endExclusive);</span>
+<span class="fc" id="L212"> return secure().randomInt(startInclusive,
endExclusive);</span>
}
/**
@@ -187,19 +218,11 @@ public class RandomUtils {
* @return the random long
* @see #nextLong(long, long)
* @since 3.5
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static long nextLong() {
-<span class="fc" id="L192"> return secure().randomLong();</span>
- }
-
- /**
- * Generates a {@code long} value between 0 (inclusive) and the specified
value (exclusive).
- *
- * @param n Bound on the random number to be returned. Must be positive.
- * @return a random {@code long} value between 0 (inclusive) and {@code n}
(exclusive).
- */
- private static long nextLong(final long n) {
-<span class="fc" id="L202"> return secure().randomLong(n);</span>
+<span class="fc" id="L225"> return secure().randomLong();</span>
}
/**
@@ -210,28 +233,45 @@ public class RandomUtils {
* @throws IllegalArgumentException if {@code startInclusive >
endExclusive} or if {@code startInclusive} is
* negative
* @return the random long
+ * @deprecated Use {@link #secure()}, {@link #secureStrong()},or {@link
#insecure()}.
*/
+ @Deprecated
public static long nextLong(final long startInclusive, final long
endExclusive) {
-<span class="fc" id="L215"> return secure().randomLong(startInclusive,
endExclusive);</span>
+<span class="fc" id="L240"> return secure().randomLong(startInclusive,
endExclusive);</span>
}
/**
- * Gets the singleton instance based on {@link
SecureRandom#getInstanceStrong()} which uses an algorithms/providers
+ * Gets the singleton instance based on {@link
SecureRandom#SecureRandom()} which uses an algorithms/providers
* specified in the {@code securerandom.strongAlgorithms} {@link Security}
property.
* <p>
- * The method {@link SecureRandom#getInstanceStrong()} is called on-demand.
+ * The method {@link SecureRandom#SecureRandom()} is called on-demand.
* </p>
*
- * @return the singleton instance based on {@link
SecureRandom#getInstanceStrong()}.
- * @see SecureRandom#getInstanceStrong()
+ * @return the singleton instance based on {@link
SecureRandom#SecureRandom()}.
+ * @see SecureRandom#SecureRandom()
* @since 3.16.0
*/
public static RandomUtils secure() {
-<span class="fc" id="L230"> return SECURE;</span>
+<span class="fc" id="L255"> return SECURE;</span>
}
static SecureRandom secureRandom() {
-<span class="nc" id="L234"> return SECURE_RANDOM.get();</span>
+<span class="nc" id="L259"> return SECURE_RANDOM_STRONG.get();</span>
+ }
+
+ /**
+ * Gets the singleton instance based on {@link
SecureRandom#getInstanceStrong()} which uses an algorithms/providers
+ * specified in the {@code securerandom.strongAlgorithms} {@link Security}
property.
+ * <p>
+ * The method {@link SecureRandom#getInstanceStrong()} is called on-demand.
+ * </p>
+ *
+ * @return the singleton instance based on {@link
SecureRandom#getInstanceStrong()}.
+ * @see SecureRandom#getInstanceStrong()
+ * @since 3.17.0
+ */
+ public static RandomUtils secureStrong() {
+<span class="fc" id="L274"> return SECURE_STRONG;</span>
}
private final Supplier<Random> random;
@@ -247,15 +287,15 @@ public class RandomUtils {
*/
@Deprecated
public RandomUtils() {
-<span class="fc" id="L250"> this(SECURE_SUPPLIER);</span>
-<span class="fc" id="L251"> }</span>
+<span class="fc" id="L290"> this(SECURE_STRONG_SUPPLIER);</span>
+<span class="fc" id="L291"> }</span>
-<span class="fc" id="L253"> private RandomUtils(final
Supplier<Random> random) {</span>
-<span class="fc" id="L254"> this.random = random;</span>
-<span class="fc" id="L255"> }</span>
+<span class="fc" id="L293"> private RandomUtils(final
Supplier<Random> random) {</span>
+<span class="fc" id="L294"> this.random = random;</span>
+<span class="fc" id="L295"> }</span>
Random random() {
-<span class="fc" id="L258"> return random.get();</span>
+<span class="fc" id="L298"> return random.get();</span>
}
/**
@@ -265,7 +305,7 @@ public class RandomUtils {
* @since 3.16.0
*/
public boolean randomBoolean() {
-<span class="fc" id="L268"> return random().nextBoolean();</span>
+<span class="fc" id="L308"> return random().nextBoolean();</span>
}
/**
@@ -277,21 +317,21 @@ public class RandomUtils {
* @since 3.16.0
*/
public byte[] randomBytes(final int count) {
-<span class="fc bfc" id="L280" title="All 2 branches covered.">
Validate.isTrue(count >= 0, "Count cannot be negative.");</span>
-<span class="fc" id="L281"> final byte[] result = new
byte[count];</span>
-<span class="fc" id="L282"> random().nextBytes(result);</span>
-<span class="fc" id="L283"> return result;</span>
+<span class="fc bfc" id="L320" title="All 2 branches covered.">
Validate.isTrue(count >= 0, "Count cannot be negative.");</span>
+<span class="fc" id="L321"> final byte[] result = new
byte[count];</span>
+<span class="fc" id="L322"> random().nextBytes(result);</span>
+<span class="fc" id="L323"> return result;</span>
}
/**
* Generates a random double between 0 (inclusive) and Double.MAX_VALUE
(exclusive).
*
* @return the random double
- * @see #nextDouble(double, double)
+ * @see #randomDouble(double, double)
* @since 3.16.0
*/
public double randomDouble() {
-<span class="fc" id="L294"> return nextDouble(0,
Double.MAX_VALUE);</span>
+<span class="fc" id="L334"> return randomDouble(0,
Double.MAX_VALUE);</span>
}
/**
@@ -305,23 +345,23 @@ public class RandomUtils {
* @since 3.16.0
*/
public double randomDouble(final double startInclusive, final double
endExclusive) {
-<span class="fc bfc" id="L308" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
-<span class="fc bfc" id="L309" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
-<span class="fc bfc" id="L310" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
-<span class="fc" id="L311"> return startInclusive;</span>
+<span class="fc bfc" id="L348" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
+<span class="fc bfc" id="L349" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
+<span class="fc bfc" id="L350" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
+<span class="fc" id="L351"> return startInclusive;</span>
}
-<span class="fc" id="L313"> return startInclusive + (endExclusive -
startInclusive) * random().nextDouble();</span>
+<span class="fc" id="L353"> return startInclusive + (endExclusive -
startInclusive) * random().nextDouble();</span>
}
/**
* Generates a random float between 0 (inclusive) and Float.MAX_VALUE
(exclusive).
*
* @return the random float
- * @see #nextFloat(float, float)
+ * @see #randomFloat(float, float)
* @since 3.16.0
*/
public float randomFloat() {
-<span class="fc" id="L324"> return nextFloat(0, Float.MAX_VALUE);</span>
+<span class="fc" id="L364"> return randomFloat(0,
Float.MAX_VALUE);</span>
}
/**
@@ -334,23 +374,23 @@ public class RandomUtils {
* @return the random float
*/
public float randomFloat(final float startInclusive, final float
endExclusive) {
-<span class="fc bfc" id="L337" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
-<span class="fc bfc" id="L338" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
-<span class="fc bfc" id="L339" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
-<span class="fc" id="L340"> return startInclusive;</span>
+<span class="fc bfc" id="L377" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
+<span class="fc bfc" id="L378" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
+<span class="fc bfc" id="L379" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
+<span class="fc" id="L380"> return startInclusive;</span>
}
-<span class="fc" id="L342"> return startInclusive + (endExclusive -
startInclusive) * random().nextFloat();</span>
+<span class="fc" id="L382"> return startInclusive + (endExclusive -
startInclusive) * random().nextFloat();</span>
}
/**
* Generates a random int between 0 (inclusive) and Integer.MAX_VALUE
(exclusive).
*
* @return the random integer
- * @see #nextInt(int, int)
+ * @see #randomInt(int, int)
* @since 3.16.0
*/
public int randomInt() {
-<span class="fc" id="L353"> return nextInt(0, Integer.MAX_VALUE);</span>
+<span class="fc" id="L393"> return randomInt(0,
Integer.MAX_VALUE);</span>
}
/**
@@ -364,23 +404,23 @@ public class RandomUtils {
* @since 3.16.0
*/
public int randomInt(final int startInclusive, final int endExclusive) {
-<span class="fc bfc" id="L367" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
-<span class="fc bfc" id="L368" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
-<span class="fc bfc" id="L369" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
-<span class="fc" id="L370"> return startInclusive;</span>
+<span class="fc bfc" id="L407" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
+<span class="fc bfc" id="L408" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
+<span class="fc bfc" id="L409" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
+<span class="fc" id="L410"> return startInclusive;</span>
}
-<span class="fc" id="L372"> return startInclusive +
random().nextInt(endExclusive - startInclusive);</span>
+<span class="fc" id="L412"> return startInclusive +
random().nextInt(endExclusive - startInclusive);</span>
}
/**
* Generates a random long between 0 (inclusive) and Long.MAX_VALUE
(exclusive).
*
* @return the random long
- * @see #nextLong(long, long)
+ * @see #randomLong(long, long)
* @since 3.16.0
*/
public long randomLong() {
-<span class="fc" id="L383"> return nextLong(Long.MAX_VALUE);</span>
+<span class="fc" id="L423"> return randomLong(Long.MAX_VALUE);</span>
}
/**
@@ -394,10 +434,10 @@ public class RandomUtils {
long bits;
long val;
do {
-<span class="fc" id="L397"> bits = random().nextLong() >>>
1;</span>
-<span class="fc" id="L398"> val = bits % n;</span>
-<span class="pc bpc" id="L399" title="1 of 2 branches missed."> } while
(bits - val + n - 1 < 0);</span>
-<span class="fc" id="L400"> return val;</span>
+<span class="fc" id="L437"> bits = random().nextLong() >>>
1;</span>
+<span class="fc" id="L438"> val = bits % n;</span>
+<span class="pc bpc" id="L439" title="1 of 2 branches missed."> } while
(bits - val + n - 1 < 0);</span>
+<span class="fc" id="L440"> return val;</span>
}
/**
@@ -411,17 +451,17 @@ public class RandomUtils {
* @since 3.16.0
*/
public long randomLong(final long startInclusive, final long endExclusive)
{
-<span class="fc bfc" id="L414" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
-<span class="fc bfc" id="L415" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
-<span class="fc bfc" id="L416" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
-<span class="fc" id="L417"> return startInclusive;</span>
+<span class="fc bfc" id="L454" title="All 2 branches covered.">
Validate.isTrue(endExclusive >= startInclusive, "Start value must be
smaller or equal to end value.");</span>
+<span class="fc bfc" id="L455" title="All 2 branches covered.">
Validate.isTrue(startInclusive >= 0, "Both range values must be
non-negative.");</span>
+<span class="fc bfc" id="L456" title="All 2 branches covered."> if
(startInclusive == endExclusive) {</span>
+<span class="fc" id="L457"> return startInclusive;</span>
}
-<span class="fc" id="L419"> return startInclusive +
nextLong(endExclusive - startInclusive);</span>
+<span class="fc" id="L459"> return startInclusive +
randomLong(endExclusive - startInclusive);</span>
}
@Override
public String toString() {
-<span class="fc" id="L424"> return "RandomUtils [random=" +
random() + "]";</span>
+<span class="fc" id="L464"> return "RandomUtils [random=" +
random() + "]";</span>
}
}
Modified:
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/StringUtils.html
==============================================================================
---
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/StringUtils.html
(original)
+++
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/StringUtils.html
Thu Aug 29 19:59:17 2024
@@ -1 +1 @@
[... 5 lines stripped ...]
Modified:
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/StringUtils.java.html
==============================================================================
---
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/StringUtils.java.html
(original)
+++
websites/production/commons/content/proper/commons-lang/jacoco/org.apache.commons.lang3/StringUtils.java.html
Thu Aug 29 19:59:17 2024
@@ -9031,20 +9031,18 @@ public class StringUtils {
* @param charsetName
* the encoding to use, if null then use the platform default
* @return a new String
- * @throws UnsupportedEncodingException
- * Never thrown
* @throws NullPointerException
* if the input is null
* @deprecated use {@link StringUtils#toEncodedString(byte[], Charset)}
instead of String constants in your code
* @since 3.1
*/
@Deprecated
- public static String toString(final byte[] bytes, final String
charsetName) throws UnsupportedEncodingException {
-<span class="fc" id="L9043"> return new String(bytes,
Charsets.toCharset(charsetName));</span>
+ public static String toString(final byte[] bytes, final String
charsetName) {
+<span class="fc" id="L9041"> return new String(bytes,
Charsets.toCharset(charsetName));</span>
}
private static String toStringOrEmpty(final Object obj) {
-<span class="fc" id="L9047"> return Objects.toString(obj, EMPTY);</span>
+<span class="fc" id="L9045"> return Objects.toString(obj, EMPTY);</span>
}
/**
@@ -9071,7 +9069,7 @@ public class StringUtils {
* @return the trimmed string, {@code null} if null String input
*/
public static String trim(final String str) {
-<span class="fc bfc" id="L9074" title="All 2 branches covered."> return
str == null ? null : str.trim();</span>
+<span class="fc bfc" id="L9072" title="All 2 branches covered."> return
str == null ? null : str.trim();</span>
}
/**
@@ -9096,7 +9094,7 @@ public class StringUtils {
* @since 2.0
*/
public static String trimToEmpty(final String str) {
-<span class="fc bfc" id="L9099" title="All 2 branches covered."> return
str == null ? EMPTY : str.trim();</span>
+<span class="fc bfc" id="L9097" title="All 2 branches covered."> return
str == null ? EMPTY : str.trim();</span>
}
/**
@@ -9122,8 +9120,8 @@ public class StringUtils {
* @since 2.0
*/
public static String trimToNull(final String str) {
-<span class="fc" id="L9125"> final String ts = trim(str);</span>
-<span class="fc bfc" id="L9126" title="All 2 branches covered."> return
isEmpty(ts) ? null : ts;</span>
+<span class="fc" id="L9123"> final String ts = trim(str);</span>
+<span class="fc bfc" id="L9124" title="All 2 branches covered."> return
isEmpty(ts) ? null : ts;</span>
}
/**
@@ -9159,7 +9157,7 @@ public class StringUtils {
* @since 3.5
*/
public static String truncate(final String str, final int maxWidth) {
-<span class="fc" id="L9162"> return truncate(str, 0, maxWidth);</span>
+<span class="fc" id="L9160"> return truncate(str, 0, maxWidth);</span>
}
/**
@@ -9223,23 +9221,23 @@ public class StringUtils {
* @since 3.5
*/
public static String truncate(final String str, final int offset, final
int maxWidth) {
-<span class="fc bfc" id="L9226" title="All 2 branches covered."> if
(offset < 0) {</span>
-<span class="fc" id="L9227"> throw new
IllegalArgumentException("offset cannot be negative");</span>
+<span class="fc bfc" id="L9224" title="All 2 branches covered."> if
(offset < 0) {</span>
+<span class="fc" id="L9225"> throw new
IllegalArgumentException("offset cannot be negative");</span>
}
-<span class="fc bfc" id="L9229" title="All 2 branches covered."> if
(maxWidth < 0) {</span>
-<span class="fc" id="L9230"> throw new
IllegalArgumentException("maxWith cannot be negative");</span>
+<span class="fc bfc" id="L9227" title="All 2 branches covered."> if
(maxWidth < 0) {</span>
+<span class="fc" id="L9228"> throw new
IllegalArgumentException("maxWith cannot be negative");</span>
}
-<span class="fc bfc" id="L9232" title="All 2 branches covered."> if
(str == null) {</span>
-<span class="fc" id="L9233"> return null;</span>
+<span class="fc bfc" id="L9230" title="All 2 branches covered."> if
(str == null) {</span>
+<span class="fc" id="L9231"> return null;</span>
}
-<span class="fc bfc" id="L9235" title="All 2 branches covered."> if
(offset > str.length()) {</span>
-<span class="fc" id="L9236"> return EMPTY;</span>
+<span class="fc bfc" id="L9233" title="All 2 branches covered."> if
(offset > str.length()) {</span>
+<span class="fc" id="L9234"> return EMPTY;</span>
}
-<span class="fc bfc" id="L9238" title="All 2 branches covered."> if
(str.length() > maxWidth) {</span>
-<span class="fc" id="L9239"> final int ix = Math.min(offset +
maxWidth, str.length());</span>
-<span class="fc" id="L9240"> return str.substring(offset,
ix);</span>
+<span class="fc bfc" id="L9236" title="All 2 branches covered."> if
(str.length() > maxWidth) {</span>
+<span class="fc" id="L9237"> final int ix = Math.min(offset +
maxWidth, str.length());</span>
+<span class="fc" id="L9238"> return str.substring(offset,
ix);</span>
}
-<span class="fc" id="L9242"> return str.substring(offset);</span>
+<span class="fc" id="L9240"> return str.substring(offset);</span>
}
/**
@@ -9264,27 +9262,27 @@ public class StringUtils {
* @since 2.0
*/
public static String uncapitalize(final String str) {
-<span class="fc" id="L9267"> final int strLen = length(str);</span>
-<span class="fc bfc" id="L9268" title="All 2 branches covered."> if
(strLen == 0) {</span>
-<span class="fc" id="L9269"> return str;</span>
+<span class="fc" id="L9265"> final int strLen = length(str);</span>
+<span class="fc bfc" id="L9266" title="All 2 branches covered."> if
(strLen == 0) {</span>
+<span class="fc" id="L9267"> return str;</span>
}
-<span class="fc" id="L9272"> final int firstCodePoint =
str.codePointAt(0);</span>
-<span class="fc" id="L9273"> final int newCodePoint =
Character.toLowerCase(firstCodePoint);</span>
-<span class="fc bfc" id="L9274" title="All 2 branches covered."> if
(firstCodePoint == newCodePoint) {</span>
+<span class="fc" id="L9270"> final int firstCodePoint =
str.codePointAt(0);</span>
+<span class="fc" id="L9271"> final int newCodePoint =
Character.toLowerCase(firstCodePoint);</span>
+<span class="fc bfc" id="L9272" title="All 2 branches covered."> if
(firstCodePoint == newCodePoint) {</span>
// already capitalized
-<span class="fc" id="L9276"> return str;</span>
+<span class="fc" id="L9274"> return str;</span>
}
-<span class="fc" id="L9279"> final int[] newCodePoints = new
int[strLen]; // cannot be longer than the char array</span>
-<span class="fc" id="L9280"> int outOffset = 0;</span>
-<span class="fc" id="L9281"> newCodePoints[outOffset++] = newCodePoint;
// copy the first code point</span>
-<span class="fc bfc" id="L9282" title="All 2 branches covered."> for
(int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; )
{</span>
-<span class="fc" id="L9283"> final int codePoint =
str.codePointAt(inOffset);</span>
-<span class="fc" id="L9284"> newCodePoints[outOffset++] =
codePoint; // copy the remaining ones</span>
-<span class="fc" id="L9285"> inOffset +=
Character.charCount(codePoint);</span>
-<span class="fc" id="L9286"> }</span>
-<span class="fc" id="L9287"> return new String(newCodePoints, 0,
outOffset);</span>
+<span class="fc" id="L9277"> final int[] newCodePoints = new
int[strLen]; // cannot be longer than the char array</span>
+<span class="fc" id="L9278"> int outOffset = 0;</span>
+<span class="fc" id="L9279"> newCodePoints[outOffset++] = newCodePoint;
// copy the first code point</span>
+<span class="fc bfc" id="L9280" title="All 2 branches covered."> for
(int inOffset = Character.charCount(firstCodePoint); inOffset < strLen; )
{</span>
+<span class="fc" id="L9281"> final int codePoint =
str.codePointAt(inOffset);</span>
+<span class="fc" id="L9282"> newCodePoints[outOffset++] =
codePoint; // copy the remaining ones</span>
+<span class="fc" id="L9283"> inOffset +=
Character.charCount(codePoint);</span>
+<span class="fc" id="L9284"> }</span>
+<span class="fc" id="L9285"> return new String(newCodePoints, 0,
outOffset);</span>
}
/**
@@ -9312,18 +9310,18 @@ public class StringUtils {
* @since 3.6
*/
public static String unwrap(final String str, final char wrapChar) {
-<span class="pc bpc" id="L9315" title="2 of 6 branches missed."> if
(isEmpty(str) || wrapChar == CharUtils.NUL || str.length() == 1) {</span>
-<span class="fc" id="L9316"> return str;</span>
+<span class="pc bpc" id="L9313" title="2 of 6 branches missed."> if
(isEmpty(str) || wrapChar == CharUtils.NUL || str.length() == 1) {</span>
+<span class="fc" id="L9314"> return str;</span>
}
-<span class="fc bfc" id="L9319" title="All 4 branches covered."> if
(str.charAt(0) == wrapChar && str.charAt(str.length() - 1) == wrapChar)
{</span>
-<span class="fc" id="L9320"> final int startIndex = 0;</span>
-<span class="fc" id="L9321"> final int endIndex = str.length() -
1;</span>
+<span class="fc bfc" id="L9317" title="All 4 branches covered."> if
(str.charAt(0) == wrapChar && str.charAt(str.length() - 1) == wrapChar)
{</span>
+<span class="fc" id="L9318"> final int startIndex = 0;</span>
+<span class="fc" id="L9319"> final int endIndex = str.length() -
1;</span>
-<span class="fc" id="L9323"> return str.substring(startIndex + 1,
endIndex);</span>
+<span class="fc" id="L9321"> return str.substring(startIndex + 1,
endIndex);</span>
}
-<span class="fc" id="L9326"> return str;</span>
+<span class="fc" id="L9324"> return str;</span>
}
/**
@@ -9352,15 +9350,15 @@ public class StringUtils {
* @since 3.6
*/
public static String unwrap(final String str, final String wrapToken) {
-<span class="fc bfc" id="L9355" title="All 6 branches covered."> if
(isEmpty(str) || isEmpty(wrapToken) || str.length() < 2 *
wrapToken.length()) {</span>
-<span class="fc" id="L9356"> return str;</span>
+<span class="fc bfc" id="L9353" title="All 6 branches covered."> if
(isEmpty(str) || isEmpty(wrapToken) || str.length() < 2 *
wrapToken.length()) {</span>
+<span class="fc" id="L9354"> return str;</span>
}
-<span class="fc bfc" id="L9359" title="All 4 branches covered."> if
(startsWith(str, wrapToken) && endsWith(str, wrapToken)) {</span>
-<span class="fc" id="L9360"> return
str.substring(wrapToken.length(), str.lastIndexOf(wrapToken));</span>
+<span class="fc bfc" id="L9357" title="All 4 branches covered."> if
(startsWith(str, wrapToken) && endsWith(str, wrapToken)) {</span>
+<span class="fc" id="L9358"> return
str.substring(wrapToken.length(), str.lastIndexOf(wrapToken));</span>
}
-<span class="fc" id="L9363"> return str;</span>
+<span class="fc" id="L9361"> return str;</span>
}
/**
@@ -9383,10 +9381,10 @@ public class StringUtils {
* @return the upper-cased String, {@code null} if null String input
*/
public static String upperCase(final String str) {
-<span class="fc bfc" id="L9386" title="All 2 branches covered."> if
(str == null) {</span>
-<span class="fc" id="L9387"> return null;</span>
+<span class="fc bfc" id="L9384" title="All 2 branches covered."> if
(str == null) {</span>
+<span class="fc" id="L9385"> return null;</span>
}
-<span class="fc" id="L9389"> return str.toUpperCase();</span>
+<span class="fc" id="L9387"> return str.toUpperCase();</span>
}
/**
@@ -9406,10 +9404,10 @@ public class StringUtils {
* @since 2.5
*/
public static String upperCase(final String str, final Locale locale) {
-<span class="fc bfc" id="L9409" title="All 2 branches covered."> if
(str == null) {</span>
-<span class="fc" id="L9410"> return null;</span>
+<span class="fc bfc" id="L9407" title="All 2 branches covered."> if
(str == null) {</span>
+<span class="fc" id="L9408"> return null;</span>
}
-<span class="fc" id="L9412"> return
str.toUpperCase(LocaleUtils.toLocale(locale));</span>
+<span class="fc" id="L9410"> return
str.toUpperCase(LocaleUtils.toLocale(locale));</span>
}
/**
@@ -9421,7 +9419,7 @@ public class StringUtils {
* @since 3.9
*/
public static String valueOf(final char[] value) {
-<span class="fc bfc" id="L9424" title="All 2 branches covered."> return
value == null ? null : String.valueOf(value);</span>
+<span class="fc bfc" id="L9422" title="All 2 branches covered."> return
value == null ? null : String.valueOf(value);</span>
}
/**
@@ -9445,11 +9443,11 @@ public class StringUtils {
*/
public static String wrap(final String str, final char wrapWith) {
-<span class="pc bpc" id="L9448" title="1 of 4 branches missed."> if
(isEmpty(str) || wrapWith == CharUtils.NUL) {</span>
-<span class="fc" id="L9449"> return str;</span>
+<span class="pc bpc" id="L9446" title="1 of 4 branches missed."> if
(isEmpty(str) || wrapWith == CharUtils.NUL) {</span>
+<span class="fc" id="L9447"> return str;</span>
}
-<span class="fc" id="L9452"> return wrapWith + str + wrapWith;</span>
+<span class="fc" id="L9450"> return wrapWith + str + wrapWith;</span>
}
/**
@@ -9481,11 +9479,11 @@ public class StringUtils {
*/
public static String wrap(final String str, final String wrapWith) {
-<span class="fc bfc" id="L9484" title="All 4 branches covered."> if
(isEmpty(str) || isEmpty(wrapWith)) {</span>
-<span class="fc" id="L9485"> return str;</span>
+<span class="fc bfc" id="L9482" title="All 4 branches covered."> if
(isEmpty(str) || isEmpty(wrapWith)) {</span>
+<span class="fc" id="L9483"> return str;</span>
}
-<span class="fc" id="L9488"> return
wrapWith.concat(str).concat(wrapWith);</span>
+<span class="fc" id="L9486"> return
wrapWith.concat(str).concat(wrapWith);</span>
}
/**
@@ -9514,24 +9512,24 @@ public class StringUtils {
* @since 3.5
*/
public static String wrapIfMissing(final String str, final char wrapWith) {
-<span class="pc bpc" id="L9517" title="1 of 4 branches missed."> if
(isEmpty(str) || wrapWith == CharUtils.NUL) {</span>
-<span class="fc" id="L9518"> return str;</span>
+<span class="pc bpc" id="L9515" title="1 of 4 branches missed."> if
(isEmpty(str) || wrapWith == CharUtils.NUL) {</span>
+<span class="fc" id="L9516"> return str;</span>
}
-<span class="fc bfc" id="L9520" title="All 2 branches covered."> final
boolean wrapStart = str.charAt(0) != wrapWith;</span>
-<span class="fc bfc" id="L9521" title="All 2 branches covered."> final
boolean wrapEnd = str.charAt(str.length() - 1) != wrapWith;</span>
-<span class="fc bfc" id="L9522" title="All 4 branches covered."> if
(!wrapStart && !wrapEnd) {</span>
-<span class="fc" id="L9523"> return str;</span>
+<span class="fc bfc" id="L9518" title="All 2 branches covered."> final
boolean wrapStart = str.charAt(0) != wrapWith;</span>
+<span class="fc bfc" id="L9519" title="All 2 branches covered."> final
boolean wrapEnd = str.charAt(str.length() - 1) != wrapWith;</span>
+<span class="fc bfc" id="L9520" title="All 4 branches covered."> if
(!wrapStart && !wrapEnd) {</span>
+<span class="fc" id="L9521"> return str;</span>
}
-<span class="fc" id="L9526"> final StringBuilder builder = new
StringBuilder(str.length() + 2);</span>
-<span class="fc bfc" id="L9527" title="All 2 branches covered."> if
(wrapStart) {</span>
-<span class="fc" id="L9528"> builder.append(wrapWith);</span>
+<span class="fc" id="L9524"> final StringBuilder builder = new
StringBuilder(str.length() + 2);</span>
+<span class="fc bfc" id="L9525" title="All 2 branches covered."> if
(wrapStart) {</span>
+<span class="fc" id="L9526"> builder.append(wrapWith);</span>
}
-<span class="fc" id="L9530"> builder.append(str);</span>
-<span class="fc bfc" id="L9531" title="All 2 branches covered."> if
(wrapEnd) {</span>
-<span class="fc" id="L9532"> builder.append(wrapWith);</span>
+<span class="fc" id="L9528"> builder.append(str);</span>
+<span class="fc bfc" id="L9529" title="All 2 branches covered."> if
(wrapEnd) {</span>
+<span class="fc" id="L9530"> builder.append(wrapWith);</span>
}
-<span class="fc" id="L9534"> return builder.toString();</span>
+<span class="fc" id="L9532"> return builder.toString();</span>
}
/**
@@ -9564,25 +9562,25 @@ public class StringUtils {
* @since 3.5
*/
public static String wrapIfMissing(final String str, final String
wrapWith) {
-<span class="pc bpc" id="L9567" title="1 of 4 branches missed."> if
(isEmpty(str) || isEmpty(wrapWith)) {</span>
-<span class="fc" id="L9568"> return str;</span>
+<span class="pc bpc" id="L9565" title="1 of 4 branches missed."> if
(isEmpty(str) || isEmpty(wrapWith)) {</span>
+<span class="fc" id="L9566"> return str;</span>
}
-<span class="fc bfc" id="L9571" title="All 2 branches covered."> final
boolean wrapStart = !str.startsWith(wrapWith);</span>
-<span class="fc bfc" id="L9572" title="All 2 branches covered."> final
boolean wrapEnd = !str.endsWith(wrapWith);</span>
-<span class="fc bfc" id="L9573" title="All 4 branches covered."> if
(!wrapStart && !wrapEnd) {</span>
-<span class="fc" id="L9574"> return str;</span>
+<span class="fc bfc" id="L9569" title="All 2 branches covered."> final
boolean wrapStart = !str.startsWith(wrapWith);</span>
+<span class="fc bfc" id="L9570" title="All 2 branches covered."> final
boolean wrapEnd = !str.endsWith(wrapWith);</span>
+<span class="fc bfc" id="L9571" title="All 4 branches covered."> if
(!wrapStart && !wrapEnd) {</span>
+<span class="fc" id="L9572"> return str;</span>
}
-<span class="fc" id="L9577"> final StringBuilder builder = new
StringBuilder(str.length() + wrapWith.length() + wrapWith.length());</span>
-<span class="fc bfc" id="L9578" title="All 2 branches covered."> if
(wrapStart) {</span>
-<span class="fc" id="L9579"> builder.append(wrapWith);</span>
+<span class="fc" id="L9575"> final StringBuilder builder = new
StringBuilder(str.length() + wrapWith.length() + wrapWith.length());</span>
+<span class="fc bfc" id="L9576" title="All 2 branches covered."> if
(wrapStart) {</span>
+<span class="fc" id="L9577"> builder.append(wrapWith);</span>
}
-<span class="fc" id="L9581"> builder.append(str);</span>
-<span class="fc bfc" id="L9582" title="All 2 branches covered."> if
(wrapEnd) {</span>
-<span class="fc" id="L9583"> builder.append(wrapWith);</span>
+<span class="fc" id="L9579"> builder.append(str);</span>
+<span class="fc bfc" id="L9580" title="All 2 branches covered."> if
(wrapEnd) {</span>
+<span class="fc" id="L9581"> builder.append(wrapWith);</span>
}
-<span class="fc" id="L9585"> return builder.toString();</span>
+<span class="fc" id="L9583"> return builder.toString();</span>
}
/**
@@ -9596,9 +9594,9 @@ public class StringUtils {
* @deprecated TODO Make private in 4.0.
*/
@Deprecated
-<span class="fc" id="L9599"> public StringUtils() {</span>
+<span class="fc" id="L9597"> public StringUtils() {</span>
// empty
-<span class="fc" id="L9601"> }</span>
+<span class="fc" id="L9599"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a
href="http://www.jacoco.org/jacoco">JaCoCo</a>
0.8.12.202403310830</span></div></body></html>
\ No newline at end of file