Skip to content
Commits on Source (10)
......@@ -2,5 +2,12 @@ Plexus-Utils
============
[![Build Status](https://travis-ci.org/codehaus-plexus/plexus-utils.svg?branch=master)](https://travis-ci.org/codehaus-plexus/plexus-utils)
[![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-utils.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.codehaus.plexus%22%20a%3A%plexus-utils%22)
The current master is now at https://github.com/codehaus-plexus/plexus-utils
For publishing [the site](https://codehaus-plexus.github.io/plexus-utils/) do the following:
```
mvn -Preporting verify site site:stage scm-publish:publish-scm
```
plexus-utils2 (3.1.0-1) unstable; urgency=medium
* Team upload.
* New upstream release
- Refreshed the patches
- Fixed a test failure in CommandlineTest with Maven 3.5.4 or later
* Breaks/Replaces libplexus-utils-java and install the same artifacts
* Standards-Version updated to 4.2.1
* Switch to debhelper level 11
* Use salsa.debian.org Vcs-* URLs
* Removed Damien Raude-Morvan from the uploaders (Closes: #889436)
-- Emmanuel Bourg <ebourg@apache.org> Mon, 19 Nov 2018 12:36:19 +0100
plexus-utils2 (3.0.24-3) unstable; urgency=medium
* Team upload.
......
......@@ -2,25 +2,27 @@ Source: plexus-utils2
Section: java
Priority: optional
Maintainer: Debian Java Maintainers <pkg-java-maintainers@lists.alioth.debian.org>
Uploaders: Ludovic Claude <ludovic.claude@laposte.net>,
Damien Raude-Morvan <drazzib@debian.org>
Uploaders: Ludovic Claude <ludovic.claude@laposte.net>
Build-Depends:
debhelper (>= 10),
debhelper (>= 11),
default-jdk,
default-jdk-doc,
junit (>= 3.8.2),
libmaven-javadoc-plugin-java,
libmaven-plugin-testing-java,
maven-debian-helper
Standards-Version: 4.0.0
Vcs-Git: https://anonscm.debian.org/git/pkg-java/plexus-utils2.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/plexus-utils2.git
Standards-Version: 4.2.1
Vcs-Git: https://salsa.debian.org/java-team/plexus-utils2.git
Vcs-Browser: https://salsa.debian.org/java-team/plexus-utils2
Homepage: http://codehaus-plexus.github.io/plexus-utils/
Package: libplexus-utils2-java
Architecture: all
Depends: ${misc:Depends}
Suggests: libplexus-utils2-java-doc
Breaks: libplexus-utils-java
Replaces: libplexus-utils-java
Provides: libplexus-utils-java
Description: utilities for the Plexus framework
The Plexus project provides a full software stack for creating and executing
software projects. Based on the Plexus container, the applications can
......
......@@ -3,7 +3,7 @@ Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/pom.xml
+++ b/pom.xml
@@ -57,6 +57,12 @@
@@ -61,6 +61,12 @@
<version>1.1</version>
<scope>test</scope>
</dependency>
......
......@@ -4,12 +4,11 @@ Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
+++ b/src/main/java/org/codehaus/plexus/util/PropertyUtils.java
@@ -34,27 +34,45 @@
public class PropertyUtils
@@ -34,29 +34,44 @@
{
- public static Properties loadProperties( final URL url ) throws IOException
+ public static Properties loadProperties( final URL url )
public static Properties loadProperties( final URL url )
- throws IOException
{
if ( url == null )
{
......@@ -29,8 +28,8 @@ Forwarded: not-needed
+ return null;
}
- public static Properties loadProperties( final File file ) throws IOException
+ public static Properties loadProperties( final File file )
public static Properties loadProperties( final File file )
- throws IOException
{
if ( file == null )
{
......@@ -50,12 +49,12 @@ Forwarded: not-needed
+ return null;
}
- public static Properties loadProperties( final InputStream is ) throws IOException
+ public static Properties loadProperties( final InputStream is )
public static Properties loadProperties( final InputStream is )
- throws IOException
{
InputStream in = is;
try
@@ -71,10 +89,16 @@
@@ -73,10 +88,16 @@
return properties;
}
......
......@@ -3,7 +3,7 @@ Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,12 @@
@@ -62,6 +62,12 @@
<scope>test</scope>
</dependency>
<dependency>
......
Description: Fixes CommandlineTest for Maven 3.5.4 or later
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: https://github.com/codehaus-plexus/plexus-utils/issues/48
--- a/src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java
+++ b/src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java
@@ -103,7 +103,6 @@
assertTrue( out.contains( "Apache Maven" ) );
assertTrue( out.contains( "Maven home:" ) );
assertTrue( out.contains( "Java version:" ) );
- assertTrue( out.contains( "Java home:" ) );
}
catch ( Exception e )
{
01-add-junit-dependency.patch
02-propertyutils-compatibility.patch
03-maven-plugin-testing-compatibility.patch
04-fix-test-failures.patch
......@@ -3,5 +3,12 @@
%:
dh $@
get-orig-source:
uscan --download-current-version --force-download --rename
override_dh_auto_install:
# Install the artifacts installed by libplexus-utils-java
# (don't use a relocation pom for maximum compatibility)
mh_installpom -plibplexus-utils2-java --set-version=debian pom.xml
rm -Rf debian/libplexus-utils2-java/usr/share/maven-repo/org/codehaus/plexus/plexus-utils/2.x
dh_link -plibplexus-utils2-java usr/share/java/plexus-utils2.jar usr/share/java/plexus-utils.jar
dh_link -plibplexus-utils2-java usr/share/java/plexus-utils2.jar usr/share/maven-repo/org/codehaus/plexus/plexus-utils/debian/plexus-utils-debian.jar
dh_auto_install
version=3
opts="uversionmangle=s/-(alpha|beta)-/~$1/" \
version=4
opts="repack,compression=xz,uversionmangle=s/-(alpha|beta)-/~$1/" \
https://github.com/codehaus-plexus/plexus-utils/tags .*/plexus-utils-(\d.*).tar.gz
......@@ -26,7 +26,7 @@ limitations under the License.
</parent>
<artifactId>plexus-utils</artifactId>
<version>3.0.24</version>
<version>3.1.0</version>
<name>Plexus Common Utilities</name>
<description>A collection of various utility classes to ease working with strings, files, command lines, XML and
......@@ -37,7 +37,7 @@ limitations under the License.
<connection>scm:git:git@github.com:codehaus-plexus/plexus-utils.git</connection>
<developerConnection>scm:git:git@github.com:codehaus-plexus/plexus-utils.git</developerConnection>
<url>http://github.com/codehaus-plexus/plexus-utils</url>
<tag>plexus-utils-3.0.24</tag>
<tag>plexus-utils-3.1.0</tag>
</scm>
<issueManagement>
<system>github</system>
......@@ -50,6 +50,10 @@ limitations under the License.
</site>
</distributionManagement>
<properties>
<javaVersion>6</javaVersion>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
......@@ -120,4 +124,19 @@ limitations under the License.
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- See https://github.com/codehaus-plexus/plexus-utils/pull/27 -->
<!-- m2e Eclipse plugin doesn't respect the maven-enforcer-plugin 'requireJavaVersion' parameter -->
<id>eclipse-only-jdk-version</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<javaVersion>7</javaVersion>
</properties>
</profile>
</profiles>
</project>
......@@ -16,7 +16,6 @@
* limitations under the License.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.List;
......@@ -44,8 +43,10 @@ public abstract class AbstractScanner
* <li>Serena Dimension: &#42;&#42;/.metadata, &#42;&#42;/.metadata/&#42;&#42;</li>
* <li>Mercurial: &#42;&#42;/.hg, &#42;&#42;/.hg/&#42;&#42;, &#42;&#42;/.hgignore</li>
* <li>GIT: &#42;&#42;/.git, &#42;&#42;/.gitignore, &#42;&#42;/.gitattributes, &#42;&#42;/.git/&#42;&#42;</li>
* <li>Bitkeeper: &#42;&#42;/BitKeeper, &#42;&#42;/BitKeeper/&#42;&#42;, &#42;&#42;/ChangeSet, &#42;&#42;/ChangeSet/&#42;&#42;</li>
* <li>Darcs: &#42;&#42;/_darcs, &#42;&#42;/_darcs/&#42;&#42;, &#42;&#42;/.darcsrepo, &#42;&#42;/.darcsrepo/&#42;&#42;&#42;&#42;/-darcs-backup&#42;, &#42;&#42;/.darcs-temp-mail
* <li>Bitkeeper: &#42;&#42;/BitKeeper, &#42;&#42;/BitKeeper/&#42;&#42;, &#42;&#42;/ChangeSet,
* &#42;&#42;/ChangeSet/&#42;&#42;</li>
* <li>Darcs: &#42;&#42;/_darcs, &#42;&#42;/_darcs/&#42;&#42;, &#42;&#42;/.darcsrepo,
* &#42;&#42;/.darcsrepo/&#42;&#42;&#42;&#42;/-darcs-backup&#42;, &#42;&#42;/.darcs-temp-mail
* </ul>
*
* @see #addDefaultExcludes()
......@@ -114,16 +115,14 @@ public abstract class AbstractScanner
private MatchPatterns excludesPatterns;
/**
* Whether or not the file system should be treated as a case sensitive
* one.
* Whether or not the file system should be treated as a case sensitive one.
*/
protected boolean isCaseSensitive = true;
/**
* Sets whether or not the file system should be regarded as case sensitive.
*
* @param isCaseSensitive whether or not the file system should be
* regarded as a case sensitive one
* @param isCaseSensitive whether or not the file system should be regarded as a case sensitive one
*/
public void setCaseSensitive( boolean isCaseSensitive )
{
......@@ -131,19 +130,14 @@ public void setCaseSensitive( boolean isCaseSensitive )
}
/**
* Tests whether or not a given path matches the start of a given
* pattern up to the first "**".
* Tests whether or not a given path matches the start of a given pattern up to the first "**".
* <p/>
* This is not a general purpose test and should only be used if you
* can live with false positives. For example, <code>pattern=**\a</code>
* and <code>str=b</code> will yield <code>true</code>.
* This is not a general purpose test and should only be used if you can live with false positives. For example,
* <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.
*
* @param pattern The pattern to match against. Must not be
* <code>null</code>.
* @param str The path to match, as a String. Must not be
* <code>null</code>.
* @return whether or not a given path matches the start of a given
* pattern up to the first "**".
* @param pattern The pattern to match against. Must not be <code>null</code>.
* @param str The path to match, as a String. Must not be <code>null</code>.
* @return whether or not a given path matches the start of a given pattern up to the first "**".
*/
protected static boolean matchPatternStart( String pattern, String str )
{
......@@ -151,21 +145,15 @@ protected static boolean matchPatternStart( String pattern, String str )
}
/**
* Tests whether or not a given path matches the start of a given
* pattern up to the first "**".
* Tests whether or not a given path matches the start of a given pattern up to the first "**".
* <p/>
* This is not a general purpose test and should only be used if you
* can live with false positives. For example, <code>pattern=**\a</code>
* and <code>str=b</code> will yield <code>true</code>.
* This is not a general purpose test and should only be used if you can live with false positives. For example,
* <code>pattern=**\a</code> and <code>str=b</code> will yield <code>true</code>.
*
* @param pattern The pattern to match against. Must not be
* <code>null</code>.
* @param str The path to match, as a String. Must not be
* <code>null</code>.
* @param isCaseSensitive Whether or not matching should be performed
* case sensitively.
* @return whether or not a given path matches the start of a given
* pattern up to the first "**".
* @param pattern The pattern to match against. Must not be <code>null</code>.
* @param str The path to match, as a String. Must not be <code>null</code>.
* @param isCaseSensitive Whether or not matching should be performed case sensitively.
* @return whether or not a given path matches the start of a given pattern up to the first "**".
*/
protected static boolean matchPatternStart( String pattern, String str, boolean isCaseSensitive )
{
......@@ -175,12 +163,9 @@ protected static boolean matchPatternStart( String pattern, String str, boolean
/**
* Tests whether or not a given path matches a given pattern.
*
* @param pattern The pattern to match against. Must not be
* <code>null</code>.
* @param str The path to match, as a String. Must not be
* <code>null</code>.
* @return <code>true</code> if the pattern matches against the string,
* or <code>false</code> otherwise.
* @param pattern The pattern to match against. Must not be <code>null</code>.
* @param str The path to match, as a String. Must not be <code>null</code>.
* @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise.
*/
protected static boolean matchPath( String pattern, String str )
{
......@@ -190,14 +175,10 @@ protected static boolean matchPath( String pattern, String str )
/**
* Tests whether or not a given path matches a given pattern.
*
* @param pattern The pattern to match against. Must not be
* <code>null</code>.
* @param str The path to match, as a String. Must not be
* <code>null</code>.
* @param isCaseSensitive Whether or not matching should be performed
* case sensitively.
* @return <code>true</code> if the pattern matches against the string,
* or <code>false</code> otherwise.
* @param pattern The pattern to match against. Must not be <code>null</code>.
* @param str The path to match, as a String. Must not be <code>null</code>.
* @param isCaseSensitive Whether or not matching should be performed case sensitively.
* @return <code>true</code> if the pattern matches against the string, or <code>false</code> otherwise.
*/
protected static boolean matchPath( String pattern, String str, boolean isCaseSensitive )
{
......@@ -205,17 +186,13 @@ protected static boolean matchPath( String pattern, String str, boolean isCaseSe
}
/**
* Tests whether or not a string matches against a pattern.
* The pattern may contain two special characters:<br>
* Tests whether or not a string matches against a pattern. The pattern may contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
* @param pattern The pattern to match against.
* Must not be <code>null</code>.
* @param str The string which must be matched against the pattern.
* Must not be <code>null</code>.
* @return <code>true</code> if the string matches against the pattern,
* or <code>false</code> otherwise.
* @param pattern The pattern to match against. Must not be <code>null</code>.
* @param str The string which must be matched against the pattern. Must not be <code>null</code>.
* @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
*/
public static boolean match( String pattern, String str )
{
......@@ -223,38 +200,28 @@ public static boolean match( String pattern, String str )
}
/**
* Tests whether or not a string matches against a pattern.
* The pattern may contain two special characters:<br>
* Tests whether or not a string matches against a pattern. The pattern may contain two special characters:<br>
* '*' means zero or more characters<br>
* '?' means one and only one character
*
* @param pattern The pattern to match against.
* Must not be <code>null</code>.
* @param str The string which must be matched against the pattern.
* Must not be <code>null</code>.
* @param isCaseSensitive Whether or not matching should be performed
* case sensitively.
* @return <code>true</code> if the string matches against the pattern,
* or <code>false</code> otherwise.
* @param pattern The pattern to match against. Must not be <code>null</code>.
* @param str The string which must be matched against the pattern. Must not be <code>null</code>.
* @param isCaseSensitive Whether or not matching should be performed case sensitively.
* @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
*/
protected static boolean match( String pattern, String str, boolean isCaseSensitive )
{
return SelectorUtils.match( pattern, str, isCaseSensitive );
}
/**
* Sets the list of include patterns to use. All '/' and '\' characters
* are replaced by <code>File.separatorChar</code>, so the separator used
* need not match <code>File.separatorChar</code>.
* Sets the list of include patterns to use. All '/' and '\' characters are replaced by
* <code>File.separatorChar</code>, so the separator used need not match <code>File.separatorChar</code>.
* <p/>
* When a pattern ends with a '/' or '\', "**" is appended.
*
* @param includes A list of include patterns.
* May be <code>null</code>, indicating that all files
* should be included. If a non-<code>null</code>
* list is given, all elements must be
* non-<code>null</code>.
* @param includes A list of include patterns. May be <code>null</code>, indicating that all files should be
* included. If a non-<code>null</code> list is given, all elements must be non-<code>null</code>.
*/
public void setIncludes( String[] includes )
{
......@@ -277,16 +244,13 @@ public void setIncludes( String[] includes )
}
/**
* Sets the list of exclude patterns to use. All '/' and '\' characters
* are replaced by <code>File.separatorChar</code>, so the separator used
* need not match <code>File.separatorChar</code>.
* Sets the list of exclude patterns to use. All '/' and '\' characters are replaced by
* <code>File.separatorChar</code>, so the separator used need not match <code>File.separatorChar</code>.
* <p/>
* When a pattern ends with a '/' or '\', "**" is appended.
*
* @param excludes A list of exclude patterns.
* May be <code>null</code>, indicating that no files
* should be excluded. If a non-<code>null</code> list is
* given, all elements must be non-<code>null</code>.
* @param excludes A list of exclude patterns. May be <code>null</code>, indicating that no files should be
* excluded. If a non-<code>null</code> list is given, all elements must be non-<code>null</code>.
*/
public void setExcludes( String[] excludes )
{
......@@ -343,12 +307,11 @@ private String normalizePattern( String pattern )
}
/**
* Tests whether or not a name matches against at least one include
* pattern.
* Tests whether or not a name matches against at least one include pattern.
*
* @param name The name to match. Must not be <code>null</code>.
* @return <code>true</code> when the name matches against at least one
* include pattern, or <code>false</code> otherwise.
* @return <code>true</code> when the name matches against at least one include pattern, or <code>false</code>
* otherwise.
*/
protected boolean isIncluded( String name )
{
......@@ -361,12 +324,11 @@ protected boolean isIncluded( String name, String[] tokenizedName )
}
/**
* Tests whether or not a name matches the start of at least one include
* pattern.
* Tests whether or not a name matches the start of at least one include pattern.
*
* @param name The name to match. Must not be <code>null</code>.
* @return <code>true</code> when the name matches against the start of at
* least one include pattern, or <code>false</code> otherwise.
* @return <code>true</code> when the name matches against the start of at least one include pattern, or
* <code>false</code> otherwise.
*/
protected boolean couldHoldIncluded( String name )
{
......@@ -374,12 +336,11 @@ protected boolean couldHoldIncluded( String name )
}
/**
* Tests whether or not a name matches against at least one exclude
* pattern.
* Tests whether or not a name matches against at least one exclude pattern.
*
* @param name The name to match. Must not be <code>null</code>.
* @return <code>true</code> when the name matches against at least one
* exclude pattern, or <code>false</code> otherwise.
* @return <code>true</code> when the name matches against at least one exclude pattern, or <code>false</code>
* otherwise.
*/
protected boolean isExcluded( String name )
{
......
......@@ -18,17 +18,18 @@
/**
* Provides Base64 encoding and decoding as defined by RFC 2045.
*
* <p>This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite>
* from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One:
* Format of Internet Message Bodies</cite> by Freed and Borenstein.</p>
* <p>
* This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite> from RFC 2045 <cite>Multipurpose
* Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</cite> by Freed and Borenstein.
* </p>
*
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
* @author Apache Software Foundation
* @since 1.0-dev
* @version $Id$
*/
public class Base64 {
public class Base64
{
//
// Source Id: Base64.java 161350 2005-04-14 20:39:46Z ggregory
......@@ -36,9 +37,10 @@ public class Base64 {
/**
* Chunk size per RFC 2045 section 6.8.
*
* <p>The {@value} character limit does not count the trailing CRLF, but counts
* all other characters, including any equal signs.</p>
* <p>
* The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any
* equal signs.
* </p>
*
* @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
*/
......@@ -119,32 +121,40 @@ public class Base64 {
private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
// Populating the lookup and character arrays
static {
for (int i = 0; i < BASELENGTH; i++) {
static
{
for ( int i = 0; i < BASELENGTH; i++ )
{
base64Alphabet[i] = (byte) -1;
}
for (int i = 'Z'; i >= 'A'; i--) {
for ( int i = 'Z'; i >= 'A'; i-- )
{
base64Alphabet[i] = (byte) ( i - 'A' );
}
for (int i = 'z'; i >= 'a'; i--) {
for ( int i = 'z'; i >= 'a'; i-- )
{
base64Alphabet[i] = (byte) ( i - 'a' + 26 );
}
for (int i = '9'; i >= '0'; i--) {
for ( int i = '9'; i >= '0'; i-- )
{
base64Alphabet[i] = (byte) ( i - '0' + 52 );
}
base64Alphabet['+'] = 62;
base64Alphabet['/'] = 63;
for (int i = 0; i <= 25; i++) {
for ( int i = 0; i <= 25; i++ )
{
lookUpBase64Alphabet[i] = (byte) ( 'A' + i );
}
for (int i = 26, j = 0; i <= 51; i++, j++) {
for ( int i = 26, j = 0; i <= 51; i++, j++ )
{
lookUpBase64Alphabet[i] = (byte) ( 'a' + j );
}
for (int i = 52, j = 0; i <= 61; i++, j++) {
for ( int i = 52, j = 0; i <= 61; i++, j++ )
{
lookUpBase64Alphabet[i] = (byte) ( '0' + j );
}
......@@ -158,30 +168,37 @@ public class Base64 {
* @param octect The value to test
* @return <code>true</code> if the value is defined in the the base 64 alphabet, <code>false</code> otherwise.
*/
private static boolean isBase64(byte octect) {
if (octect == PAD) {
private static boolean isBase64( byte octect )
{
if ( octect == PAD )
{
return true;
} else if (octect < 0 || base64Alphabet[octect] == -1) {
}
else if ( octect < 0 || base64Alphabet[octect] == -1 )
{
return false;
} else {
}
else
{
return true;
}
}
/**
* Tests a given byte array to see if it contains
* only valid characters within the Base64 alphabet.
* Tests a given byte array to see if it contains only valid characters within the Base64 alphabet.
*
* @param arrayOctect byte array to test
* @return <code>true</code> if all bytes are valid characters in the Base64
* alphabet or if the byte array is empty; false, otherwise
* @return <code>true</code> if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
* false, otherwise
*/
public static boolean isArrayByteBase64(byte[] arrayOctect) {
public static boolean isArrayByteBase64( byte[] arrayOctect )
{
arrayOctect = discardWhitespace( arrayOctect );
int length = arrayOctect.length;
if (length == 0) {
if ( length == 0 )
{
// shouldn't a 0 length array be valid base64 data?
// return false;
return true;
......@@ -197,49 +214,47 @@ public static boolean isArrayByteBase64(byte[] arrayOctect) {
}
/**
* Encodes binary data using the base64 algorithm but
* does not chunk the output.
* Encodes binary data using the base64 algorithm but does not chunk the output.
*
* @param binaryData binary data to encode
* @return Base64 characters
*/
public static byte[] encodeBase64(byte[] binaryData) {
public static byte[] encodeBase64( byte[] binaryData )
{
return encodeBase64( binaryData, false );
}
/**
* Encodes binary data using the base64 algorithm and chunks
* the encoded output into 76 character blocks
* Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks
*
* @param binaryData binary data to encode
* @return Base64 characters chunked in 76 character blocks
*/
public static byte[] encodeBase64Chunked(byte[] binaryData) {
public static byte[] encodeBase64Chunked( byte[] binaryData )
{
return encodeBase64( binaryData, true );
}
/**
* Decodes a byte[] containing containing
* characters in the Base64 alphabet.
* Decodes a byte[] containing containing characters in the Base64 alphabet.
*
* @param pArray A byte array containing Base64 character data
* @return a byte array containing binary data
*/
public byte[] decode(byte[] pArray) {
public byte[] decode( byte[] pArray )
{
return decodeBase64( pArray );
}
/**
* Encodes binary data using the base64 algorithm, optionally
* chunking the output into 76 character blocks.
* Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
*
* @param binaryData Array containing binary data to encode.
* @param isChunked if <code>true</code> this encoder will chunk
* the base64 output into 76 character blocks
* @param isChunked if <code>true</code> this encoder will chunk the base64 output into 76 character blocks
* @return Base64-encoded data.
*/
public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
public static byte[] encodeBase64( byte[] binaryData, boolean isChunked )
{
int lengthDataBits = binaryData.length * EIGHTBIT;
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
......@@ -247,10 +262,13 @@ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
int encodedDataLength = 0;
int nbrChunks = 0;
if (fewerThan24bits != 0) {
if ( fewerThan24bits != 0 )
{
// data not divisible by 24 bit
encodedDataLength = ( numberTriplets + 1 ) * 4;
} else {
}
else
{
// 16 or 8 bit
encodedDataLength = numberTriplets * 4;
}
......@@ -258,10 +276,10 @@ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
// If the output is to be "chunked" into 76 character sections,
// for compliance with RFC 2045 MIME, then it is important to
// allow for extra length to account for the separator(s)
if (isChunked) {
if ( isChunked )
{
nbrChunks =
(CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
nbrChunks = ( CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil( (float) encodedDataLength / CHUNK_SIZE ) );
encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
}
......@@ -276,7 +294,8 @@ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
int chunksSoFar = 0;
// log.debug("number of triplets = " + numberTriplets);
for (i = 0; i < numberTriplets; i++) {
for ( i = 0; i < numberTriplets; i++ )
{
dataIndex = i * 3;
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
......@@ -287,39 +306,30 @@ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
l = (byte) ( b2 & 0x0f );
k = (byte) ( b1 & 0x03 );
byte val1 =
((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val2 =
((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
byte val3 =
((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
byte val1 = ( ( b1 & SIGN ) == 0 ) ? (byte) ( b1 >> 2 ) : (byte) ( ( b1 ) >> 2 ^ 0xc0 );
byte val2 = ( ( b2 & SIGN ) == 0 ) ? (byte) ( b2 >> 4 ) : (byte) ( ( b2 ) >> 4 ^ 0xf0 );
byte val3 = ( ( b3 & SIGN ) == 0 ) ? (byte) ( b3 >> 6 ) : (byte) ( ( b3 ) >> 6 ^ 0xfc );
encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
// log.debug( "val2 = " + val2 );
// log.debug( "k4 = " + (k<<4) );
// log.debug( "vak = " + (val2 | (k<<4)) );
encodedData[encodedIndex + 1] =
lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex + 2] =
lookUpBase64Alphabet[(l << 2) | val3];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[val2 | ( k << 4 )];
encodedData[encodedIndex + 2] = lookUpBase64Alphabet[( l << 2 ) | val3];
encodedData[encodedIndex + 3] = lookUpBase64Alphabet[b3 & 0x3f];
encodedIndex += 4;
// If we are chunking, let's put a chunk separator down.
if (isChunked) {
if ( isChunked )
{
// this assumes that CHUNK_SIZE % 4 == 0
if (encodedIndex == nextSeparatorIndex) {
System.arraycopy(
CHUNK_SEPARATOR,
0,
encodedData,
encodedIndex,
CHUNK_SEPARATOR.length);
if ( encodedIndex == nextSeparatorIndex )
{
System.arraycopy( CHUNK_SEPARATOR, 0, encodedData, encodedIndex, CHUNK_SEPARATOR.length );
chunksSoFar++;
nextSeparatorIndex =
(CHUNK_SIZE * (chunksSoFar + 1)) +
(chunksSoFar * CHUNK_SEPARATOR.length);
( CHUNK_SIZE * ( chunksSoFar + 1 ) ) + ( chunksSoFar * CHUNK_SEPARATOR.length );
encodedIndex += CHUNK_SEPARATOR.length;
}
}
......@@ -328,44 +338,41 @@ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
// form integral number of 6-bit groups
dataIndex = i * 3;
if (fewerThan24bits == EIGHTBIT) {
if ( fewerThan24bits == EIGHTBIT )
{
b1 = binaryData[dataIndex];
k = (byte) ( b1 & 0x03 );
// log.debug("b1=" + b1);
// log.debug("b1<<2 = " + (b1>>2) );
byte val1 =
((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val1 = ( ( b1 & SIGN ) == 0 ) ? (byte) ( b1 >> 2 ) : (byte) ( ( b1 ) >> 2 ^ 0xc0 );
encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
encodedData[encodedIndex + 2] = PAD;
encodedData[encodedIndex + 3] = PAD;
} else if (fewerThan24bits == SIXTEENBIT) {
}
else if ( fewerThan24bits == SIXTEENBIT )
{
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex + 1];
l = (byte) ( b2 & 0x0f );
k = (byte) ( b1 & 0x03 );
byte val1 =
((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
byte val2 =
((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
byte val1 = ( ( b1 & SIGN ) == 0 ) ? (byte) ( b1 >> 2 ) : (byte) ( ( b1 ) >> 2 ^ 0xc0 );
byte val2 = ( ( b2 & SIGN ) == 0 ) ? (byte) ( b2 >> 4 ) : (byte) ( ( b2 ) >> 4 ^ 0xf0 );
encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex + 1] =
lookUpBase64Alphabet[val2 | (k << 4)];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[val2 | ( k << 4 )];
encodedData[encodedIndex + 2] = lookUpBase64Alphabet[l << 2];
encodedData[encodedIndex + 3] = PAD;
}
if (isChunked) {
if ( isChunked )
{
// we also add a separator to the end of the final chunk.
if (chunksSoFar < nbrChunks) {
System.arraycopy(
CHUNK_SEPARATOR,
0,
encodedData,
encodedDataLength - CHUNK_SEPARATOR.length,
if ( chunksSoFar < nbrChunks )
{
System.arraycopy( CHUNK_SEPARATOR, 0, encodedData, encodedDataLength - CHUNK_SEPARATOR.length,
CHUNK_SEPARATOR.length );
}
}
......@@ -379,12 +386,14 @@ public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
* @param base64Data Byte array containing Base64 data
* @return Array containing decoded data.
*/
public static byte[] decodeBase64(byte[] base64Data) {
public static byte[] decodeBase64( byte[] base64Data )
{
// RFC 2045 requires that we discard ALL non-Base64 characters
base64Data = discardNonBase64( base64Data );
// handle the edge case, so we don't have to worry about it later
if (base64Data.length == 0) {
if ( base64Data.length == 0 )
{
return new byte[0];
}
......@@ -400,15 +409,18 @@ public static byte[] decodeBase64(byte[] base64Data) {
// this sizes the output array properly - rlw
int lastData = base64Data.length;
// ignore the '=' padding
while (base64Data[lastData - 1] == PAD) {
if (--lastData == 0) {
while ( base64Data[lastData - 1] == PAD )
{
if ( --lastData == 0 )
{
return new byte[0];
}
}
decodedData = new byte[lastData - numberQuadruple];
}
for (int i = 0; i < numberQuadruple; i++) {
for ( int i = 0; i < numberQuadruple; i++ )
{
dataIndex = i * 4;
marker0 = base64Data[dataIndex + 2];
marker1 = base64Data[dataIndex + 3];
......@@ -416,25 +428,28 @@ public static byte[] decodeBase64(byte[] base64Data) {
b1 = base64Alphabet[base64Data[dataIndex]];
b2 = base64Alphabet[base64Data[dataIndex + 1]];
if (marker0 != PAD && marker1 != PAD) {
if ( marker0 != PAD && marker1 != PAD )
{
// No PAD e.g 3cQl
b3 = base64Alphabet[marker0];
b4 = base64Alphabet[marker1];
decodedData[encodedIndex] = (byte) ( b1 << 2 | b2 >> 4 );
decodedData[encodedIndex + 1] =
(byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex + 1] = (byte) ( ( ( b2 & 0xf ) << 4 ) | ( ( b3 >> 2 ) & 0xf ) );
decodedData[encodedIndex + 2] = (byte) ( b3 << 6 | b4 );
} else if (marker0 == PAD) {
}
else if ( marker0 == PAD )
{
// Two PAD e.g. 3c[Pad][Pad]
decodedData[encodedIndex] = (byte) ( b1 << 2 | b2 >> 4 );
} else if (marker1 == PAD) {
}
else if ( marker1 == PAD )
{
// One PAD e.g. 3cQ[Pad]
b3 = base64Alphabet[marker0];
decodedData[encodedIndex] = (byte) ( b1 << 2 | b2 >> 4 );
decodedData[encodedIndex + 1] =
(byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
decodedData[encodedIndex + 1] = (byte) ( ( ( b2 & 0xf ) << 4 ) | ( ( b3 >> 2 ) & 0xf ) );
}
encodedIndex += 3;
}
......@@ -444,11 +459,11 @@ public static byte[] decodeBase64(byte[] base64Data) {
/**
* Discards any whitespace from a base-64 encoded block.
*
* @param data The base-64 encoded data to discard the whitespace
* from.
* @param data The base-64 encoded data to discard the whitespace from.
* @return The data, less whitespace (see RFC 2045).
*/
static byte[] discardWhitespace(byte[] data) {
static byte[] discardWhitespace( byte[] data )
{
byte groomedData[] = new byte[data.length];
int bytesCopied = 0;
......@@ -474,15 +489,14 @@ static byte[] discardWhitespace(byte[] data) {
}
/**
* Discards any characters outside of the base64 alphabet, per
* the requirements on page 25 of RFC 2045 - "Any characters
* outside of the base64 alphabet are to be ignored in base64
* encoded data."
* Discards any characters outside of the base64 alphabet, per the requirements on page 25 of RFC 2045 - "Any
* characters outside of the base64 alphabet are to be ignored in base64 encoded data."
*
* @param data The base-64 encoded data to groom
* @return The data, less non-base64 characters (see RFC 2045).
*/
static byte[] discardNonBase64(byte[] data) {
static byte[] discardNonBase64( byte[] data )
{
byte groomedData[] = new byte[data.length];
int bytesCopied = 0;
......@@ -502,13 +516,13 @@ static byte[] discardNonBase64(byte[] data) {
}
/**
* Encodes a byte[] containing binary data, into a byte[] containing
* characters in the Base64 alphabet.
* Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.
*
* @param pArray a byte array containing binary data
* @return A byte array containing only Base64 character data
*/
public byte[] encode(byte[] pArray) {
public byte[] encode( byte[] pArray )
{
return encodeBase64( pArray, false );
}
......
......@@ -37,19 +37,10 @@ public class CollectionUtils
// ----------------------------------------------------------------------
/**
* Take a dominant and recessive Map and merge the key:value
* pairs where the recessive Map may add key:value pairs to the dominant
* Map but may not override any existing key:value pairs.
*
* If we have two Maps, a dominant and recessive, and
* their respective keys are as follows:
*
* dominantMapKeys = { a, b, c, d, e, f }
* recessiveMapKeys = { a, b, c, x, y, z }
*
* Then the result should be the following:
*
* resultantKeys = { a, b, c, d, e, f, x, y, z }
* Take a dominant and recessive Map and merge the key:value pairs where the recessive Map may add key:value pairs
* to the dominant Map but may not override any existing key:value pairs. If we have two Maps, a dominant and
* recessive, and their respective keys are as follows: dominantMapKeys = { a, b, c, d, e, f } recessiveMapKeys = {
* a, b, c, x, y, z } Then the result should be the following: resultantKeys = { a, b, c, d, e, f, x, y, z }
*
* @param dominantMap Dominant Map.
* @param recessiveMap Recessive Map.
......@@ -99,9 +90,8 @@ public static <K,V> Map<K,V> mergeMaps( Map<K,V> dominantMap, Map<K,V> recessive
}
/**
* Take a series of <code>Map</code>s and merge
* them where the ordering of the array from 0..n
* is the dominant order.
* Take a series of <code>Map</code>s and merge them where the ordering of the array from 0..n is the dominant
* order.
*
* @param maps An array of Maps to merge.
* @return Map The result Map produced after the merging process.
......@@ -132,12 +122,10 @@ else if ( maps.length == 1 )
}
/**
* Returns a {@link Collection} containing the intersection
* of the given {@link Collection}s.
* Returns a {@link Collection} containing the intersection of the given {@link Collection}s.
* <p>
* The cardinality of each element in the returned {@link Collection}
* will be equal to the minimum of the cardinality of that element
* in the two given {@link Collection}s.
* The cardinality of each element in the returned {@link Collection} will be equal to the minimum of the
* cardinality of that element in the two given {@link Collection}s.
*
* @param a The first collection
* @param b The second collection
......@@ -162,10 +150,9 @@ public static <E> Collection<E> intersection( final Collection<E> a, final Colle
}
/**
* Returns a {@link Collection} containing <tt><i>a</i> - <i>b</i></tt>.
* The cardinality of each element <i>e</i> in the returned {@link Collection}
* will be the cardinality of <i>e</i> in <i>a</i> minus the cardinality
* of <i>e</i> in <i>b</i>, or zero, whichever is greater.
* Returns a {@link Collection} containing <tt><i>a</i> - <i>b</i></tt>. The cardinality of each element <i>e</i> in
* the returned {@link Collection} will be the cardinality of <i>e</i> in <i>a</i> minus the cardinality of <i>e</i>
* in <i>b</i>, or zero, whichever is greater.
*
* @param a The start collection
* @param b The collection that will be subtracted
......@@ -183,12 +170,10 @@ public static <T> Collection<T> subtract( final Collection<T> a, final Collectio
}
/**
* Returns a {@link Map} mapping each unique element in
* the given {@link Collection} to an {@link Integer}
* representing the number of occurances of that element
* in the {@link Collection}.
* An entry that maps to <tt>null</tt> indicates that the
* element does not appear in the given {@link Collection}.
* Returns a {@link Map} mapping each unique element in the given {@link Collection} to an {@link Integer}
* representing the number of occurrences of that element in the {@link Collection}. An entry that maps to
* <tt>null</tt> indicates that the element does not appear in the given {@link Collection}.
*
* @param col The collection to count cardinalities for
* @return A map of counts, indexed on each element in the collection
*/
......
......@@ -20,6 +20,7 @@
/**
* Observes the actions of a {@link DirectoryWalker}.
*
* @version $Id$
* @see DirectoryWalker
*/
......
......@@ -24,6 +24,7 @@
/**
* DirectoryWalker
*
* @version $Id$
*/
public class DirectoryWalker
......@@ -71,8 +72,7 @@ public DirStackEntry( File d, int length )
}
/**
* Calculate the next percentage offset.
* Used by the next DirStackEntry.
* Calculate the next percentage offset. Used by the next DirStackEntry.
*
* @return the value for the next percentage offset.
*/
......@@ -82,8 +82,7 @@ public double getNextPercentageOffset()
}
/**
* Calculate the next percentage size.
* Used by the next DirStackEntry.
* Calculate the next percentage size. Used by the next DirStackEntry.
*
* @return the value for the next percentage size.
*/
......@@ -93,8 +92,7 @@ public double getNextPercentageSize()
}
/**
* The percentage of the DirStackEntry right now.
* Based on count, index, percentageOffset, and percentageSize.
* The percentage of the DirStackEntry right now. Based on count, index, percentageOffset, and percentageSize.
*
* @return the percentage right now.
*/
......
package org.codehaus.plexus.util;
/* ====================================================================
* The Apache Software License, Version 1.1
*
......@@ -17,11 +19,11 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* any, must include the following acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.codehaus.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
......@@ -51,7 +53,6 @@
* information on the Apache Software Foundation, please see
* <http://www.codehaus.org/>.
*/
package org.codehaus.plexus.util;
import java.io.PrintStream;
import java.io.PrintWriter;
......@@ -67,8 +68,9 @@
import java.util.StringTokenizer;
/**
* <p><code>ExceptionUtils</code> provides utilities for manipulating
* <code>Throwable</code> objects.</p>
* <p>
* <code>ExceptionUtils</code> provides utilities for manipulating <code>Throwable</code> objects.
* </p>
*
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
* @author Dmitri Plotnikov
......@@ -79,38 +81,28 @@
public class ExceptionUtils
{
/**
* Used when printing stack frames to denote the start of a
* wrapped exception. Package private for accessibility by test
* suite.
* Used when printing stack frames to denote the start of a wrapped exception. Package private for accessibility by
* test suite.
*/
static final String WRAPPED_MARKER = " [wrapped] ";
/**
* The names of methods commonly used to access a wrapped
* exception.
* The names of methods commonly used to access a wrapped exception.
*/
protected static String[] CAUSE_METHOD_NAMES = {
"getCause",
"getNextException",
"getTargetException",
"getException",
"getSourceException",
"getRootCause",
"getCausedByException",
"getNested"
};
protected static String[] CAUSE_METHOD_NAMES = { "getCause", "getNextException", "getTargetException",
"getException", "getSourceException", "getRootCause", "getCausedByException", "getNested" };
/**
* Constructs a new <code>ExceptionUtils</code>. Protected to
* discourage instantiation.
* Constructs a new <code>ExceptionUtils</code>. Protected to discourage instantiation.
*/
protected ExceptionUtils()
{
}
/**
* <p>Adds to the list of method names used in the search for <code>Throwable</code>
* objects.</p>
* <p>
* Adds to the list of method names used in the search for <code>Throwable</code> objects.
* </p>
*
* @param methodName the methodName to add to the list, null and empty strings are ignored
*/
......@@ -125,13 +117,14 @@ public static void addCauseMethodName( String methodName )
}
/**
* <p>Introspects the specified <code>Throwable</code> to obtain the cause.</p>
*
* <p>The method searches for methods with specific names that return a
* <code>Throwable</code> object. This will pick up most wrapping exceptions,
* including those from JDK 1.4, and
* The method names can be added to using {@link #addCauseMethodName(String)}.
* The default list searched for are:</p>
* <p>
* Introspects the specified <code>Throwable</code> to obtain the cause.
* </p>
* <p>
* The method searches for methods with specific names that return a <code>Throwable</code> object. This will pick
* up most wrapping exceptions, including those from JDK 1.4, and The method names can be added to using
* {@link #addCauseMethodName(String)}. The default list searched for are:
* </p>
* <ul>
* <li><code>getCause()</code>
* <li><code>getNextException()</code>
......@@ -142,11 +135,13 @@ public static void addCauseMethodName( String methodName )
* <li><code>getCausedByException()</code>
* <li><code>getNested()</code>
* </ul>
*
* <p>In the absence of any such method, the object is inspected for a
* <code>detail</code> field assignable to a <code>Throwable</code>.</p>
*
* <p>If none of the above is found, returns <code>null</code>.</p>
* <p>
* In the absence of any such method, the object is inspected for a <code>detail</code> field assignable to a
* <code>Throwable</code>.
* </p>
* <p>
* If none of the above is found, returns <code>null</code>.
* </p>
*
* @param throwable The exception to introspect for a cause.
* @return The cause of the <code>Throwable</code>.
......@@ -158,8 +153,9 @@ public static Throwable getCause( Throwable throwable )
}
/**
* <p>Introspects the specified <code>Throwable</code> to obtain the cause
* using a supplied array of method names.</p>
* <p>
* Introspects the specified <code>Throwable</code> to obtain the cause using a supplied array of method names.
* </p>
*
* @param throwable The exception to introspect for a cause.
* @return The cause of the <code>Throwable</code>.
......@@ -189,9 +185,10 @@ public static Throwable getCause( Throwable throwable, String[] methodNames )
}
/**
* <p>Walks through the exception chain to the last element -- the
* "root" of the tree -- using {@link #getCause(Throwable)}, and
* returns that exception.</p>
* <p>
* Walks through the exception chain to the last element -- the "root" of the tree -- using
* {@link #getCause(Throwable)}, and returns that exception.
* </p>
*
* @param throwable the throwable to get the root cause for
* @return The root cause of the <code>Throwable</code>.
......@@ -211,13 +208,13 @@ public static Throwable getRootCause( Throwable throwable )
}
/**
* <p>Uses <code>instanceof</code> checks to examine the exception,
* looking for well known types which could contain chained or
* wrapped exceptions.</p>
* <p>
* Uses <code>instanceof</code> checks to examine the exception, looking for well known types which could contain
* chained or wrapped exceptions.
* </p>
*
* @param throwable the exception to examine
* @return The wrapped exception, or <code>null</code> if not
* found.
* @return The wrapped exception, or <code>null</code> if not found.
*/
private static Throwable getCauseUsingWellKnownTypes( Throwable throwable )
{
......@@ -236,12 +233,13 @@ else if ( throwable instanceof InvocationTargetException )
}
/**
* <p>Find a throwable by method name.</p>
* <p>
* Find a throwable by method name.
* </p>
*
* @param throwable the exception to examine
* @param methodName the name of the method to find and invoke
* @return The wrapped exception, or <code>null</code> if not
* found.
* @return The wrapped exception, or <code>null</code> if not found.
*/
private static Throwable getCauseUsingMethodName( Throwable throwable, String methodName )
{
......@@ -277,12 +275,13 @@ private static Throwable getCauseUsingMethodName( Throwable throwable, String me
}
/**
* <p>Find a throwable by field name.</p>
* <p>
* Find a throwable by field name.
* </p>
*
* @param throwable the exception to examine
* @param fieldName the name of the attribute to examine
* @return The wrapped exception, or <code>null</code> if not
* found.
* @return The wrapped exception, or <code>null</code> if not found.
*/
private static Throwable getCauseUsingFieldName( Throwable throwable, String fieldName )
{
......@@ -315,8 +314,9 @@ private static Throwable getCauseUsingFieldName( Throwable throwable, String fie
}
/**
* <p>Returns the number of <code>Throwable</code> objects in the
* exception chain.</p>
* <p>
* Returns the number of <code>Throwable</code> objects in the exception chain.
* </p>
*
* @param throwable the exception to inspect
* @return The throwable count.
......@@ -334,8 +334,9 @@ public static int getThrowableCount( Throwable throwable )
}
/**
* <p>Returns the list of <code>Throwable</code> objects in the
* exception chain.</p>
* <p>
* Returns the list of <code>Throwable</code> objects in the exception chain.
* </p>
*
* @param throwable the exception to inspect
* @return The list of <code>Throwable</code> objects.
......@@ -352,8 +353,10 @@ public static Throwable[] getThrowables( Throwable throwable )
}
/**
* <p>Delegates to {@link #indexOfThrowable(Throwable, Class, int)},
* starting the search at the beginning of the exception chain.</p>
* <p>
* Delegates to {@link #indexOfThrowable(Throwable, Class, int)}, starting the search at the beginning of the
* exception chain.
* </p>
*
* @see #indexOfThrowable(Throwable, Class, int)
*/
......@@ -363,21 +366,18 @@ public static int indexOfThrowable( Throwable throwable, Class type )
}
/**
* <p>Returns the (zero based) index, of the first
* <code>Throwable</code> that matches the specified type in the
* exception chain of <code>Throwable</code> objects with an index
* greater than or equal to the specified index, or
* <code>-1</code> if the type is not found.</p>
* <p>
* Returns the (zero based) index, of the first <code>Throwable</code> that matches the specified type in the
* exception chain of <code>Throwable</code> objects with an index greater than or equal to the specified index, or
* <code>-1</code> if the type is not found.
* </p>
*
* @param throwable the exception to inspect
* @param type <code>Class</code> to look for
* @param fromIndex the (zero based) index of the starting
* position in the chain to be searched
* @return the first occurrence of the type in the chain, or
* <code>-1</code> if the type is not found
* @throws IndexOutOfBoundsException If the <code>fromIndex</code>
* argument is negative or not less than the count of
* <code>Throwable</code>s in the chain.
* @param fromIndex the (zero based) index of the starting position in the chain to be searched
* @return the first occurrence of the type in the chain, or <code>-1</code> if the type is not found
* @throws IndexOutOfBoundsException If the <code>fromIndex</code> argument is negative or not less than the count
* of <code>Throwable</code>s in the chain.
*/
public static int indexOfThrowable( Throwable throwable, Class type, int fromIndex )
{
......@@ -401,14 +401,11 @@ public static int indexOfThrowable( Throwable throwable, Class type, int fromInd
}
/**
* Prints a compact stack trace for the root cause of a throwable.
* The compact stack trace starts with the root cause and prints
* stack frames up to the place where it was caught and wrapped.
* Then it prints the wrapped exception and continues with stack frames
* until the wrapper exception is caught and wrapped again, etc.
* Prints a compact stack trace for the root cause of a throwable. The compact stack trace starts with the root
* cause and prints stack frames up to the place where it was caught and wrapped. Then it prints the wrapped
* exception and continues with stack frames until the wrapper exception is caught and wrapped again, etc.
* <p>
* The method is equivalent to t.printStackTrace() for throwables
* that don't have nested causes.
* The method is equivalent to t.printStackTrace() for throwables that don't have nested causes.
*/
public static void printRootCauseStackTrace( Throwable t, PrintStream stream )
{
......@@ -429,8 +426,7 @@ public static void printRootCauseStackTrace( Throwable t )
}
/**
* Same as printRootCauseStackTrace(t, stream), except it takes
* a PrintWriter as an argument.
* Same as printRootCauseStackTrace(t, stream), except it takes a PrintWriter as an argument.
*/
public static void printRootCauseStackTrace( Throwable t, PrintWriter writer )
{
......@@ -443,10 +439,8 @@ public static void printRootCauseStackTrace( Throwable t, PrintWriter writer )
}
/**
* Creates a compact stack trace for the root cause of the supplied
* throwable.
*
* See <code>printRootCauseStackTrace(Throwable t, PrintStream s)</code>
* Creates a compact stack trace for the root cause of the supplied throwable. See
* <code>printRootCauseStackTrace(Throwable t, PrintStream s)</code>
*/
public static String[] getRootCauseStackTrace( Throwable t )
{
......@@ -504,12 +498,10 @@ private static void removeCommonFrames( List<String> causeFrames, List<String> w
}
/**
* A convenient way of extracting the stack trace from an
* exception.
* A convenient way of extracting the stack trace from an exception.
*
* @param t The <code>Throwable</code>.
* @return The stack trace as generated by the exception's
* <code>printStackTrace(PrintWriter)</code> method.
* @return The stack trace as generated by the exception's <code>printStackTrace(PrintWriter)</code> method.
*/
public static String getStackTrace( Throwable t )
{
......@@ -600,9 +592,8 @@ else if ( throwable instanceof InvocationTargetException )
}
/**
* Captures the stack trace associated with the specified
* <code>Throwable</code> object, decomposing it into a list of
* stack frames.
* Captures the stack trace associated with the specified <code>Throwable</code> object, decomposing it into a list
* of stack frames.
*
* @param t The <code>Throwable</code>.
* @return An array of strings describing each stack frame.
......@@ -613,9 +604,7 @@ public static String[] getStackFrames( Throwable t )
}
/**
* Functionality shared between the
* <code>getStackFrames(Throwable)</code> methods of this and the
* classes.
* Functionality shared between the <code>getStackFrames(Throwable)</code> methods of this and the classes.
*/
static String[] getStackFrames( String stackTrace )
{
......@@ -630,9 +619,8 @@ static String[] getStackFrames( String stackTrace )
}
/**
* Produces a List of stack frames - the message is not included.
* This works in most cases - it will only fail if the exception message
* contains a line that starts with: " at".
* Produces a List of stack frames - the message is not included. This works in most cases - it will only fail if
* the exception message contains a line that starts with: " at".
*
* @param t is any throwable
* @return List of stack frames
......