dlr 01/08/25 21:48:22
Modified: util/src/java/org/apache/commons/util StringUtils.java
Log:
* Removed stackTrace(Throwable, boolean). If you want <pre> HTML tags
around stackTrace()'s output, add them yourself.
* Provided better JavaDoc for equals(String, String) and optimized
method.
Revision Changes Path
1.10 +8 -40
jakarta-commons-sandbox/util/src/java/org/apache/commons/util/StringUtils.java
Index: StringUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/util/src/java/org/apache/commons/util/StringUtils.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -u -r1.9 -r1.10
--- StringUtils.java 2001/08/26 02:03:16 1.9
+++ StringUtils.java 2001/08/26 04:48:22 1.10
@@ -77,7 +77,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Greg Coladonato</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Bayard</a>
- * @version $Id: StringUtils.java,v 1.9 2001/08/26 02:03:16 dlr Exp $
+ * @version $Id: StringUtils.java,v 1.10 2001/08/26 04:48:22 dlr Exp $
*/
public class StringUtils
{
@@ -132,56 +132,24 @@
e.printStackTrace( new PrintWriter(buf, true) );
trace = buf.toString();
}
- catch (Exception f)
+ catch (Exception ignored)
{
- // Do nothing.
}
return trace;
}
/**
- * Returns the output of printStackTrace as a String.
- *
- * @param e A Throwable.
- * @param addPre a boolean to add HTML <pre> tags around the stacktrace
- * @return A String.
- */
- public static final String stackTrace(Throwable e, boolean addPre)
- {
- if (addPre)
- {
- return "<pre>" + stackTrace(e) + "</pre>";
- }
- else
- {
- return stackTrace(e);
- }
- }
-
- /**
- * Compares two Strings, returns true if their values are the
- * same.
+ * Safely compares two <code>String</code> objects, returning
+ * whether their values are the same. Two <code>null</code>
+ * references are considered equal.
*
* @param s1 The first string.
* @param s2 The second string.
- * @return True if the values of both strings are the same.
+ * @return Whether the values of both strings are the same.
*/
- public static boolean equals( String s1,
- String s2 )
+ public static boolean equals(String s1, String s2)
{
- if (s1 == null)
- {
- return (s2 == null);
- }
- else if (s2 == null)
- {
- // s1 is not null
- return false;
- }
- else
- {
- return s1.equals(s2);
- }
+ return (s1 == null ? s2 == null : s1.equals(s2));
}
/**