geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r576632 [1/2] - /geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/
Date Tue, 18 Sep 2007 00:22:05 GMT
Author: jdillon
Date: Mon Sep 17 17:22:04 2007
New Revision: 576632

URL: http://svn.apache.org/viewvc?rev=576632&view=rev
Log:
Add the ToStringBuilder muck from commons-lang

Added:
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringStyle.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/package-info.java   (with props)

Added: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java?rev=576632&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java Mon Sep 17 17:22:04 2007
@@ -0,0 +1,777 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.common.tostring;
+
+//
+// NOTE: Copied and massaged from commons-lang 2.3
+//
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * <p>
+ * Assists in implementing {@link Object#toString()} methods using reflection.
+ * </p>
+ *
+ * <p>
+ * This class uses reflection to determine the fields to append. Because these fields are usually private, the class
+ * uses {@link java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[], boolean)} to
+ * change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions are
+ * set up correctly.
+ * </p>
+ *
+ * <p>
+ * A typical invocation for this method would look like:
+ * </p>
+ *
+ * <pre>
+ * public String toString() {
+ *   return ReflectionToStringBuilder.toString(this);
+ * }</pre>
+ *
+ *
+ *
+ * <p>
+ * You can also use the builder to debug 3rd party objects:
+ * </p>
+ *
+ * <pre>
+ * System.out.println("An object: " + ReflectionToStringBuilder.toString(anObject));</pre>
+ *
+ *
+ *
+ * <p>
+ * A subclass can control field output by overriding the methods:
+ * <ul>
+ * <li>{@link #accept(java.lang.reflect.Field)}</li>
+ * <li>{@link #getValue(java.lang.reflect.Field)}</li>
+ * </ul>
+ * </p>
+ * <p>
+ * For example, this method does <i>not</i> include the <code>password</code> field in the returned
+ * <code>String</code>:
+ * </p>
+ *
+ * <pre>
+ * public String toString() {
+ *     return (new ReflectionToStringBuilder(this) {
+ *         protected boolean accept(Field f) {
+ *             return super.accept(f) && !f.getName().equals("password");
+ *         }
+ *     }).toString();
+ * }</pre>
+ *
+ *
+ *
+ * <p>
+ * The exact format of the <code>toString</code> is determined by the {@link ToStringStyle} passed into the
+ * constructor.
+ * </p>
+ *
+ * @author Gary Gregory
+ * @author Stephen Colebourne
+ * @author Pete Gieser
+ * @since 2.0
+ * @version $Id$
+ */
+public class ReflectionToStringBuilder extends ToStringBuilder {
+
+    /**
+     * <p>
+     * Builds a <code>toString</code> value using the default <code>ToStringStyle</code> through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * Transient members will be not be included, as they are likely derived. Static fields will not be included.
+     * Superclass fields will be appended.
+     * </p>
+     *
+     * @param object
+     *            the Object to be output
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     */
+    public static String toString(Object object) {
+        return toString(object, null, false, false, null);
+    }
+
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * Transient members will be not be included, as they are likely derived. Static fields will not be included.
+     * Superclass fields will be appended.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object or <code>ToStringStyle</code> is <code>null</code>
+     */
+    public static String toString(Object object, ToStringStyle style) {
+        return toString(object, style, false, false, null);
+    }
+
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputTransients</code> is <code>true</code>, transient members will be output, otherwise they
+     * are ignored, as they are likely derived fields, and not part of the value of the Object.
+     * </p>
+     *
+     * <p>
+     * Static fields will not be included. Superclass fields will be appended.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     */
+    public static String toString(Object object, ToStringStyle style, boolean outputTransients) {
+        return toString(object, style, outputTransients, false, null);
+    }
+
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputTransients</code> is <code>true</code>, transient fields will be output, otherwise they
+     * are ignored, as they are likely derived fields, and not part of the value of the Object.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputStatics</code> is <code>true</code>, static fields will be output, otherwise they are
+     * ignored.
+     * </p>
+     *
+     * <p>
+     * Static fields will not be included. Superclass fields will be appended.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include transient fields
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     * @since 2.1
+     */
+    public static String toString(Object object, ToStringStyle style, boolean outputTransients, boolean outputStatics) {
+        return toString(object, style, outputTransients, outputStatics, null);
+    }
+
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputTransients</code> is <code>true</code>, transient fields will be output, otherwise they
+     * are ignored, as they are likely derived fields, and not part of the value of the Object.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputStatics</code> is <code>true</code>, static fields will be output, otherwise they are
+     * ignored.
+     * </p>
+     *
+     * <p>
+     * Superclass fields will be appended up to and including the specified superclass. A null superclass is treated as
+     * <code>java.lang.Object</code>.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include static fields
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     * @since 2.1
+     */
+    public static String toString(Object object, ToStringStyle style, boolean outputTransients, boolean outputStatics,
+            Class reflectUpToClass) {
+        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics)
+                .toString();
+    }
+
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputTransients</code> is <code>true</code>, transient members will be output, otherwise they
+     * are ignored, as they are likely derived fields, and not part of the value of the Object.
+     * </p>
+     *
+     * <p>
+     * Static fields will not be included. Superclass fields will be appended up to and including the specified
+     * superclass. A null superclass is treated as <code>java.lang.Object</code>.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @deprecated Use {@link #toString(Object,ToStringStyle,boolean,boolean,Class)}
+     *
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     * @since 2.0
+     */
+    public static String toString(Object object, ToStringStyle style,
+                                  boolean outputTransients, Class reflectUpToClass)
+    {
+        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients).toString();
+    }
+
+    /**
+     * Builds a String for a toString method excluding the given field name.
+     *
+     * @param object
+     *            The object to "toString".
+     * @param excludeFieldName
+     *            The field name to exclude
+     * @return The toString value.
+     */
+    public static String toStringExclude(Object object, final String excludeFieldName) {
+        return toStringExclude(object, new String[]{excludeFieldName});
+    }
+
+    /**
+     * Builds a String for a toString method excluding the given field names.
+     *
+     * @param object
+     *            The object to "toString".
+     * @param excludeFieldNames
+     *            The field names to exclude. Null excludes nothing.
+     * @return The toString value.
+     */
+    public static String toStringExclude(Object object, Collection /*String*/ excludeFieldNames) {
+        return toStringExclude(object, toNoNullStringArray(excludeFieldNames));
+    }
+
+    /**
+     * Converts the given Collection into an array of Strings. The returned array does not contain <code>null</code>
+     * entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element
+     * is <code>null</code>.
+     *
+     * @param collection
+     *            The collection to convert
+     * @return A new array of Strings.
+     */
+    static String[] toNoNullStringArray(Collection collection) {
+        if (collection == null) {
+            return ArrayUtils_EMPTY_STRING_ARRAY;
+        }
+        return toNoNullStringArray(collection.toArray());
+    }
+
+    /**
+     * Returns a new array of Strings without null elements. Internal method used to normalize exclude lists
+     * (arrays and collections). Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException}
+     * if an array element is <code>null</code>.
+     *
+     * @param array
+     *            The array to check
+     * @return The given array or a new array without null.
+     */
+    static String[] toNoNullStringArray(Object[] array) {
+        ArrayList list = new ArrayList(array.length);
+        for (int i = 0; i < array.length; i++) {
+            Object e = array[i];
+            if (e != null) {
+                list.add(e.toString());
+            }
+        }
+        return (String[]) list.toArray(ArrayUtils_EMPTY_STRING_ARRAY);
+    }
+
+
+    /**
+     * Builds a String for a toString method excluding the given field names.
+     *
+     * @param object
+     *            The object to "toString".
+     * @param excludeFieldNames
+     *            The field names to exclude
+     * @return The toString value.
+     */
+    public static String toStringExclude(Object object, String[] excludeFieldNames) {
+        return new ReflectionToStringBuilder(object).setExcludeFieldNames(excludeFieldNames).toString();
+    }
+
+    /**
+     * Whether or not to append static fields.
+     */
+    private boolean appendStatics = false;
+
+    /**
+     * Whether or not to append transient fields.
+     */
+    private boolean appendTransients = false;
+
+    /**
+     * Which field names to exclude from output. Intended for fields like <code>"password"</code>.
+     */
+    private String[] excludeFieldNames;
+
+    /**
+     * The last super class to stop appending fields for.
+     */
+    private Class upToClass = null;
+
+    /**
+     * <p>
+     * Constructor.
+     * </p>
+     *
+     * <p>
+     * This constructor outputs using the default style set with <code>setDefaultStyle</code>.
+     * </p>
+     *
+     * @param object
+     *            the Object to build a <code>toString</code> for, must not be <code>null</code>
+     * @throws IllegalArgumentException
+     *             if the Object passed in is <code>null</code>
+     */
+    public ReflectionToStringBuilder(Object object) {
+        super(object);
+    }
+
+    /**
+     * <p>
+     * Constructor.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default style is used.
+     * </p>
+     *
+     * @param object
+     *            the Object to build a <code>toString</code> for, must not be <code>null</code>
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @throws IllegalArgumentException
+     *             if the Object passed in is <code>null</code>
+     */
+    public ReflectionToStringBuilder(Object object, ToStringStyle style) {
+        super(object, style);
+    }
+
+    /**
+     * <p>
+     * Constructor.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default style is used.
+     * </p>
+     *
+     * <p>
+     * If the buffer is <code>null</code>, a new one is created.
+     * </p>
+     *
+     * @param object
+     *            the Object to build a <code>toString</code> for
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param buffer
+     *            the <code>StringBuffer</code> to populate, may be <code>null</code>
+     * @throws IllegalArgumentException
+     *             if the Object passed in is <code>null</code>
+     */
+    public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer) {
+        super(object, style, buffer);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @deprecated Use {@link #ReflectionToStringBuilder(Object,ToStringStyle,StringBuffer,Class,boolean,boolean)}.
+     *
+     * @param object
+     *            the Object to build a <code>toString</code> for
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param buffer
+     *            the <code>StringBuffer</code> to populate, may be <code>null</code>
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     */
+    public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer, Class reflectUpToClass,
+            boolean outputTransients) {
+        super(object, style, buffer);
+        this.setUpToClass(reflectUpToClass);
+        this.setAppendTransients(outputTransients);
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param object
+     *            the Object to build a <code>toString</code> for
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param buffer
+     *            the <code>StringBuffer</code> to populate, may be <code>null</code>
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include static fields
+     * @since 2.1
+     */
+    public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer, Class reflectUpToClass,
+            boolean outputTransients, boolean outputStatics) {
+        super(object, style, buffer);
+        this.setUpToClass(reflectUpToClass);
+        this.setAppendTransients(outputTransients);
+        this.setAppendStatics(outputStatics);
+    }
+
+    /**
+     * Returns whether or not to append the given <code>Field</code>.
+     * <ul>
+     * <li>Transient fields are appended only if {@link #isAppendTransients()} returns <code>true</code>.
+     * <li>Static fields are appended only if {@link #isAppendStatics()} returns <code>true</code>.
+     * <li>Inner class fields are not appened.</li>
+     * </ul>
+     *
+     * @param field
+     *            The Field to test.
+     * @return Whether or not to append the given <code>Field</code>.
+     */
+    protected boolean accept(Field field) {
+        if (field.getName().indexOf(ClassUtils_INNER_CLASS_SEPARATOR_CHAR) != -1) {
+            // Reject field from inner class.
+            return false;
+        }
+        if (Modifier.isTransient(field.getModifiers()) && !this.isAppendTransients()) {
+            // Reject transient fields.
+            return false;
+        }
+        if (Modifier.isStatic(field.getModifiers()) && !this.isAppendStatics()) {
+            // Rject static fields.
+            return false;
+        }
+        if (this.getExcludeFieldNames() != null
+            && Arrays.binarySearch(this.getExcludeFieldNames(), field.getName()) >= 0) {
+            // Reject fields from the getExcludeFieldNames list.
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * <p>
+     * Appends the fields and values defined by the given object of the given Class.
+     * </p>
+     *
+     * <p>
+     * If a cycle is detected as an object is &quot;toString()'ed&quot;, such an object is rendered as if
+     * <code>Object.toString()</code> had been called and not implemented by the object.
+     * </p>
+     *
+     * @param clazz
+     *            The class of object parameter
+     */
+    protected void appendFieldsIn(Class clazz) {
+        if (clazz.isArray()) {
+            this.reflectionAppendArray(this.getObject());
+            return;
+        }
+        Field[] fields = clazz.getDeclaredFields();
+        AccessibleObject.setAccessible(fields, true);
+        for (int i = 0; i < fields.length; i++) {
+            Field field = fields[i];
+            String fieldName = field.getName();
+            if (this.accept(field)) {
+                try {
+                    // Warning: Field.get(Object) creates wrappers objects
+                    // for primitive types.
+                    Object fieldValue = this.getValue(field);
+                    this.append(fieldName, fieldValue);
+                } catch (IllegalAccessException ex) {
+                    //this can't happen. Would get a Security exception
+                    // instead
+                    //throw a runtime exception in case the impossible
+                    // happens.
+                    throw new InternalError("Unexpected IllegalAccessException: " + ex.getMessage());
+                }
+            }
+        }
+    }
+
+    /**
+     * @return Returns the excludeFieldNames.
+     */
+    public String[] getExcludeFieldNames() {
+        return this.excludeFieldNames;
+    }
+
+    /**
+     * <p>
+     * Gets the last super class to stop appending fields for.
+     * </p>
+     *
+     * @return The last super class to stop appending fields for.
+     */
+    public Class getUpToClass() {
+        return this.upToClass;
+    }
+
+    /**
+     * <p>
+     * Calls <code>java.lang.reflect.Field.get(Object)</code>.
+     * </p>
+     *
+     * @param field
+     *            The Field to query.
+     * @return The Object from the given Field.
+     *
+     * @throws IllegalArgumentException
+     *             see {@link java.lang.reflect.Field#get(Object)}
+     * @throws IllegalAccessException
+     *             see {@link java.lang.reflect.Field#get(Object)}
+     *
+     * @see java.lang.reflect.Field#get(Object)
+     */
+    protected Object getValue(Field field) throws IllegalArgumentException, IllegalAccessException {
+        return field.get(this.getObject());
+    }
+
+    /**
+     * <p>
+     * Gets whether or not to append static fields.
+     * </p>
+     *
+     * @return Whether or not to append static fields.
+     * @since 2.1
+     */
+    public boolean isAppendStatics() {
+        return this.appendStatics;
+    }
+
+    /**
+     * <p>
+     * Gets whether or not to append transient fields.
+     * </p>
+     *
+     * @return Whether or not to append transient fields.
+     */
+    public boolean isAppendTransients() {
+        return this.appendTransients;
+    }
+
+    /**
+     * <p>
+     * Append to the <code>toString</code> an <code>Object</code> array.
+     * </p>
+     *
+     * @param array
+     *            the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder reflectionAppendArray(Object array) {
+        this.getStyle().reflectionAppendArrayDetail(this.getStringBuffer(), null, array);
+        return this;
+    }
+
+    /**
+     * <p>
+     * Sets whether or not to append static fields.
+     * </p>
+     *
+     * @param appendStatics
+     *            Whether or not to append static fields.
+     * @since 2.1
+     */
+    public void setAppendStatics(boolean appendStatics) {
+        this.appendStatics = appendStatics;
+    }
+
+    /**
+     * <p>
+     * Sets whether or not to append transient fields.
+     * </p>
+     *
+     * @param appendTransients
+     *            Whether or not to append transient fields.
+     */
+    public void setAppendTransients(boolean appendTransients) {
+        this.appendTransients = appendTransients;
+    }
+
+    /**
+     * Sets the field names to exclude.
+     *
+     * @param excludeFieldNamesParam
+     *            The excludeFieldNames to excluding from toString or <code>null</code>.
+     * @return <code>this</code>
+     */
+    public ReflectionToStringBuilder setExcludeFieldNames(String[] excludeFieldNamesParam) {
+        if (excludeFieldNamesParam == null) {
+            this.excludeFieldNames = null;
+        } else {
+            this.excludeFieldNames = toNoNullStringArray(excludeFieldNamesParam);
+            Arrays.sort(this.excludeFieldNames);
+        }
+        return this;
+    }
+
+    /**
+     * <p>
+     * Sets the last super class to stop appending fields for.
+     * </p>
+     *
+     * @param clazz
+     *            The last super class to stop appending fields for.
+     */
+    public void setUpToClass(Class clazz) {
+        this.upToClass = clazz;
+    }
+
+    /**
+     * <p>
+     * Gets the String built by this builder.
+     * </p>
+     *
+     * @return the built string
+     */
+    public String toString() {
+        if (this.getObject() == null) {
+            return this.getStyle().getNullText();
+        }
+        Class clazz = this.getObject().getClass();
+        this.appendFieldsIn(clazz);
+        while (clazz.getSuperclass() != null && clazz != this.getUpToClass()) {
+            clazz = clazz.getSuperclass();
+            this.appendFieldsIn(clazz);
+        }
+        return super.toString();
+    }
+
+    //
+    // NOTE: Unrolled from commons-lang bits
+    //
+
+    private static final String[] ArrayUtils_EMPTY_STRING_ARRAY = {};
+
+    private static final char ClassUtils_INNER_CLASS_SEPARATOR_CHAR = '$';
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ReflectionToStringBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java?rev=576632&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java Mon Sep 17 17:22:04 2007
@@ -0,0 +1,552 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.common.tostring;
+
+//
+// NOTE: Copied and massaged from commons-lang 2.3
+//
+
+/**
+ * <p>Works with {@link ToStringBuilder} to create a <code>toString</code>.</p>
+ *
+ * <p>This class is intended to be used as a singleton.
+ * There is no need to instantiate a new style each time.
+ * Simply instantiate the class once, customize the values as required, and
+ * store the result in a public static final variable for the rest of the
+ * program to access.</p>
+ *
+ * @author Stephen Colebourne
+ * @author Pete Gieser
+ * @author Gary Gregory
+ * @since 1.0
+ * @version $Id$
+ */
+public class StandardToStringStyle extends ToStringStyle {
+
+    /**
+     * Required for serialization support.
+     *
+     * @see java.io.Serializable
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * <p>Constructor.</p>
+     */
+    public StandardToStringStyle() {
+        super();
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether to use the class name.</p>
+     *
+     * @return the current useClassName flag
+     */
+    public boolean isUseClassName() {
+        return super.isUseClassName();
+    }
+
+    /**
+     * <p>Sets whether to use the class name.</p>
+     *
+     * @param useClassName  the new useClassName flag
+     */
+    public void setUseClassName(boolean useClassName) {
+        super.setUseClassName(useClassName);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether to output short or long class names.</p>
+     *
+     * @return the current useShortClassName flag
+     * @since 2.0
+     */
+    public boolean isUseShortClassName() {
+        return super.isUseShortClassName();
+    }
+
+    /**
+     * <p>Gets whether to output short or long class names.</p>
+     *
+     * @return the current shortClassName flag
+     * @deprecated Use {@link #isUseShortClassName()}
+     *             Method will be removed in Commons Lang 3.0.
+     */
+    public boolean isShortClassName() {
+        return super.isUseShortClassName();
+    }
+
+    /**
+     * <p>Sets whether to output short or long class names.</p>
+     *
+     * @param useShortClassName  the new useShortClassName flag
+     * @since 2.0
+     */
+    public void setUseShortClassName(boolean useShortClassName) {
+        super.setUseShortClassName(useShortClassName);
+    }
+
+    /**
+     * <p>Sets whether to output short or long class names.</p>
+     *
+     * @param shortClassName  the new shortClassName flag
+     * @deprecated Use {@link #setUseShortClassName(boolean)}
+     *             Method will be removed in Commons Lang 3.0.
+     */
+    public void setShortClassName(boolean shortClassName) {
+        super.setUseShortClassName(shortClassName);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether to use the identity hash code.</p>
+     * @return the current useIdentityHashCode flag
+     */
+    public boolean isUseIdentityHashCode() {
+        return super.isUseIdentityHashCode();
+    }
+
+    /**
+     * <p>Sets whether to use the identity hash code.</p>
+     *
+     * @param useIdentityHashCode  the new useIdentityHashCode flag
+     */
+    public void setUseIdentityHashCode(boolean useIdentityHashCode) {
+        super.setUseIdentityHashCode(useIdentityHashCode);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether to use the field names passed in.</p>
+     *
+     * @return the current useFieldNames flag
+     */
+    public boolean isUseFieldNames() {
+        return super.isUseFieldNames();
+    }
+
+    /**
+     * <p>Sets whether to use the field names passed in.</p>
+     *
+     * @param useFieldNames  the new useFieldNames flag
+     */
+    public void setUseFieldNames(boolean useFieldNames) {
+        super.setUseFieldNames(useFieldNames);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether to use full detail when the caller doesn't
+     * specify.</p>
+     *
+     * @return the current defaultFullDetail flag
+     */
+    public boolean isDefaultFullDetail() {
+        return super.isDefaultFullDetail();
+    }
+
+    /**
+     * <p>Sets whether to use full detail when the caller doesn't
+     * specify.</p>
+     *
+     * @param defaultFullDetail  the new defaultFullDetail flag
+     */
+    public void setDefaultFullDetail(boolean defaultFullDetail) {
+        super.setDefaultFullDetail(defaultFullDetail);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether to output array content detail.</p>
+     *
+     * @return the current array content detail setting
+     */
+    public boolean isArrayContentDetail() {
+        return super.isArrayContentDetail();
+    }
+
+    /**
+     * <p>Sets whether to output array content detail.</p>
+     *
+     * @param arrayContentDetail  the new arrayContentDetail flag
+     */
+    public void setArrayContentDetail(boolean arrayContentDetail) {
+        super.setArrayContentDetail(arrayContentDetail);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the array start text.</p>
+     *
+     * @return the current array start text
+     */
+    public String getArrayStart() {
+        return super.getArrayStart();
+    }
+
+    /**
+     * <p>Sets the array start text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param arrayStart  the new array start text
+     */
+    public void setArrayStart(String arrayStart) {
+        super.setArrayStart(arrayStart);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the array end text.</p>
+     *
+     * @return the current array end text
+     */
+    public String getArrayEnd() {
+        return super.getArrayEnd();
+    }
+
+    /**
+     * <p>Sets the array end text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param arrayEnd  the new array end text
+     */
+    public void setArrayEnd(String arrayEnd) {
+        super.setArrayEnd(arrayEnd);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the array separator text.</p>
+     *
+     * @return the current array separator text
+     */
+    public String getArraySeparator() {
+        return super.getArraySeparator();
+    }
+
+    /**
+     * <p>Sets the array separator text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param arraySeparator  the new array separator text
+     */
+    public void setArraySeparator(String arraySeparator) {
+        super.setArraySeparator(arraySeparator);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the content start text.</p>
+     *
+     * @return the current content start text
+     */
+    public String getContentStart() {
+        return super.getContentStart();
+    }
+
+    /**
+     * <p>Sets the content start text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param contentStart  the new content start text
+     */
+    public void setContentStart(String contentStart) {
+        super.setContentStart(contentStart);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the content end text.</p>
+     *
+     * @return the current content end text
+     */
+    public String getContentEnd() {
+        return super.getContentEnd();
+    }
+
+    /**
+     * <p>Sets the content end text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param contentEnd  the new content end text
+     */
+    public void setContentEnd(String contentEnd) {
+        super.setContentEnd(contentEnd);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the field name value separator text.</p>
+     *
+     * @return the current field name value separator text
+     */
+    public String getFieldNameValueSeparator() {
+        return super.getFieldNameValueSeparator();
+    }
+
+    /**
+     * <p>Sets the field name value separator text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param fieldNameValueSeparator  the new field name value separator text
+     */
+    public void setFieldNameValueSeparator(String fieldNameValueSeparator) {
+        super.setFieldNameValueSeparator(fieldNameValueSeparator);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the field separator text.</p>
+     *
+     * @return the current field separator text
+     */
+    public String getFieldSeparator() {
+        return super.getFieldSeparator();
+    }
+
+    /**
+     * <p>Sets the field separator text.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param fieldSeparator  the new field separator text
+     */
+    public void setFieldSeparator(String fieldSeparator) {
+        super.setFieldSeparator(fieldSeparator);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether the field separator should be added at the start
+     * of each buffer.</p>
+     *
+     * @return the fieldSeparatorAtStart flag
+     * @since 2.0
+     */
+    public boolean isFieldSeparatorAtStart() {
+        return super.isFieldSeparatorAtStart();
+    }
+
+    /**
+     * <p>Sets whether the field separator should be added at the start
+     * of each buffer.</p>
+     *
+     * @param fieldSeparatorAtStart  the fieldSeparatorAtStart flag
+     * @since 2.0
+     */
+    public void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) {
+        super.setFieldSeparatorAtStart(fieldSeparatorAtStart);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets whether the field separator should be added at the end
+     * of each buffer.</p>
+     *
+     * @return fieldSeparatorAtEnd flag
+     * @since 2.0
+     */
+    public boolean isFieldSeparatorAtEnd() {
+        return super.isFieldSeparatorAtEnd();
+    }
+
+    /**
+     * <p>Sets whether the field separator should be added at the end
+     * of each buffer.</p>
+     *
+     * @param fieldSeparatorAtEnd  the fieldSeparatorAtEnd flag
+     * @since 2.0
+     */
+    public void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
+        super.setFieldSeparatorAtEnd(fieldSeparatorAtEnd);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the text to output when <code>null</code> found.</p>
+     *
+     * @return the current text to output when <code>null</code> found
+     */
+    public String getNullText() {
+        return super.getNullText();
+    }
+
+    /**
+     * <p>Sets the text to output when <code>null</code> found.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param nullText  the new text to output when <code>null</code> found
+     */
+    public void setNullText(String nullText) {
+        super.setNullText(nullText);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the text to output when a <code>Collection</code>,
+     * <code>Map</code> or <code>Array</code> size is output.</p>
+     *
+     * <p>This is output before the size value.</p>
+     *
+     * @return the current start of size text
+     */
+    public String getSizeStartText() {
+        return super.getSizeStartText();
+    }
+
+    /**
+     * <p>Sets the start text to output when a <code>Collection</code>,
+     * <code>Map</code> or <code>Array</code> size is output.</p>
+     *
+     * <p>This is output before the size value.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted to
+     * an empty String.</p>
+     *
+     * @param sizeStartText  the new start of size text
+     */
+    public void setSizeStartText(String sizeStartText) {
+        super.setSizeStartText(sizeStartText);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * Gets the end text to output when a <code>Collection</code>,
+     * <code>Map</code> or <code>Array</code> size is output.</p>
+     *
+     * <p>This is output after the size value.</p>
+     *
+     * @return the current end of size text
+     */
+    public String getSizeEndText() {
+        return super.getSizeEndText();
+    }
+
+    /**
+     * <p>Sets the end text to output when a <code>Collection</code>,
+     * <code>Map</code> or <code>Array</code> size is output.</p>
+     *
+     * <p>This is output after the size value.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted
+     * to an empty String.</p>
+     *
+     * @param sizeEndText  the new end of size text
+     */
+    public void setSizeEndText(String sizeEndText) {
+        super.setSizeEndText(sizeEndText);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the start text to output when an <code>Object</code> is
+     * output in summary mode.</p>
+     *
+     * <P>This is output before the size value.</p>
+     *
+     * @return the current start of summary text
+     */
+    public String getSummaryObjectStartText() {
+        return super.getSummaryObjectStartText();
+    }
+
+    /**
+     * <p>Sets the start text to output when an <code>Object</code> is
+     * output in summary mode.</p>
+     *
+     * <p>This is output before the size value.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted to
+     * an empty String.</p>
+     *
+     * @param summaryObjectStartText  the new start of summary text
+     */
+    public void setSummaryObjectStartText(String summaryObjectStartText) {
+        super.setSummaryObjectStartText(summaryObjectStartText);
+    }
+
+    //---------------------------------------------------------------------
+
+    /**
+     * <p>Gets the end text to output when an <code>Object</code> is
+     * output in summary mode.</p>
+     *
+     * <p>This is output after the size value.</p>
+     *
+     * @return the current end of summary text
+     */
+    public String getSummaryObjectEndText() {
+        return super.getSummaryObjectEndText();
+    }
+
+    /**
+     * <p>Sets the end text to output when an <code>Object</code> is
+     * output in summary mode.</p>
+     *
+     * <p>This is output after the size value.</p>
+     *
+     * <p><code>null</code> is accepted, but will be converted to
+     * an empty String.</p>
+     *
+     * @param summaryObjectEndText  the new end of summary text
+     */
+    public void setSummaryObjectEndText(String summaryObjectEndText) {
+        super.setSummaryObjectEndText(summaryObjectEndText);
+    }
+
+    //---------------------------------------------------------------------
+
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/StandardToStringStyle.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java?rev=576632&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java Mon Sep 17 17:22:04 2007
@@ -0,0 +1,1081 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.common.tostring;
+
+//
+// NOTE: Copied and massaged from commons-lang 2.3
+//
+
+/**
+ * <p>Assists in implementing {@link Object#toString()} methods.</p>
+ *
+ * <p>This class enables a good and consistent <code>toString()</code> to be built for any
+ * class or object. This class aims to simplify the process by:</p>
+ * <ul>
+ *  <li>allowing field names</li>
+ *  <li>handling all types consistently</li>
+ *  <li>handling nulls consistently</li>
+ *  <li>outputting arrays and multi-dimensional arrays</li>
+ *  <li>enabling the detail level to be controlled for Objects and Collections</li>
+ *  <li>handling class hierarchies</li>
+ * </ul>
+ *
+ * <p>To use this class write code as follows:</p>
+ *
+ * <pre>
+ * public class Person {
+ *   String name;
+ *   int age;
+ *   boolean smoker;
+ *
+ *   ...
+ *
+ *   public String toString() {
+ *     return new ToStringBuilder(this).
+ *       append("name", name).
+ *       append("age", age).
+ *       append("smoker", smoker).
+ *       toString();
+ *   }
+ * }
+ * </pre>
+ *
+ * <p>This will produce a toString of the format:
+ * <code>Person@7f54[name=Stephen,age=29,smoker=false]</code></p>
+ *
+ * <p>To add the superclass <code>toString</code>, use {@link #appendSuper}.
+ * To append the <code>toString</code> from an object that is delegated
+ * to (or any other object), use {@link #appendToString}.</p>
+ *
+ * <p>Alternatively, there is a method that uses reflection to determine
+ * the fields to test. Because these fields are usually private, the method,
+ * <code>reflectionToString</code>, uses <code>AccessibleObject.setAccessible</code> to
+ * change the visibility of the fields. This will fail under a security manager,
+ * unless the appropriate permissions are set up correctly. It is also
+ * slower than testing explicitly.</p>
+ *
+ * <p>A typical invocation for this method would look like:</p>
+ *
+ * <pre>
+ * public String toString() {
+ *   return ToStringBuilder.reflectionToString(this);
+ * }
+ * </pre>
+ *
+ * <p>You can also use the builder to debug 3rd party objects:</p>
+ *
+ * <pre>
+ * System.out.println("An object: " + ToStringBuilder.reflectionToString(anObject));
+ * </pre>
+ *
+ * <p>The exact format of the <code>toString</code> is determined by
+ * the {@link ToStringStyle} passed into the constructor.</p>
+ *
+ * @author Stephen Colebourne
+ * @author Gary Gregory
+ * @author Pete Gieser
+ * @since 1.0
+ * @version $Id$
+ */
+public class ToStringBuilder {
+
+    /**
+     * The default style of output to use.
+     */
+    private static ToStringStyle defaultStyle = ToStringStyle.DEFAULT_STYLE;
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Gets the default <code>ToStringStyle</code> to use.</p>
+     *
+     * <p>This could allow the <code>ToStringStyle</code> to be
+     * controlled for an entire application with one call.</p>
+     *
+     * <p>This might be used to have a verbose
+     * <code>ToStringStyle</code> during development and a compact
+     * <code>ToStringStyle</code> in production.</p>
+     *
+     * @return the default <code>ToStringStyle</code>
+     */
+    public static ToStringStyle getDefaultStyle() {
+        return defaultStyle;
+    }
+
+    /**
+     * <p>Forwards to <code>ReflectionToStringBuilder</code>.</p>
+     *
+     * @param object  the Object to be output
+     * @return the String result
+     * @see ReflectionToStringBuilder#toString(Object)
+     */
+    public static String reflectionToString(Object object) {
+        return ReflectionToStringBuilder.toString(object);
+    }
+
+    /**
+     * <p>Forwards to <code>ReflectionToStringBuilder</code>.</p>
+     *
+     * @param object  the Object to be output
+     * @param style  the style of the <code>toString</code> to create, may be <code>null</code>
+     * @return the String result
+     * @see ReflectionToStringBuilder#toString(Object,ToStringStyle)
+     */
+    public static String reflectionToString(Object object, ToStringStyle style) {
+        return ReflectionToStringBuilder.toString(object, style);
+    }
+
+    /**
+     * <p>Forwards to <code>ReflectionToStringBuilder</code>.</p>
+     *
+     * @param object  the Object to be output
+     * @param style  the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients  whether to include transient fields
+     * @return the String result
+     * @see ReflectionToStringBuilder#toString(Object,ToStringStyle,boolean)
+     */
+    public static String reflectionToString(Object object, ToStringStyle style, boolean outputTransients) {
+        return ReflectionToStringBuilder.toString(object, style, outputTransients, false, null);
+    }
+
+    /**
+     * <p>Forwards to <code>ReflectionToStringBuilder</code>.</p>
+     *
+     * @param object  the Object to be output
+     * @param style  the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients  whether to include transient fields
+     * @param reflectUpToClass  the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @return the String result
+     * @see ReflectionToStringBuilder#toString(Object,ToStringStyle,boolean,boolean,Class)
+     * @since 2.0
+     */
+    public static String reflectionToString(
+        Object object,
+        ToStringStyle style,
+        boolean outputTransients,
+        Class reflectUpToClass) {
+        return ReflectionToStringBuilder.toString(object, style, outputTransients, false, reflectUpToClass);
+    }
+
+    /**
+     * <p>Sets the default <code>ToStringStyle</code> to use.</p>
+     *
+     * @param style  the default <code>ToStringStyle</code>
+     * @throws IllegalArgumentException if the style is <code>null</code>
+     */
+    public static void setDefaultStyle(ToStringStyle style) {
+        if (style == null) {
+            throw new IllegalArgumentException("The style must not be null");
+        }
+        defaultStyle = style;
+    }
+
+    /**
+     * Current toString buffer.
+     */
+    private final StringBuffer buffer;
+
+    /**
+     * The object being output.
+     */
+    private final Object object;
+
+    /**
+     * The style of output to use.
+     */
+    private final ToStringStyle style;
+
+    /**
+     * <p>Constructor for <code>ToStringBuilder</code>.</p>
+     *
+     * <p>This constructor outputs using the default style set with
+     * <code>setDefaultStyle</code>.</p>
+     *
+     * @param object  the Object to build a <code>toString</code> for
+     * @throws IllegalArgumentException  if the Object passed in is
+     *  <code>null</code>
+     */
+    public ToStringBuilder(Object object) {
+        this(object, getDefaultStyle(), null);
+    }
+
+    /**
+     * <p>Constructor for <code>ToStringBuilder</code> specifying the
+     * output style.</p>
+     *
+     * <p>If the style is <code>null</code>, the default style is used.</p>
+     *
+     * @param object  the Object to build a <code>toString</code> for
+     * @param style  the style of the <code>toString</code> to create,
+     *  may be <code>null</code>
+     * @throws IllegalArgumentException  if the Object passed in is
+     *  <code>null</code>
+     */
+    public ToStringBuilder(Object object, ToStringStyle style) {
+        this(object, style, null);
+    }
+
+    /**
+     * <p>Constructor for <code>ToStringBuilder</code>.</p>
+     *
+     * <p>If the style is <code>null</code>, the default style is used.</p>
+     *
+     * <p>If the buffer is <code>null</code>, a new one is created.</p>
+     *
+     * @param object  the Object to build a <code>toString</code> for
+     * @param style  the style of the <code>toString</code> to create,
+     *  may be <code>null</code>
+     * @param buffer  the <code>StringBuffer</code> to populate, may be
+     *  <code>null</code>
+     */
+    public ToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer) {
+        if (style == null) {
+            style = getDefaultStyle();
+        }
+        if (buffer == null) {
+            buffer = new StringBuffer(512);
+        }
+        this.buffer = buffer;
+        this.style = style;
+        this.object = object;
+
+        style.appendStart(buffer, object);
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>boolean</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(boolean value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>boolean</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(boolean[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>byte</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(byte value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>byte</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(byte[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>char</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(char value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>char</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(char[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>double</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(double value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>double</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(double[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>float</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(float value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>float</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(float[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>int</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(int value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>int</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(int[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>long</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(long value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>long</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(long[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>Object</code>
+     * value.</p>
+     *
+     * @param obj  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(Object obj) {
+        style.append(buffer, null, obj, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>Object</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(Object[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>short</code>
+     * value.</p>
+     *
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(short value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>short</code>
+     * array.</p>
+     *
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(short[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>boolean</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, boolean value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>boolean</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>hashCode</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, boolean[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>boolean</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, boolean[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>byte</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, byte value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>byte</code> array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, byte[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>byte</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, byte[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>char</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, char value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>char</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, char[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>char</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, char[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>double</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, double value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>double</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, double[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>double</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, double[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>float</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, float value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>float</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, float[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>float</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, float[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>int</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, int value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>int</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, int[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>int</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, int[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>long</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, long value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>long</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, long[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>long</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, long[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>Object</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param obj  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, Object obj) {
+        style.append(buffer, fieldName, obj, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>Object</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param obj  the value to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail,
+     *  <code>false</code> for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, Object obj, boolean fullDetail) {
+        style.append(buffer, fieldName, obj, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>Object</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, Object[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>Object</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, Object[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> an <code>short</code>
+     * value.</p>
+     *
+     * @param fieldName  the field name
+     * @param value  the value to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, short value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>short</code>
+     * array.</p>
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, short[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    /**
+     * <p>Append to the <code>toString</code> a <code>short</code>
+     * array.</p>
+     *
+     * <p>A boolean parameter controls the level of detail to show.
+     * Setting <code>true</code> will output the array in full. Setting
+     * <code>false</code> will output a summary, typically the size of
+     * the array.
+     *
+     * @param fieldName  the field name
+     * @param array  the array to add to the <code>toString</code>
+     * @param fullDetail  <code>true</code> for detail, <code>false</code>
+     *  for summary info
+     * @return this
+     */
+    public ToStringBuilder append(String fieldName, short[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    /**
+     * <p>Appends with the same format as the default <code>Object toString()
+     * </code> method. Appends the class name followed by
+     * {@link System#identityHashCode(java.lang.Object)}.</p>
+     *
+     * @param object  the <code>Object</code> whose class name and id to output
+     * @return this
+     * @since 2.0
+     */
+    public ToStringBuilder appendAsObjectToString(Object object) {
+        ObjectUtils_appendIdentityToString(this.getStringBuffer(), object);
+        return this;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Append the <code>toString</code> from the superclass.</p>
+     *
+     * <p>This method assumes that the superclass uses the same <code>ToStringStyle</code>
+     * as this one.</p>
+     *
+     * <p>If <code>superToString</code> is <code>null</code>, no change is made.</p>
+     *
+     * @param superToString  the result of <code>super.toString()</code>
+     * @return this
+     * @since 2.0
+     */
+    public ToStringBuilder appendSuper(String superToString) {
+        if (superToString != null) {
+            style.appendSuper(buffer, superToString);
+        }
+        return this;
+    }
+
+    /**
+     * <p>Append the <code>toString</code> from another object.</p>
+     *
+     * <p>This method is useful where a class delegates most of the implementation of
+     * its properties to another class. You can then call <code>toString()</code> on
+     * the other class and pass the result into this method.</p>
+     *
+     * <pre>
+     *   private AnotherObject delegate;
+     *   private String fieldInThisClass;
+     *
+     *   public String toString() {
+     *     return new ToStringBuilder(this).
+     *       appendToString(delegate.toString()).
+     *       append(fieldInThisClass).
+     *       toString();
+     *   }</pre>
+     *
+     * <p>This method assumes that the other object uses the same <code>ToStringStyle</code>
+     * as this one.</p>
+     *
+     * <p>If the <code>toString</code> is <code>null</code>, no change is made.</p>
+     *
+     * @param toString  the result of <code>toString()</code> on another object
+     * @return this
+     * @since 2.0
+     */
+    public ToStringBuilder appendToString(String toString) {
+        if (toString != null) {
+            style.appendToString(buffer, toString);
+        }
+        return this;
+    }
+
+    /**
+     * <p>Returns the <code>Object</code> being output.</p>
+     *
+     * @return The object being output.
+     * @since 2.0
+     */
+    public Object getObject() {
+        return object;
+    }
+
+    /**
+     * <p>Gets the <code>StringBuffer</code> being populated.</p>
+     *
+     * @return the <code>StringBuffer</code> being populated
+     */
+    public StringBuffer getStringBuffer() {
+        return buffer;
+    }
+
+    //----------------------------------------------------------------------------
+
+    /**
+     * <p>Gets the <code>ToStringStyle</code> being used.</p>
+     *
+     * @return the <code>ToStringStyle</code> being used
+     * @since 2.0
+     */
+    public ToStringStyle getStyle() {
+        return style;
+    }
+
+    /**
+     * <p>Returns the built <code>toString</code>.</p>
+     *
+     * <p>This method appends the end of data indicator, and can only be called once.
+     * Use {@link #getStringBuffer} to get the current string state.</p>
+     *
+     * <p>If the object is <code>null</code>, return the style's <code>nullText</code></p>
+     *
+     * @return the String <code>toString</code>
+     */
+    public String toString() {
+        if (this.getObject() == null) {
+            this.getStringBuffer().append(this.getStyle().getNullText());
+        } else {
+            style.appendEnd(this.getStringBuffer(), this.getObject());
+        }
+        return this.getStringBuffer().toString();
+    }
+
+    //
+    // NOTE: Unrolled from commons-lang bits
+    //
+
+    private static Boolean BooleanUtils_toBooleanObject(boolean bool) {
+        return bool ? Boolean.TRUE : Boolean.FALSE;
+    }
+    
+    private static StringBuffer ObjectUtils_appendIdentityToString(StringBuffer buffer, Object object) {
+        if (object == null) {
+            return null;
+        }
+        if (buffer == null) {
+            buffer = new StringBuffer();
+        }
+        return buffer
+            .append(object.getClass().getName())
+            .append('@')
+            .append(Integer.toHexString(System.identityHashCode(object)));
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/tostring/ToStringBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message