Gary D. Gregory 2003-08-21 15:52:55 +00:00
parent f74b10ecad
commit fac4f8d2d6
10 changed files with 97 additions and 15 deletions

View File

@ -68,7 +68,7 @@ import java.io.Serializable;
* @author Stephen Colebourne * @author Stephen Colebourne
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @since 1.0 * @since 1.0
* @version $Id: ObjectUtils.java,v 1.19 2003/08/18 02:22:23 bayard Exp $ * @version $Id: ObjectUtils.java,v 1.20 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class ObjectUtils { public class ObjectUtils {
@ -193,6 +193,7 @@ public class ObjectUtils {
* @param object the object to create a toString for, may be <code>null</code> * @param object the object to create a toString for, may be <code>null</code>
* @return the default toString text, or <code>null</code> if * @return the default toString text, or <code>null</code> if
* <code>null</code> passed in * <code>null</code> passed in
* @since 2.0
*/ */
public static StringBuffer appendIdentityToString(StringBuffer buffer, Object object) { public static StringBuffer appendIdentityToString(StringBuffer buffer, Object object) {
if (object == null) { if (object == null) {
@ -224,6 +225,7 @@ public class ObjectUtils {
* @see String#valueOf(Object) * @see String#valueOf(Object)
* @param obj the Object to <code>toString</code>, may be null * @param obj the Object to <code>toString</code>, may be null
* @return the passed in Object's toString, or nullStr if <code>null</code> input * @return the passed in Object's toString, or nullStr if <code>null</code> input
* @since 2.0
*/ */
public static String toString(Object obj) { public static String toString(Object obj) {
return (obj == null ? "" : obj.toString()); return (obj == null ? "" : obj.toString());
@ -246,6 +248,7 @@ public class ObjectUtils {
* @param obj the Object to <code>toString</code>, may be null * @param obj the Object to <code>toString</code>, may be null
* @param nullStr the String to return if <code>null</code> input, may be null * @param nullStr the String to return if <code>null</code> input, may be null
* @return the passed in Object's toString, or nullStr if <code>null</code> input * @return the passed in Object's toString, or nullStr if <code>null</code> input
* @since 2.0
*/ */
public static String toString(Object obj, String nullStr) { public static String toString(Object obj, String nullStr) {
return (obj == null ? nullStr : obj.toString()); return (obj == null ? nullStr : obj.toString());

View File

@ -64,7 +64,7 @@ import java.util.Random;
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz * @author Phil Steitz
* @since 1.0 * @since 1.0
* @version $Id: RandomStringUtils.java,v 1.22 2003/08/18 02:22:23 bayard Exp $ * @version $Id: RandomStringUtils.java,v 1.23 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class RandomStringUtils { public class RandomStringUtils {
@ -250,6 +250,7 @@ public class RandomStringUtils {
* @throws ArrayIndexOutOfBoundsException if there are not * @throws ArrayIndexOutOfBoundsException if there are not
* <code>(end - start) + 1</code> characters in the set array. * <code>(end - start) + 1</code> characters in the set array.
* @throws IllegalArgumentException if <code>count</code> &lt; 0. * @throws IllegalArgumentException if <code>count</code> &lt; 0.
* @since 2.0
*/ */
public static String random(int count, int start, int end, boolean letters, boolean numbers, char[] chars, Random random) { public static String random(int count, int start, int end, boolean letters, boolean numbers, char[] chars, Random random) {
if (count == 0) { if (count == 0) {

View File

@ -68,7 +68,7 @@ package org.apache.commons.lang;
* @author Michael Becke * @author Michael Becke
* @author Tetsuya Kaneuchi * @author Tetsuya Kaneuchi
* @since 1.0 * @since 1.0
* @version $Id: SystemUtils.java,v 1.20 2003/08/18 02:22:23 bayard Exp $ * @version $Id: SystemUtils.java,v 1.21 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class SystemUtils { public class SystemUtils {
@ -83,7 +83,8 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since Java version 1.2. * @since 2.0
* @since Java 1.2.
*/ */
public static final String FILE_ENCODING = getSystemProperty("file.encoding"); public static final String FILE_ENCODING = getSystemProperty("file.encoding");
@ -94,7 +95,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since Java version 1.1. * @since Java 1.1.
*/ */
public static final String FILE_SEPARATOR = getSystemProperty("file.separator"); public static final String FILE_SEPARATOR = getSystemProperty("file.separator");
@ -104,7 +105,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since Java version 1.1. * @since Java 1.1.
*/ */
public static final String JAVA_CLASS_PATH = getSystemProperty("java.class.path"); public static final String JAVA_CLASS_PATH = getSystemProperty("java.class.path");
@ -115,7 +116,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since Java version 1.1. * @since Java 1.1.
*/ */
public static final String JAVA_CLASS_VERSION = getSystemProperty("java.class.version"); public static final String JAVA_CLASS_VERSION = getSystemProperty("java.class.version");
@ -126,7 +127,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since Java version 1.2. Not used in Sun versions after 1.2. * @since Java 1.2. Not used in Sun versions after 1.2.
*/ */
public static final String JAVA_COMPILER = getSystemProperty("java.compiler"); public static final String JAVA_COMPILER = getSystemProperty("java.compiler");
@ -179,6 +180,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since 2.0
* @since Java 1.3 * @since Java 1.3
*/ */
public static final String JAVA_RUNTIME_NAME = getSystemProperty("java.runtime.name"); public static final String JAVA_RUNTIME_NAME = getSystemProperty("java.runtime.name");
@ -190,6 +192,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since 2.0
* @since Java 1.3 * @since Java 1.3
*/ */
public static final String JAVA_RUNTIME_VERSION = getSystemProperty("java.runtime.version"); public static final String JAVA_RUNTIME_VERSION = getSystemProperty("java.runtime.version");
@ -264,6 +267,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since 2.0
* @since Java 1.2 * @since Java 1.2
*/ */
public static final String JAVA_VM_INFO = getSystemProperty("java.vm.info"); public static final String JAVA_VM_INFO = getSystemProperty("java.vm.info");
@ -394,6 +398,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since 2.0
* @since Java 1.2 * @since Java 1.2
*/ */
public static final String USER_COUNTRY = public static final String USER_COUNTRY =
@ -428,6 +433,7 @@ public class SystemUtils {
* <p>Defaults to <code>null</code> if the runtime does not have * <p>Defaults to <code>null</code> if the runtime does not have
* security access to read this property or the property does not exist.</p> * security access to read this property or the property does not exist.</p>
* *
* @since 2.0
* @since Java 1.2 * @since Java 1.2
*/ */
public static final String USER_LANGUAGE = getSystemProperty("user.language"); public static final String USER_LANGUAGE = getSystemProperty("user.language");
@ -531,6 +537,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_AIX = getOSMatches("AIX"); public static final boolean IS_OS_AIX = getOSMatches("AIX");
@ -539,6 +547,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX"); public static final boolean IS_OS_HP_UX = getOSMatches("HP-UX");
@ -547,6 +557,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_IRIX = getOSMatches("Irix"); public static final boolean IS_OS_IRIX = getOSMatches("Irix");
@ -555,6 +567,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX"); public static final boolean IS_OS_LINUX = getOSMatches("Linux") || getOSMatches("LINUX");
@ -563,6 +577,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_MAC = getOSMatches("Mac"); public static final boolean IS_OS_MAC = getOSMatches("Mac");
@ -571,6 +587,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X"); public static final boolean IS_OS_MAC_OSX = getOSMatches("Mac OS X");
@ -579,6 +597,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_OS2 = getOSMatches("OS/2"); public static final boolean IS_OS_OS2 = getOSMatches("OS/2");
@ -587,6 +607,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris"); public static final boolean IS_OS_SOLARIS = getOSMatches("Solaris");
@ -595,6 +617,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS"); public static final boolean IS_OS_SUN_OS = getOSMatches("SunOS");
@ -603,6 +627,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS = getOSMatches("Windows"); public static final boolean IS_OS_WINDOWS = getOSMatches("Windows");
@ -611,6 +637,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS_2000 = getOSMatches("Windows", "5.0"); public static final boolean IS_OS_WINDOWS_2000 = getOSMatches("Windows", "5.0");
@ -619,6 +647,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS_95 = getOSMatches("Windows 9", "4.0"); public static final boolean IS_OS_WINDOWS_95 = getOSMatches("Windows 9", "4.0");
// JDK 1.2 running on Windows98 returns 'Windows 95', hence the above // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
@ -628,6 +658,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS_98 = getOSMatches("Windows 9", "4.1"); public static final boolean IS_OS_WINDOWS_98 = getOSMatches("Windows 9", "4.1");
// JDK 1.2 running on Windows98 returns 'Windows 95', hence the above // JDK 1.2 running on Windows98 returns 'Windows 95', hence the above
@ -637,6 +669,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS_ME = getOSMatches("Windows", "4.9"); public static final boolean IS_OS_WINDOWS_ME = getOSMatches("Windows", "4.9");
// JDK 1.2 running on WindowsME may return 'Windows 95', hence the above // JDK 1.2 running on WindowsME may return 'Windows 95', hence the above
@ -646,6 +680,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS_NT = getOSMatches("Windows NT"); public static final boolean IS_OS_WINDOWS_NT = getOSMatches("Windows NT");
// Windows 2000 returns 'Windows 2000' but may suffer from same JDK1.2 problem // Windows 2000 returns 'Windows 2000' but may suffer from same JDK1.2 problem
@ -655,6 +691,8 @@ public class SystemUtils {
* *
* <p>The field will return <code>false</code> if <code>OS_NAME</code> is * <p>The field will return <code>false</code> if <code>OS_NAME</code> is
* <code>null</code>.</p> * <code>null</code>.</p>
*
* @since 2.0
*/ */
public static final boolean IS_OS_WINDOWS_XP = getOSMatches("Windows", "5.1"); public static final boolean IS_OS_WINDOWS_XP = getOSMatches("Windows", "5.1");
// Windows XP returns 'Windows 2000' just for fun... // Windows XP returns 'Windows 2000' just for fun...
@ -835,6 +873,7 @@ public class SystemUtils {
* @param requiredVersion the required version, for example 131 * @param requiredVersion the required version, for example 131
* @return <code>true</code> if the actual version is equal or greater * @return <code>true</code> if the actual version is equal or greater
* than the required version * than the required version
* @since 2.0
*/ */
public static boolean isJavaVersionAtLeast(int requiredVersion) { public static boolean isJavaVersionAtLeast(int requiredVersion) {
return (JAVA_VERSION_INT >= requiredVersion); return (JAVA_VERSION_INT >= requiredVersion);

View File

@ -111,7 +111,7 @@ import java.lang.reflect.Modifier;
* @author Gary Gregory * @author Gary Gregory
* @author Pete Gieser * @author Pete Gieser
* @since 1.0 * @since 1.0
* @version $Id: EqualsBuilder.java,v 1.18 2003/08/18 02:22:24 bayard Exp $ * @version $Id: EqualsBuilder.java,v 1.19 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class EqualsBuilder { public class EqualsBuilder {
/** /**
@ -201,6 +201,7 @@ public class EqualsBuilder {
* @param reflectUpToClass the superclass to reflect up to (inclusive), * @param reflectUpToClass the superclass to reflect up to (inclusive),
* may be <code>null</code> * may be <code>null</code>
* @return <code>true</code> if the two Objects have tested equals. * @return <code>true</code> if the two Objects have tested equals.
* @since 2.0
*/ */
public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients, Class reflectUpToClass) { public static boolean reflectionEquals(Object lhs, Object rhs, boolean testTransients, Class reflectUpToClass) {
if (lhs == rhs) { if (lhs == rhs) {
@ -291,6 +292,7 @@ public class EqualsBuilder {
* *
* @param superEquals the result of calling <code>super.equals()</code> * @param superEquals the result of calling <code>super.equals()</code>
* @return EqualsBuilder - used to chain calls. * @return EqualsBuilder - used to chain calls.
* @since 2.0
*/ */
public EqualsBuilder appendSuper(boolean superEquals) { public EqualsBuilder appendSuper(boolean superEquals) {
if (isEquals == false) { if (isEquals == false) {

View File

@ -112,7 +112,7 @@ import java.lang.reflect.Modifier;
* @author Gary Gregory * @author Gary Gregory
* @author Pete Gieser * @author Pete Gieser
* @since 1.0 * @since 1.0
* @version $Id: HashCodeBuilder.java,v 1.18 2003/08/18 02:22:24 bayard Exp $ * @version $Id: HashCodeBuilder.java,v 1.19 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class HashCodeBuilder { public class HashCodeBuilder {
@ -310,6 +310,7 @@ public class HashCodeBuilder {
* @return int hash code * @return int hash code
* @throws IllegalArgumentException if the Object is <code>null</code> * @throws IllegalArgumentException if the Object is <code>null</code>
* @throws IllegalArgumentException if the number is zero or even * @throws IllegalArgumentException if the number is zero or even
* @since 2.0
*/ */
public static int reflectionHashCode( public static int reflectionHashCode(
int initialNonZeroOddNumber, int initialNonZeroOddNumber,
@ -366,6 +367,7 @@ public class HashCodeBuilder {
* *
* @param superHashCode the result of calling <code>super.hashCode()</code> * @param superHashCode the result of calling <code>super.hashCode()</code>
* @return this HashCodeBuilder, used to chain calls. * @return this HashCodeBuilder, used to chain calls.
* @since 2.0
*/ */
public HashCodeBuilder appendSuper(int superHashCode) { public HashCodeBuilder appendSuper(int superHashCode) {
iTotal = iTotal * iConstant + superHashCode; iTotal = iTotal * iConstant + superHashCode;

View File

@ -66,7 +66,7 @@ package org.apache.commons.lang.builder;
* @author Stephen Colebourne * @author Stephen Colebourne
* @author Pete Gieser * @author Pete Gieser
* @since 1.0 * @since 1.0
* @version $Id: StandardToStringStyle.java,v 1.13 2003/08/18 02:22:24 bayard Exp $ * @version $Id: StandardToStringStyle.java,v 1.14 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class StandardToStringStyle extends ToStringStyle { public class StandardToStringStyle extends ToStringStyle {
@ -103,6 +103,7 @@ public class StandardToStringStyle extends ToStringStyle {
* <p>Gets whether to output short or long class names.</p> * <p>Gets whether to output short or long class names.</p>
* *
* @return the current useShortClassName flag * @return the current useShortClassName flag
* @since 2.0
*/ */
public boolean isUseShortClassName() { public boolean isUseShortClassName() {
return super.isUseShortClassName(); return super.isUseShortClassName();
@ -123,6 +124,7 @@ public class StandardToStringStyle extends ToStringStyle {
* <p>Sets whether to output short or long class names.</p> * <p>Sets whether to output short or long class names.</p>
* *
* @param useShortClassName the new useShortClassName flag * @param useShortClassName the new useShortClassName flag
* @since 2.0
*/ */
public void setUseShortClassName(boolean useShortClassName) { public void setUseShortClassName(boolean useShortClassName) {
super.setUseShortClassName(useShortClassName); super.setUseShortClassName(useShortClassName);
@ -398,6 +400,7 @@ public class StandardToStringStyle extends ToStringStyle {
* of each buffer.</p> * of each buffer.</p>
* *
* @param fieldSeparatorAtStart the fieldSeparatorAtStart flag * @param fieldSeparatorAtStart the fieldSeparatorAtStart flag
* @since 2.0
*/ */
public void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) { public void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) {
super.setFieldSeparatorAtStart(fieldSeparatorAtStart); super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
@ -410,6 +413,7 @@ public class StandardToStringStyle extends ToStringStyle {
* of each buffer.</p> * of each buffer.</p>
* *
* @return fieldSeparatorAtEnd flag * @return fieldSeparatorAtEnd flag
* @since 2.0
*/ */
public boolean isFieldSeparatorAtEnd() { public boolean isFieldSeparatorAtEnd() {
return super.isFieldSeparatorAtEnd(); return super.isFieldSeparatorAtEnd();
@ -420,6 +424,7 @@ public class StandardToStringStyle extends ToStringStyle {
* of each buffer.</p> * of each buffer.</p>
* *
* @param fieldSeparatorAtEnd the fieldSeparatorAtEnd flag * @param fieldSeparatorAtEnd the fieldSeparatorAtEnd flag
* @since 2.0
*/ */
public void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) { public void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd); super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);

View File

@ -125,7 +125,7 @@ import org.apache.commons.lang.ObjectUtils;
* @author Gary Gregory * @author Gary Gregory
* @author Pete Gieser * @author Pete Gieser
* @since 1.0 * @since 1.0
* @version $Id: ToStringBuilder.java,v 1.27 2003/08/18 02:22:24 bayard Exp $ * @version $Id: ToStringBuilder.java,v 1.28 2003/08/21 15:52:54 ggregory Exp $
*/ */
public class ToStringBuilder { public class ToStringBuilder {
@ -183,6 +183,7 @@ public class ToStringBuilder {
* <p>Forwards to <code>ReflectionToStringBuilder</code>.</p> * <p>Forwards to <code>ReflectionToStringBuilder</code>.</p>
* *
* @see ReflectionToStringBuilder#toString(Object,ToStringStyle,boolean,Class) * @see ReflectionToStringBuilder#toString(Object,ToStringStyle,boolean,Class)
* @since 2.0
*/ */
public static String reflectionToString( public static String reflectionToString(
Object object, Object object,
@ -972,6 +973,7 @@ public class ToStringBuilder {
* {@link System#identityHashCode(java.lang.Object)}.</p> * {@link System#identityHashCode(java.lang.Object)}.</p>
* *
* @param object the <code>Object</code> whose class name and id to output * @param object the <code>Object</code> whose class name and id to output
* @since 2.0
*/ */
public ToStringBuilder appendAsObjectToString(Object object) { public ToStringBuilder appendAsObjectToString(Object object) {
ObjectUtils.appendIdentityToString(this.getStringBuffer(), object); ObjectUtils.appendIdentityToString(this.getStringBuffer(), object);
@ -990,6 +992,7 @@ public class ToStringBuilder {
* *
* @param superToString the result of <code>super.toString()</code> * @param superToString the result of <code>super.toString()</code>
* @return this * @return this
* @since 2.0
*/ */
public ToStringBuilder appendSuper(String superToString) { public ToStringBuilder appendSuper(String superToString) {
if (superToString != null) { if (superToString != null) {
@ -1023,6 +1026,7 @@ public class ToStringBuilder {
* *
* @param toString the result of <code>toString()</code> on another object * @param toString the result of <code>toString()</code> on another object
* @return this * @return this
* @since 2.0
*/ */
public ToStringBuilder appendToString(String toString) { public ToStringBuilder appendToString(String toString) {
if (toString != null) { if (toString != null) {
@ -1046,6 +1050,7 @@ public class ToStringBuilder {
* <p>Gets the <code>ToStringStyle</code> being used.</p> * <p>Gets the <code>ToStringStyle</code> being used.</p>
* *
* @return the <code>ToStringStyle</code> being used * @return the <code>ToStringStyle</code> being used
* @since 2.0
*/ */
public ToStringStyle getStyle() { public ToStringStyle getStyle() {
return style; return style;
@ -1068,6 +1073,7 @@ public class ToStringBuilder {
* <p>Returns the <code>Object</code> being output.</p> * <p>Returns the <code>Object</code> being output.</p>
* *
* @return The object being output. * @return The object being output.
* @since 2.0
*/ */
public Object getObject() { public Object getObject() {
return object; return object;

View File

@ -87,7 +87,7 @@ import org.apache.commons.lang.SystemUtils;
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Pete Gieser * @author Pete Gieser
* @since 1.0 * @since 1.0
* @version $Id: ToStringStyle.java,v 1.24 2003/08/18 02:22:24 bayard Exp $ * @version $Id: ToStringStyle.java,v 1.25 2003/08/21 15:52:54 ggregory Exp $
*/ */
public abstract class ToStringStyle implements Serializable { public abstract class ToStringStyle implements Serializable {
@ -221,6 +221,7 @@ public abstract class ToStringStyle implements Serializable {
* *
* @param buffer the <code>StringBuffer</code> to populate * @param buffer the <code>StringBuffer</code> to populate
* @param toString the additional <code>toString</code> * @param toString the additional <code>toString</code>
* @since 2.0
*/ */
public void appendToString(StringBuffer buffer, String toString) { public void appendToString(StringBuffer buffer, String toString) {
if (toString != null) { if (toString != null) {
@ -271,6 +272,7 @@ public abstract class ToStringStyle implements Serializable {
* <p>Remove the last field separator from the buffer.</p> * <p>Remove the last field separator from the buffer.</p>
* *
* @param buffer the <code>StringBuffer</code> to populate * @param buffer the <code>StringBuffer</code> to populate
* @since 2.0
*/ */
protected void removeLastFieldSeparator(StringBuffer buffer) { protected void removeLastFieldSeparator(StringBuffer buffer) {
int len = buffer.length(); int len = buffer.length();
@ -762,6 +764,7 @@ public abstract class ToStringStyle implements Serializable {
* @param fieldName the field name, typically not used as already appended * @param fieldName the field name, typically not used as already appended
* @param array the array to add to the <code>toString</code>, * @param array the array to add to the <code>toString</code>,
* not <code>null</code> * not <code>null</code>
* @since 2.0
*/ */
protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array) { protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array) {
buffer.append(arrayStart); buffer.append(arrayStart);
@ -1459,6 +1462,7 @@ public abstract class ToStringStyle implements Serializable {
* <p>Gets whether to output short or long class names.</p> * <p>Gets whether to output short or long class names.</p>
* *
* @return the current useShortClassName flag * @return the current useShortClassName flag
* @since 2.0
*/ */
protected boolean isUseShortClassName() { protected boolean isUseShortClassName() {
return useShortClassName; return useShortClassName;
@ -1479,6 +1483,7 @@ public abstract class ToStringStyle implements Serializable {
* <p>Sets whether to output short or long class names.</p> * <p>Sets whether to output short or long class names.</p>
* *
* @param useShortClassName the new useShortClassName flag * @param useShortClassName the new useShortClassName flag
* @since 2.0
*/ */
protected void setUseShortClassName(boolean useShortClassName) { protected void setUseShortClassName(boolean useShortClassName) {
this.useShortClassName = useShortClassName; this.useShortClassName = useShortClassName;
@ -1766,6 +1771,7 @@ public abstract class ToStringStyle implements Serializable {
* of each buffer.</p> * of each buffer.</p>
* *
* @return the fieldSeparatorAtStart flag * @return the fieldSeparatorAtStart flag
* @since 2.0
*/ */
protected boolean isFieldSeparatorAtStart() { protected boolean isFieldSeparatorAtStart() {
return fieldSeparatorAtStart; return fieldSeparatorAtStart;
@ -1776,6 +1782,7 @@ public abstract class ToStringStyle implements Serializable {
* of each buffer.</p> * of each buffer.</p>
* *
* @param fieldSeparatorAtStart the fieldSeparatorAtStart flag * @param fieldSeparatorAtStart the fieldSeparatorAtStart flag
* @since 2.0
*/ */
protected void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) { protected void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) {
this.fieldSeparatorAtStart = fieldSeparatorAtStart; this.fieldSeparatorAtStart = fieldSeparatorAtStart;
@ -1788,6 +1795,7 @@ public abstract class ToStringStyle implements Serializable {
* of each buffer.</p> * of each buffer.</p>
* *
* @return fieldSeparatorAtEnd flag * @return fieldSeparatorAtEnd flag
* @since 2.0
*/ */
protected boolean isFieldSeparatorAtEnd() { protected boolean isFieldSeparatorAtEnd() {
return fieldSeparatorAtEnd; return fieldSeparatorAtEnd;
@ -1798,6 +1806,7 @@ public abstract class ToStringStyle implements Serializable {
* of each buffer.</p> * of each buffer.</p>
* *
* @param fieldSeparatorAtEnd the fieldSeparatorAtEnd flag * @param fieldSeparatorAtEnd the fieldSeparatorAtEnd flag
* @since 2.0
*/ */
protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) { protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
this.fieldSeparatorAtEnd = fieldSeparatorAtEnd; this.fieldSeparatorAtEnd = fieldSeparatorAtEnd;

View File

@ -220,7 +220,7 @@ import org.apache.commons.lang.StringUtils;
* @author Chris Webb * @author Chris Webb
* @author Mike Bowler * @author Mike Bowler
* @since 1.0 * @since 1.0
* @version $Id: Enum.java,v 1.20 2003/08/18 02:22:24 bayard Exp $ * @version $Id: Enum.java,v 1.21 2003/08/21 15:52:55 ggregory Exp $
*/ */
public abstract class Enum implements Comparable, Serializable { public abstract class Enum implements Comparable, Serializable {
@ -233,20 +233,25 @@ public abstract class Enum implements Comparable, Serializable {
* An empty <code>Map</code>, as JDK1.2 didn't have an empty map. * An empty <code>Map</code>, as JDK1.2 didn't have an empty map.
*/ */
private static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap(0)); private static final Map EMPTY_MAP = Collections.unmodifiableMap(new HashMap(0));
/** /**
* <code>Map</code>, key of class name, value of <code>Entry</code>. * <code>Map</code>, key of class name, value of <code>Entry</code>.
*/ */
private static final Map cEnumClasses = new HashMap(); private static final Map cEnumClasses = new HashMap();
/** /**
* The string representation of the Enum. * The string representation of the Enum.
*/ */
private final String iName; private final String iName;
/** /**
* The hashcode representation of the Enum. * The hashcode representation of the Enum.
*/ */
private transient final int iHashCode; private transient final int iHashCode;
/** /**
* The toString representation of the Enum. * The toString representation of the Enum.
* @since 2.0
*/ */
protected transient String iToString = null; protected transient String iToString = null;
@ -493,6 +498,7 @@ public abstract class Enum implements Comparable, Serializable {
* constant value.</p> * constant value.</p>
* *
* @return the <code>Class</code> of the enum * @return the <code>Class</code> of the enum
* @since 2.0
*/ */
public Class getEnumClass() { public Class getEnumClass() {
return getClass(); return getClass();

View File

@ -80,7 +80,7 @@ import org.apache.commons.lang.SystemUtils;
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a> * @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Pete Gieser * @author Pete Gieser
* @since 1.0 * @since 1.0
* @version $Id: ExceptionUtils.java,v 1.33 2003/08/18 02:22:24 bayard Exp $ * @version $Id: ExceptionUtils.java,v 1.34 2003/08/21 15:52:55 ggregory Exp $
*/ */
public class ExceptionUtils { public class ExceptionUtils {
@ -134,6 +134,7 @@ public class ExceptionUtils {
* *
* @param methodName the methodName to add to the list, <code>null</code> * @param methodName the methodName to add to the list, <code>null</code>
* and empty strings are ignored * and empty strings are ignored
* @since 2.0
*/ */
public static void addCauseMethodName(String methodName) { public static void addCauseMethodName(String methodName) {
if (StringUtils.isNotEmpty(methodName)) { if (StringUtils.isNotEmpty(methodName)) {
@ -322,6 +323,7 @@ public class ExceptionUtils {
* <p>This is true for JDK 1.4 and above.</p> * <p>This is true for JDK 1.4 and above.</p>
* *
* @return true if Throwable is nestable * @return true if Throwable is nestable
* @since 2.0
*/ */
public static boolean isThrowableNested() { public static boolean isThrowableNested() {
return (THROWABLE_CAUSE_METHOD != null); return (THROWABLE_CAUSE_METHOD != null);
@ -334,6 +336,7 @@ public class ExceptionUtils {
* *
* @param throwable the <code>Throwable</code> to examine, may be null * @param throwable the <code>Throwable</code> to examine, may be null
* @return boolean <code>true</code> if nested otherwise <code>false</code> * @return boolean <code>true</code> if nested otherwise <code>false</code>
* @since 2.0
*/ */
public static boolean isNestedThrowable(Throwable throwable) { public static boolean isNestedThrowable(Throwable throwable) {
if (throwable == null) { if (throwable == null) {
@ -484,6 +487,7 @@ public class ExceptionUtils {
* that don't have nested causes.</p> * that don't have nested causes.</p>
* *
* @param throwable the throwable to output * @param throwable the throwable to output
* @since 2.0
*/ */
public static void printRootCauseStackTrace(Throwable throwable) { public static void printRootCauseStackTrace(Throwable throwable) {
printRootCauseStackTrace(throwable, System.err); printRootCauseStackTrace(throwable, System.err);
@ -503,6 +507,7 @@ public class ExceptionUtils {
* @param throwable the throwable to output, may be null * @param throwable the throwable to output, may be null
* @param stream the stream to output to, may not be null * @param stream the stream to output to, may not be null
* @throws IllegalArgumentException if the stream is <code>null</code> * @throws IllegalArgumentException if the stream is <code>null</code>
* @since 2.0
*/ */
public static void printRootCauseStackTrace(Throwable throwable, PrintStream stream) { public static void printRootCauseStackTrace(Throwable throwable, PrintStream stream) {
if (throwable == null) { if (throwable == null) {
@ -532,6 +537,7 @@ public class ExceptionUtils {
* @param throwable the throwable to output, may be null * @param throwable the throwable to output, may be null
* @param writer the writer to output to, may not be null * @param writer the writer to output to, may not be null
* @throws IllegalArgumentException if the writer is <code>null</code> * @throws IllegalArgumentException if the writer is <code>null</code>
* @since 2.0
*/ */
public static void printRootCauseStackTrace(Throwable throwable, PrintWriter writer) { public static void printRootCauseStackTrace(Throwable throwable, PrintWriter writer) {
if (throwable == null) { if (throwable == null) {
@ -554,6 +560,7 @@ public class ExceptionUtils {
* *
* @param throwable the throwable to examine, may be null * @param throwable the throwable to examine, may be null
* @return an array of stack trace frames, never null * @return an array of stack trace frames, never null
* @since 2.0
*/ */
public static String[] getRootCauseStackTrace(Throwable throwable) { public static String[] getRootCauseStackTrace(Throwable throwable) {
if (throwable == null) { if (throwable == null) {
@ -587,6 +594,7 @@ public class ExceptionUtils {
* @param causeFrames stack trace of a cause throwable * @param causeFrames stack trace of a cause throwable
* @param wrapperFrames stack trace of a wrapper throwable * @param wrapperFrames stack trace of a wrapper throwable
* @throws IllegalArgumentException if either argument is null * @throws IllegalArgumentException if either argument is null
* @since 2.0
*/ */
public static void removeCommonFrames(List causeFrames, List wrapperFrames) { public static void removeCommonFrames(List causeFrames, List wrapperFrames) {
if (causeFrames == null || wrapperFrames == null) { if (causeFrames == null || wrapperFrames == null) {
@ -627,6 +635,7 @@ public class ExceptionUtils {
* *
* @param throwable the <code>Throwable</code> to be examined * @param throwable the <code>Throwable</code> to be examined
* @return the nested stack trace, with the root cause first * @return the nested stack trace, with the root cause first
* @since 2.0
*/ */
public static String getFullStackTrace(Throwable throwable) { public static String getFullStackTrace(Throwable throwable) {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();