/usr/share/doc/libcommons-lang3-java/api/org/apache/commons/lang3/package-summary.html is in libcommons-lang3-java-doc 3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html>
<head>
<!-- Generated by javadoc -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>org.apache.commons.lang3 (Apache Commons Lang 3.5 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="org.apache.commons.lang3 (Apache Commons Lang 3.5 API)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-use.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Package</li>
<li><a href="../../../../org/apache/commons/lang3/builder/package-summary.html">Next Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/commons/lang3/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h1 title="Package" class="title">Package org.apache.commons.lang3</h1>
<div class="docSummary">
<div class="block">Provides highly reusable static utility methods, chiefly concerned with adding value to the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/package-summary.html?is-external=true"><code>java.lang</code></a> classes.</div>
</div>
<p>See: <a href="#package.description">Description</a></p>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Interface Summary table, listing interfaces, and an explanation">
<caption><span>Interface Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ThreadUtils.ThreadGroupPredicate.html" title="interface in org.apache.commons.lang3">ThreadUtils.ThreadGroupPredicate</a></td>
<td class="colLast">
<div class="block">A predicate for selecting threadgroups.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ThreadUtils.ThreadPredicate.html" title="interface in org.apache.commons.lang3">ThreadUtils.ThreadPredicate</a></td>
<td class="colLast">
<div class="block">A predicate for selecting threads.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/AnnotationUtils.html" title="class in org.apache.commons.lang3">AnnotationUtils</a></td>
<td class="colLast">
<div class="block">Helper methods for working with <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Annotation.html?is-external=true" title="class or interface in java.lang.annotation"><code>Annotation</code></a> instances.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ArrayUtils.html" title="class in org.apache.commons.lang3">ArrayUtils</a></td>
<td class="colLast">
<div class="block">Operations on arrays, primitive arrays (like <code>int[]</code>) and
primitive wrapper arrays (like <code>Integer[]</code>).</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/BitField.html" title="class in org.apache.commons.lang3">BitField</a></td>
<td class="colLast">
<div class="block">Supports operations on bit-mapped fields.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/BooleanUtils.html" title="class in org.apache.commons.lang3">BooleanUtils</a></td>
<td class="colLast">
<div class="block">Operations on boolean primitives and Boolean objects.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/CharEncoding.html" title="class in org.apache.commons.lang3">CharEncoding</a></td>
<td class="colLast">
<div class="block">Character encoding names required of every implementation of the Java platform.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/CharSequenceUtils.html" title="class in org.apache.commons.lang3">CharSequenceUtils</a></td>
<td class="colLast">
<div class="block">Operations on <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang"><code>CharSequence</code></a> that are
<code>null</code> safe.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/CharSet.html" title="class in org.apache.commons.lang3">CharSet</a></td>
<td class="colLast">
<div class="block">A set of characters.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/CharSetUtils.html" title="class in org.apache.commons.lang3">CharSetUtils</a></td>
<td class="colLast">
<div class="block">Operations on <code>CharSet</code> instances.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/CharUtils.html" title="class in org.apache.commons.lang3">CharUtils</a></td>
<td class="colLast">
<div class="block">Operations on char primitives and Character objects.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ClassPathUtils.html" title="class in org.apache.commons.lang3">ClassPathUtils</a></td>
<td class="colLast">
<div class="block">Operations regarding the classpath.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ClassUtils.html" title="class in org.apache.commons.lang3">ClassUtils</a></td>
<td class="colLast">
<div class="block">Operates on classes without using reflection.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/Conversion.html" title="class in org.apache.commons.lang3">Conversion</a></td>
<td class="colLast">
<div class="block">
Static methods to convert a type into another, with endianness and bit ordering awareness.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/EnumUtils.html" title="class in org.apache.commons.lang3">EnumUtils</a></td>
<td class="colLast">
<div class="block">Utility library to provide helper methods for Java enums.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/LocaleUtils.html" title="class in org.apache.commons.lang3">LocaleUtils</a></td>
<td class="colLast">
<div class="block">Operations to assist when working with a <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Locale.html?is-external=true" title="class or interface in java.util"><code>Locale</code></a>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ObjectUtils.html" title="class in org.apache.commons.lang3">ObjectUtils</a></td>
<td class="colLast">
<div class="block">Operations on <code>Object</code>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ObjectUtils.Null.html" title="class in org.apache.commons.lang3">ObjectUtils.Null</a></td>
<td class="colLast">
<div class="block">Class used as a null placeholder where <code>null</code>
has another meaning.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/RandomStringUtils.html" title="class in org.apache.commons.lang3">RandomStringUtils</a></td>
<td class="colLast">
<div class="block">Operations for random <code>String</code>s.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/RandomUtils.html" title="class in org.apache.commons.lang3">RandomUtils</a></td>
<td class="colLast">
<div class="block">Utility library that supplements the standard <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Random.html?is-external=true" title="class or interface in java.util"><code>Random</code></a> class.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/Range.html" title="class in org.apache.commons.lang3">Range</a><T></td>
<td class="colLast">
<div class="block">An immutable range of objects from a minimum to maximum point inclusive.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/SerializationUtils.html" title="class in org.apache.commons.lang3">SerializationUtils</a></td>
<td class="colLast">
<div class="block">Assists with the serialization process and performs additional functionality based
on serialization.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/StringEscapeUtils.html" title="class in org.apache.commons.lang3">StringEscapeUtils</a></td>
<td class="colLast">
<div class="block">Escapes and unescapes <code>String</code>s for
Java, Java Script, HTML and XML.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/StringUtils.html" title="class in org.apache.commons.lang3">StringUtils</a></td>
<td class="colLast">
<div class="block">Operations on <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang"><code>String</code></a> that are
<code>null</code> safe.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/SystemUtils.html" title="class in org.apache.commons.lang3">SystemUtils</a></td>
<td class="colLast">
<div class="block">
Helpers for <code>java.lang.System</code>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ThreadUtils.html" title="class in org.apache.commons.lang3">ThreadUtils</a></td>
<td class="colLast">
<div class="block">
Helpers for <code>java.lang.Thread</code> and <code>java.lang.ThreadGroup</code>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ThreadUtils.NamePredicate.html" title="class in org.apache.commons.lang3">ThreadUtils.NamePredicate</a></td>
<td class="colLast">
<div class="block">A predicate implementation which matches a thread or threadgroup name.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ThreadUtils.ThreadIdPredicate.html" title="class in org.apache.commons.lang3">ThreadUtils.ThreadIdPredicate</a></td>
<td class="colLast">
<div class="block">A predicate implementation which matches a thread id.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/Validate.html" title="class in org.apache.commons.lang3">Validate</a></td>
<td class="colLast">
<div class="block">This class assists in validating arguments.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation">
<caption><span>Enum Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Enum</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/ClassUtils.Interfaces.html" title="enum in org.apache.commons.lang3">ClassUtils.Interfaces</a></td>
<td class="colLast">
<div class="block">Inclusivity literals for <a href="../../../../org/apache/commons/lang3/ClassUtils.html#hierarchy-java.lang.Class-org.apache.commons.lang3.ClassUtils.Interfaces-"><code>ClassUtils.hierarchy(Class, Interfaces)</code></a>.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/JavaVersion.html" title="enum in org.apache.commons.lang3">JavaVersion</a></td>
<td class="colLast">
<div class="block">An enum representing all the versions of the Java specification.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Exception Summary table, listing exceptions, and an explanation">
<caption><span>Exception Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Exception</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/NotImplementedException.html" title="class in org.apache.commons.lang3">NotImplementedException</a></td>
<td class="colLast">
<div class="block">Thrown to indicate that a block of code has not been implemented.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../org/apache/commons/lang3/SerializationException.html" title="class in org.apache.commons.lang3">SerializationException</a></td>
<td class="colLast">
<div class="block">Exception thrown when the Serialization process fails.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
<a name="package.description">
<!-- -->
</a>
<h2 title="Package org.apache.commons.lang3 Description">Package org.apache.commons.lang3 Description</h2>
<div class="block"><p>Provides highly reusable static utility methods, chiefly concerned with adding value to the <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/package-summary.html?is-external=true"><code>java.lang</code></a> classes.
Most of these classes are immutable and thus thread-safe.
However <a href="../../../../org/apache/commons/lang3/CharSet.html" title="class in org.apache.commons.lang3"><code>CharSet</code></a> is not currently guaranteed thread-safe under all circumstances.</p>
<p>The top level package contains various Utils classes, whilst there are various subpackages including <a href="../../../../org/apache/commons/lang3/math/package-summary.html"><code>org.apache.commons.lang3.math</code></a>, <a href="../../../../org/apache/commons/lang3/concurrent/package-summary.html"><code>org.apache.commons.lang3.concurrent</code></a> and <a href="../../../../org/apache/commons/lang3/builder/package-summary.html"><code>org.apache.commons.lang3.builder</code></a>.
Using the Utils classes is generally simplicity itself.
They are the equivalent of global functions in another language, a collection of stand-alone, thread-safe, static methods.
In contrast, subpackages may contain interfaces which may have to be implemented or classes which may need to be extended to get the full functionality from the code.
They may, however, contain more global-like functions.</p>
<p>Lang 3.0 requires JDK 1.5+, since Lang 3.2 it requires JDK 6+; The legacy release 2.6 requires JDK 1.2+.
In both cases you can find features of later JDKs being maintained by us and likely to be removed or modified in favour of the JDK in the next major version.
Note that Lang 3.0 uses a different package than its predecessors, allowing it to be used at the same time as an earlier version.</p>
<p>You will find deprecated methods as you stroll through the Lang documentation. These are removed in the next major version. </p>
<p>All util classes contain empty public constructors with warnings not to use.
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>
<p>Lang has a series of String utilities.
The first is <a href="../../../../org/apache/commons/lang3/StringUtils.html" title="class in org.apache.commons.lang3"><code>StringUtils</code></a>, oodles and oodles of functions which tweak, transform, squeeze and cuddle <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang"><code>java.lang.Strings</code></a>.
In addition to StringUtils, there are a series of other String manipulating classes; <a href="../../../../org/apache/commons/lang3/RandomStringUtils.html" title="class in org.apache.commons.lang3"><code>RandomStringUtils</code></a> and <a href="../../../../org/apache/commons/lang3/StringEscapeUtils.html" title="class in org.apache.commons.lang3"><code>StringEscapeUtils</code></a>.
RandomStringUtils speaks for itself.
It's provides ways in which to generate pieces of text, such as might be used for default passwords.
StringEscapeUtils contains methods to escape and unescape Java, JavaScript, HTML, XML and SQL.</p>
<p>These are ideal classes to start using if you're looking to get into Lang.
StringUtils' <a href="../../../../org/apache/commons/lang3/StringUtils.html#capitalize-java.lang.String-"><code>StringUtils.capitalize(String)</code></a>, <a href="../../../../org/apache/commons/lang3/StringUtils.html#substringBetween-java.lang.String-java.lang.String-"><code>StringUtils.substringBetween(String, String)</code></a>/<a href="../../../../org/apache/commons/lang3/StringUtils.html#substringBefore-java.lang.String-java.lang.String-"><code>Before</code></a>/<a href="../../../../org/apache/commons/lang3/StringUtils.html#substringAfter-java.lang.String-java.lang.String-"><code>After</code></a>, <a href="../../../../org/apache/commons/lang3/StringUtils.html#split-java.lang.String-"><code>StringUtils.split(String)</code></a> and <a href="../../../../org/apache/commons/lang3/StringUtils.html#join-T...-"><code>StringUtils.join(Object[])</code></a> are good methods to begin with.
If you use java.sql.Statements a lot, StringEscapeUtils.escapeSql might be of interest.</p>
<h3>Character handling - CharSetUtils, CharSet, CharRange, CharUtils</h3>
<p>In addition to dealing with Strings, it's also important to deal with chars and Characters.
<a href="../../../../org/apache/commons/lang3/CharUtils.html" title="class in org.apache.commons.lang3"><code>CharUtils</code></a> exists for this purpose, while <a href="../../../../org/apache/commons/lang3/CharSetUtils.html" title="class in org.apache.commons.lang3"><code>CharSetUtils</code></a> exists for set-manipulation of Strings.
Be careful, although CharSetUtils takes an argument of type String, it is only as a set of characters.
For example, <code>CharSetUtils.delete("testtest", "tr")</code> will remove all t's and all r's from the String, not just the String "tr". </p>
<p><code>CharRange</code> and <a href="../../../../org/apache/commons/lang3/CharSet.html" title="class in org.apache.commons.lang3"><code>CharSet</code></a> are both used internally by CharSetUtils, and will probably rarely be used.</p>
<h3>JVM interaction - SystemUtils, CharEncoding</h3>
<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.
Having pushed out a few JDK 1.3 bits that had slipped in (<code>Collections.EMPTY_MAP</code> is a classic offender), I then found that one of the Unit Tests was dying mysteriously under JDK 1.2, but ran fine under JDK 1.3.
There was no obvious solution and I needed to move onwards, so the simple solution was to wrap that particular test in a <code>if(SystemUtils.isJavaVersionAtLeast(1.3f)) {</code>, make a note and move on.</p>
<p>The <a href="../../../../org/apache/commons/lang3/CharEncoding.html" title="class in org.apache.commons.lang3"><code>CharEncoding</code></a> 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>
<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>
<h3>Assorted functions - ObjectUtils, ClassUtils, ArrayUtils, BooleanUtils</h3>
<p>Would you believe it, <a href="../../../../org/apache/commons/lang3/ObjectUtils.html" title="class in org.apache.commons.lang3"><code>ObjectUtils</code></a> contains handy functions for Objects, mainly null-safe implementations of the methods on <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang"><code>Object</code></a>.</p>
<p><a href="../../../../org/apache/commons/lang3/ClassUtils.html" title="class in org.apache.commons.lang3"><code>ClassUtils</code></a> is largely a set of helper methods for reflection.
Of special note are the comparators hidden away in ClassUtils, useful for sorting Class and Package objects by name; however they merely sort alphabetically and don't understand the common habit of sorting <code>java</code> and <code>javax</code> first.</p>
<p>Next up, <a href="../../../../org/apache/commons/lang3/ArrayUtils.html" title="class in org.apache.commons.lang3"><code>ArrayUtils</code></a>.
This is a big one with many methods and many overloads of these methods so it is probably worth an in depth look here.
Before we begin, assume that every method mentioned is overloaded for all the primitives and for Object.
Also, the short-hand 'xxx' implies a generic primitive type, but usually also includes Object. </p>
<ul>
<li>ArrayUtils provides singleton empty arrays for all the basic types. These will largely be of use in the Collections API with its toArray methods, but also will be of use with methods which want to return an empty array on error.</li>
<li><code>add(xxx[], xxx)</code> will add a primitive type to an array, resizing the array as you'd expect. Object is also supported. </li>
<li><code>clone(xxx[])</code> clones a primitive or Object array. </li>
<li><code>contains(xxx[], xxx)</code> searches for a primitive or Object in a primitive or Object array. </li>
<li><code>getLength(Object)</code> returns the length of any array or an IllegalArgumentException if the parameter is not an array. <code>hashCode(Object)</code>, <code>equals(Object, Object)</code>, <code>toString(Object)</code> </li>
<li><code>indexOf(xxx[], xxx)</code> and <code>indexOf(xxx[], xxx, int)</code> are copies of the classic String methods, but this time for primitive/Object arrays. In addition, a lastIndexOf set of methods exists. </li>
<li><code>isEmpty(xxx[])</code> lets you know if an array is zero-sized or null. </li>
<li><code>isSameLength(xxx[], xxx[])</code> returns true if the arrays are the same length. </li>
<li>Along side the add methods, there are also remove methods of two types. The first type remove the value at an index, <code>remove(xxx[], int)</code>, while the second type remove the first value from the array, <code>remove(xxx[], xxx)</code>. </li>
<li>Nearing the end now. The <code>reverse(xxx[])</code> method turns an array around. </li>
<li>The <code>subarray(xxx[], int, int)</code> method splices an array out of a larger array. </li>
<li>Primitive to primitive wrapper conversion is handled by the <code>toObject(xxx[])</code> and <code>toPrimitive(Xxx[])</code> methods. </li>
</ul>
<p>Lastly, <a href="../../../../org/apache/commons/lang3/ArrayUtils.html#toMap-java.lang.Object:A-"><code>ArrayUtils.toMap(Object[])</code></a> is worthy of special note.
It is not a heavily overloaded method for working with arrays, but a simple way to create Maps from literals. </p>
<h4>Using toMap</h4>
<pre>
<code>
Map colorMap = ArrayUtils.toMap(new String[][] {{
{"RED", "#FF0000"},
{"GREEN", "#00FF00"},
{"BLUE", "#0000FF"}
});
</code>
</pre>
<p>Our final util class is <a href="../../../../org/apache/commons/lang3/BooleanUtils.html" title="class in org.apache.commons.lang3"><code>BooleanUtils</code></a>.
It contains various Boolean acting methods, probably of most interest is the <a href="../../../../org/apache/commons/lang3/BooleanUtils.html#toBoolean-java.lang.String-"><code>BooleanUtils.toBoolean(String)</code></a> 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>
<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 <a href="../../../../org/apache/commons/lang3/BitField.html" title="class in org.apache.commons.lang3"><code>BitField</code></a> class provides a wrapper class around the classic bitmask integer, whilst the <a href="../../../../org/apache/commons/lang3/Validate.html" title="class in org.apache.commons.lang3"><code>Validate</code></a> class may be used for assertions (remember, we support Java 1.2). </p></div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.0</dd>
</dl>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-use.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev Package</li>
<li><a href="../../../../org/apache/commons/lang3/builder/package-summary.html">Next Package</a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/commons/lang3/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright © 2001–2016 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>
|