geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r697518 - in /geronimo/gshell/trunk: gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/ gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/ gshell-support/gshell-ya...
Date Sun, 21 Sep 2008 13:56:19 GMT
Author: jdillon
Date: Sun Sep 21 06:56:19 2008
New Revision: 697518

URL: http://svn.apache.org/viewvc?rev=697518&view=rev
Log:
Use Yarn for everything
Nuke the lame docs for commons-lang bits included in Yarn, will refactor/remove that stuff soon

Added:
    geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ReflectionToStringBuilder.java
    geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringBuilder.java
    geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringStyle.java
Removed:
    geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/StandardToStringStyle.java
Modified:
    geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestHandle.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestManager.java
    geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/ResponseHandle.java
    geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/Yarn.java
    geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/YarnStyle.java

Modified: geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java?rev=697518&r1=697517&r2=697518&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/message/LoginMessage.java Sun Sep 21 06:56:19 2008
@@ -19,8 +19,8 @@
 
 package org.apache.geronimo.gshell.remote.message;
 
-import org.apache.geronimo.gshell.yarn.ReflectionToStringBuilder;
-import org.apache.geronimo.gshell.yarn.ToStringStyle;
+import org.apache.geronimo.gshell.yarn.Yarn;
+import org.apache.geronimo.gshell.yarn.YarnStyle;
 
 import java.io.Serializable;
 
@@ -35,6 +35,7 @@
 {
     private final String username;
 
+    @YarnStyle(omit=true)
     private final char[] password;
 
     private final String realm;
@@ -52,10 +53,9 @@
     }
 
     public String toString() {
-        return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
-                .setExcludeFieldNames(new String[] { "password" }).toString();
+        return Yarn.render(this);
     }
-    
+
     public String getUsername() {
         return username;
     }

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestHandle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestHandle.java?rev=697518&r1=697517&r2=697518&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestHandle.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestHandle.java Sun Sep 21 06:56:19 2008
@@ -19,19 +19,18 @@
 
 package org.apache.geronimo.gshell.whisper.request;
 
+import org.apache.geronimo.gshell.chronos.Duration;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.yarn.Yarn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.geronimo.gshell.chronos.Duration;
-import org.apache.geronimo.gshell.yarn.ToStringBuilder;
-import org.apache.geronimo.gshell.yarn.ToStringStyle;
-import org.apache.geronimo.gshell.whisper.message.Message;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Represents a request message.
  *
@@ -86,11 +85,7 @@
     }
 
     public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
-                .append("id", getId())
-                .append("signaled", signaled)
-                .append("message", message)
-                .toString();
+        return Yarn.render(this);
     }
 
     public Message getMessage() {

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestManager.java?rev=697518&r1=697517&r2=697518&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestManager.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/RequestManager.java Sun Sep 21 06:56:19 2008
@@ -19,6 +19,14 @@
 
 package org.apache.geronimo.gshell.whisper.request;
 
+import org.apache.geronimo.gshell.chronos.Duration;
+import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.whisper.util.NamedThreadFactory;
+import org.apache.geronimo.gshell.whisper.util.SessionAttributeBinder;
+import org.apache.geronimo.gshell.yarn.Yarn;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ScheduledExecutorService;
@@ -28,15 +36,6 @@
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.geronimo.gshell.chronos.Duration;
-import org.apache.geronimo.gshell.whisper.util.NamedThreadFactory;
-import org.apache.geronimo.gshell.yarn.ToStringBuilder;
-import org.apache.geronimo.gshell.yarn.ToStringStyle;
-import org.apache.geronimo.gshell.whisper.message.Message;
-import org.apache.geronimo.gshell.whisper.util.SessionAttributeBinder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * Manages request state on a per-session basis, handles timeouts and signalling responses.
  *
@@ -323,10 +322,7 @@
         }
 
         public String toString() {
-            return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
-                    .append("id", request.getId())
-                    .append("state", state)
-                    .toString();
+            return Yarn.render(this);
         }
     }
 

Modified: geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/ResponseHandle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/ResponseHandle.java?rev=697518&r1=697517&r2=697518&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/ResponseHandle.java (original)
+++ geronimo/gshell/trunk/gshell-remote/gshell-whisper/src/main/java/org/apache/geronimo/gshell/whisper/request/ResponseHandle.java Sun Sep 21 06:56:19 2008
@@ -19,9 +19,8 @@
 
 package org.apache.geronimo.gshell.whisper.request;
 
-import org.apache.geronimo.gshell.yarn.ToStringBuilder;
-import org.apache.geronimo.gshell.yarn.ToStringStyle;
 import org.apache.geronimo.gshell.whisper.message.Message;
+import org.apache.geronimo.gshell.yarn.Yarn;
 
 //
 // NOTE: Snatched and massaged from Apache Mina
@@ -67,11 +66,7 @@
     }
 
     public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
-                .append("id", getId())
-                .append("responseTo", getRequest().getId())
-                .append("message", message)
-                .toString();
+        return Yarn.render(this);
     }
 
     public RequestHandle getRequest() {

Added: geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ReflectionToStringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ReflectionToStringBuilder.java?rev=697518&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ReflectionToStringBuilder.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ReflectionToStringBuilder.java Sun Sep 21 06:56:19 2008
@@ -0,0 +1,250 @@
+/*
+ * 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.yarn;
+
+//
+// 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;
+
+/**
+ * Porting/adapting commons-land muck to GShell Yarn.
+ *
+ * @version $Id$
+ */
+class ReflectionToStringBuilder
+    extends ToStringBuilder
+{
+    public static String toString(Object object) {
+        return toString(object, null, false, false, null);
+    }
+
+    public static String toString(Object object, ToStringStyle style) {
+        return toString(object, style, false, false, null);
+    }
+
+    public static String toString(Object object, ToStringStyle style, boolean outputTransients) {
+        return toString(object, style, outputTransients, false, null);
+    }
+
+    public static String toString(Object object, ToStringStyle style, boolean outputTransients, boolean outputStatics) {
+        return toString(object, style, outputTransients, outputStatics, null);
+    }
+
+    public static String toString(Object object, ToStringStyle style, boolean outputTransients, boolean outputStatics,
+            Class reflectUpToClass) {
+        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics)
+                .toString();
+    }
+
+    public static String toStringExclude(Object object, final String excludeFieldName) {
+        return toStringExclude(object, new String[]{excludeFieldName});
+    }
+
+    public static String toStringExclude(Object object, Collection /*String*/ excludeFieldNames) {
+        return toStringExclude(object, toNoNullStringArray(excludeFieldNames));
+    }
+
+    static String[] toNoNullStringArray(Collection collection) {
+        if (collection == null) {
+            return ArrayUtils_EMPTY_STRING_ARRAY;
+        }
+        return toNoNullStringArray(collection.toArray());
+    }
+
+    static String[] toNoNullStringArray(Object[] array) {
+        ArrayList list = new ArrayList(array.length);
+        for (Object obj : array) {
+            if (obj != null) {
+                list.add(obj.toString());
+            }
+        }
+        return (String[]) list.toArray(ArrayUtils_EMPTY_STRING_ARRAY);
+    }
+
+    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;
+
+    public ReflectionToStringBuilder(Object object) {
+        super(object);
+    }
+
+    public ReflectionToStringBuilder(Object object, ToStringStyle style) {
+        super(object, style);
+    }
+
+    public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer) {
+        super(object, style, buffer);
+    }
+
+    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);
+    }
+
+    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;
+        }
+
+        return !(this.getExcludeFieldNames() != null
+                && Arrays.binarySearch(this.getExcludeFieldNames(), field.getName()) >= 0);
+    }
+
+    protected void appendFieldsIn(Class clazz) {
+        if (clazz.isArray()) {
+            this.reflectionAppendArray(this.getObject());
+            return;
+        }
+        Field[] fields = clazz.getDeclaredFields();
+        AccessibleObject.setAccessible(fields, true);
+
+        int i = 0;
+        while (i < fields.length) {
+            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());
+                }
+            }
+            i++;
+        }
+    }
+
+    /**
+     * @return Returns the excludeFieldNames.
+     */
+    public String[] getExcludeFieldNames() {
+        return this.excludeFieldNames;
+    }
+
+    public Class getUpToClass() {
+        return this.upToClass;
+    }
+
+    protected Object getValue(Field field) throws IllegalArgumentException, IllegalAccessException {
+        return field.get(this.getObject());
+    }
+
+    public boolean isAppendStatics() {
+        return this.appendStatics;
+    }
+
+    public boolean isAppendTransients() {
+        return this.appendTransients;
+    }
+
+    public ToStringBuilder reflectionAppendArray(Object array) {
+        this.getStyle().reflectionAppendArrayDetail(this.getStringBuffer(), null, array);
+        return this;
+    }
+
+    public void setAppendStatics(boolean appendStatics) {
+        this.appendStatics = appendStatics;
+    }
+
+    public void setAppendTransients(boolean appendTransients) {
+        this.appendTransients = appendTransients;
+    }
+
+    public ReflectionToStringBuilder setExcludeFieldNames(String[] excludeFieldNamesParam) {
+        if (excludeFieldNamesParam == null) {
+            this.excludeFieldNames = null;
+        } else {
+            this.excludeFieldNames = toNoNullStringArray(excludeFieldNamesParam);
+            Arrays.sort(this.excludeFieldNames);
+        }
+        return this;
+    }
+
+    public void setUpToClass(Class clazz) {
+        this.upToClass = clazz;
+    }
+
+    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

Added: geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringBuilder.java?rev=697518&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringBuilder.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringBuilder.java Sun Sep 21 06:56:19 2008
@@ -0,0 +1,390 @@
+/*
+ * 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.yarn;
+
+//
+// NOTE: Copied and massaged from commons-lang 2.3
+//
+
+/**
+ * Porting/adapting commons-land muck to GShell Yarn.
+ *
+ * @version $Id$
+ */
+class ToStringBuilder
+{
+    private static ToStringStyle defaultStyle = ToStringStyle.DEFAULT_STYLE;
+
+    public static ToStringStyle getDefaultStyle() {
+        return defaultStyle;
+    }
+
+    public static String reflectionToString(Object object) {
+        return ReflectionToStringBuilder.toString(object);
+    }
+
+    public static String reflectionToString(Object object, ToStringStyle style) {
+        return ReflectionToStringBuilder.toString(object, style);
+    }
+
+    public static String reflectionToString(Object object, ToStringStyle style, boolean outputTransients) {
+        return ReflectionToStringBuilder.toString(object, style, outputTransients, false, null);
+    }
+
+    public static String reflectionToString(
+        Object object,
+        ToStringStyle style,
+        boolean outputTransients,
+        Class reflectUpToClass) {
+        return ReflectionToStringBuilder.toString(object, style, outputTransients, false, reflectUpToClass);
+    }
+
+    public static void setDefaultStyle(ToStringStyle style) {
+        if (style == null) {
+            throw new IllegalArgumentException("The style must not be null");
+        }
+        defaultStyle = style;
+    }
+
+    private final StringBuffer buffer;
+
+    /**
+     * The object being output.
+     */
+    private final Object object;
+
+    /**
+     * The style of output to use.
+     */
+    private final ToStringStyle style;
+
+    public ToStringBuilder(Object object) {
+        this(object, getDefaultStyle(), null);
+    }
+
+    public ToStringBuilder(Object object, ToStringStyle style) {
+        this(object, style, null);
+    }
+
+    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);
+    }
+
+    public ToStringBuilder append(boolean value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(boolean[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(byte value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(byte[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(char value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(char[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(double value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(double[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(float value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(float[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(int value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(int[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(long value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(long[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(Object obj) {
+        style.append(buffer, null, obj, null);
+        return this;
+    }
+
+    public ToStringBuilder append(Object[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(short value) {
+        style.append(buffer, null, value);
+        return this;
+    }
+
+    public ToStringBuilder append(short[] array) {
+        style.append(buffer, null, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, boolean value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, boolean[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, boolean[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, byte value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, byte[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, byte[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, char value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, char[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, char[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, double value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, double[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, double[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, float value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, float[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, float[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, int value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, int[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, int[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, long value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, long[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, long[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, Object obj) {
+        style.append(buffer, fieldName, obj, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, Object obj, boolean fullDetail) {
+        style.append(buffer, fieldName, obj, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, Object[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, Object[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, short value) {
+        style.append(buffer, fieldName, value);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, short[] array) {
+        style.append(buffer, fieldName, array, null);
+        return this;
+    }
+
+    public ToStringBuilder append(String fieldName, short[] array, boolean fullDetail) {
+        style.append(buffer, fieldName, array, BooleanUtils_toBooleanObject(fullDetail));
+        return this;
+    }
+
+    public ToStringBuilder appendAsObjectToString(Object object) {
+        ObjectUtils_appendIdentityToString(this.getStringBuffer(), object);
+        return this;
+    }
+
+    public ToStringBuilder appendSuper(String superToString) {
+        if (superToString != null) {
+            style.appendSuper(buffer, superToString);
+        }
+        return this;
+    }
+
+    public ToStringBuilder appendToString(String toString) {
+        if (toString != null) {
+            style.appendToString(buffer, toString);
+        }
+        return this;
+    }
+
+    public Object getObject() {
+        return object;
+    }
+
+    public StringBuffer getStringBuffer() {
+        return buffer;
+    }
+
+    public ToStringStyle getStyle() {
+        return style;
+    }
+
+    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

Added: geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringStyle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringStyle.java?rev=697518&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringStyle.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/ToStringStyle.java Sun Sep 21 06:56:19 2008
@@ -0,0 +1,1089 @@
+/*
+ * 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.yarn;
+
+//
+// NOTE: Copied and massaged from commons-lang 2.3
+//
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Porting/adapting commons-land muck to GShell Yarn.
+ *
+ * @version $Id$
+ */
+abstract class ToStringStyle
+    implements Serializable
+{
+    /**
+     * The default toString style.
+     */
+    public static final ToStringStyle DEFAULT_STYLE = new DefaultToStringStyle();
+
+    /**
+     * The multi line toString style.
+     */
+    public static final ToStringStyle MULTI_LINE_STYLE = new MultiLineToStringStyle();
+
+    /**
+     * The no field names toString style.
+     */
+    public static final ToStringStyle NO_FIELD_NAMES_STYLE = new NoFieldNameToStringStyle();
+
+    /**
+     * The short prefix toString style.
+     * @since 2.1
+     */
+    public static final ToStringStyle SHORT_PREFIX_STYLE = new ShortPrefixToStringStyle();
+
+    /**
+     * The simple toString style.
+     */
+    public static final ToStringStyle SIMPLE_STYLE = new SimpleToStringStyle();
+
+    private static ThreadLocal registry = new ThreadLocal() {
+        protected Object initialValue() {
+            // The HashSet implementation is not synchronized,
+            // which is just what we need here.
+            return new HashSet();
+        }
+    };
+
+    static Set getRegistry() {
+        return (Set) registry.get();
+    }
+
+    static boolean isRegistered(Object value) {
+        return getRegistry().contains(value);
+    }
+
+    static void register(Object value) {
+        if (value != null) {
+            getRegistry().add(value);
+        }
+    }
+
+
+    static void unregister(Object value) {
+        getRegistry().remove(value);
+    }
+
+    private boolean useFieldNames = true;
+
+    private boolean useClassName = true;
+
+    private boolean useShortClassName = false;
+
+    private boolean useIdentityHashCode = true;
+
+    private String contentStart = "{ ";
+
+    private String contentEnd = " }";
+
+    private String fieldNameValueSeparator = "=";
+
+    private boolean fieldSeparatorAtStart = false;
+
+    private boolean fieldSeparatorAtEnd = false;
+
+    private String fieldSeparator = ", ";
+
+    private String arrayStart = "[ ";
+
+    private String arraySeparator = ", ";
+
+    private boolean arrayContentDetail = true;
+
+    private String arrayEnd = " ]";
+
+    private boolean defaultFullDetail = true;
+
+    private String nullText = "<null>";
+
+    private String sizeStartText = "<size=";
+
+    private String sizeEndText = ">";
+
+    private String summaryObjectStartText = "<";
+
+    private String summaryObjectEndText = ">";
+
+    protected ToStringStyle() {
+        super();
+    }
+
+    public void appendSuper(StringBuffer buffer, String superToString) {
+        appendToString(buffer, superToString);
+    }
+
+    public void appendToString(StringBuffer buffer, String toString) {
+        if (toString != null) {
+            int pos1 = toString.indexOf(contentStart) + contentStart.length();
+            int pos2 = toString.lastIndexOf(contentEnd);
+            if (pos1 != pos2 && pos1 >= 0 && pos2 >= 0) {
+                String data = toString.substring(pos1, pos2);
+                if (fieldSeparatorAtStart) {
+                    removeLastFieldSeparator(buffer);
+                }
+                buffer.append(data);
+                appendFieldSeparator(buffer);
+            }
+        }
+    }
+
+    public void appendStart(StringBuffer buffer, Object object) {
+        if (object != null) {
+            appendClassName(buffer, object);
+            appendIdentityHashCode(buffer, object);
+            appendContentStart(buffer);
+            if (fieldSeparatorAtStart) {
+                appendFieldSeparator(buffer);
+            }
+        }
+    }
+
+    public void appendEnd(StringBuffer buffer, Object object) {
+        if (this.fieldSeparatorAtEnd == false) {
+            removeLastFieldSeparator(buffer);
+        }
+        appendContentEnd(buffer);
+        unregister(object);
+    }
+
+    protected void removeLastFieldSeparator(StringBuffer buffer) {
+        int len = buffer.length();
+        int sepLen = fieldSeparator.length();
+        if (len > 0 && sepLen > 0 && len >= sepLen) {
+            boolean match = true;
+            for (int i = 0; i < sepLen; i++) {
+                if (buffer.charAt(len - 1 - i) != fieldSeparator.charAt(sepLen - 1 - i)) {
+                    match = false;
+                    break;
+                }
+            }
+            if (match) {
+                buffer.setLength(len - sepLen);
+            }
+        }
+    }
+
+    public void append(StringBuffer buffer, String fieldName, Object value, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (value == null) {
+            appendNullText(buffer, fieldName);
+
+        } else {
+            appendInternal(buffer, fieldName, value, isFullDetail(fullDetail));
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendInternal(StringBuffer buffer, String fieldName, Object value, boolean detail) {
+        if (isRegistered(value)
+            && !(value instanceof Number || value instanceof Boolean || value instanceof Character)) {
+           appendCyclicObject(buffer, fieldName, value);
+           return;
+        }
+
+        register(value);
+
+        try {
+            if (value instanceof Collection) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (Collection) value);
+                } else {
+                    appendSummarySize(buffer, fieldName, ((Collection) value).size());
+                }
+
+            } else if (value instanceof Map) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (Map) value);
+                } else {
+                    appendSummarySize(buffer, fieldName, ((Map) value).size());
+                }
+
+            } else if (value instanceof long[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (long[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (long[]) value);
+                }
+
+            } else if (value instanceof int[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (int[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (int[]) value);
+                }
+
+            } else if (value instanceof short[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (short[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (short[]) value);
+                }
+
+            } else if (value instanceof byte[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (byte[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (byte[]) value);
+                }
+
+            } else if (value instanceof char[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (char[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (char[]) value);
+                }
+
+            } else if (value instanceof double[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (double[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (double[]) value);
+                }
+
+            } else if (value instanceof float[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (float[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (float[]) value);
+                }
+
+            } else if (value instanceof boolean[]) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (boolean[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (boolean[]) value);
+                }
+
+            } else if (value.getClass().isArray()) {
+                if (detail) {
+                    appendDetail(buffer, fieldName, (Object[]) value);
+                } else {
+                    appendSummary(buffer, fieldName, (Object[]) value);
+                }
+
+            } else {
+                    if (detail) {
+                        appendDetail(buffer, fieldName, value);
+                    } else {
+                        appendSummary(buffer, fieldName, value);
+                    }
+            }
+        } finally {
+            unregister(value);
+        }
+    }
+
+    protected void appendCyclicObject(StringBuffer buffer, String fieldName, Object value) {
+       ObjectUtils_appendIdentityToString(buffer, value);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, Object value) {
+        buffer.append(value);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, Collection coll) {
+        buffer.append(coll);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, Map map) {
+        buffer.append(map);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, Object value) {
+        buffer.append(summaryObjectStartText);
+        buffer.append(getShortClassName(value.getClass()));
+        buffer.append(summaryObjectEndText);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, long value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, long value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, int value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, int value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, short value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, short value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, byte value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, byte value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, char value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, char value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, double value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, double value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, float value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, float value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, boolean value) {
+        appendFieldStart(buffer, fieldName);
+        appendDetail(buffer, fieldName, value);
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, boolean value) {
+        buffer.append(value);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, Object[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, Object[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            Object item = array[i];
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            if (item == null) {
+                appendNullText(buffer, fieldName);
+
+            } else {
+                appendInternal(buffer, fieldName, item, arrayContentDetail);
+            }
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void reflectionAppendArrayDetail(StringBuffer buffer, String fieldName, Object array) {
+        buffer.append(arrayStart);
+        int length = Array.getLength(array);
+        for (int i = 0; i < length; i++) {
+            Object item = Array.get(array, i);
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            if (item == null) {
+                appendNullText(buffer, fieldName);
+
+            } else {
+                appendInternal(buffer, fieldName, item, arrayContentDetail);
+            }
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, Object[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, long[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, long[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, long[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, int[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, int[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, int[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, short[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, short[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, short[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, byte[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, byte[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, byte[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, char[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, char[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, char[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, double[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, double[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, double[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, float[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, float[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, float[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    public void append(StringBuffer buffer, String fieldName, boolean[] array, Boolean fullDetail) {
+        appendFieldStart(buffer, fieldName);
+
+        if (array == null) {
+            appendNullText(buffer, fieldName);
+
+        } else if (isFullDetail(fullDetail)) {
+            appendDetail(buffer, fieldName, array);
+
+        } else {
+            appendSummary(buffer, fieldName, array);
+        }
+
+        appendFieldEnd(buffer, fieldName);
+    }
+
+    protected void appendDetail(StringBuffer buffer, String fieldName, boolean[] array) {
+        buffer.append(arrayStart);
+        for (int i = 0; i < array.length; i++) {
+            if (i > 0) {
+                buffer.append(arraySeparator);
+            }
+            appendDetail(buffer, fieldName, array[i]);
+        }
+        buffer.append(arrayEnd);
+    }
+
+    protected void appendSummary(StringBuffer buffer, String fieldName, boolean[] array) {
+        appendSummarySize(buffer, fieldName, array.length);
+    }
+
+    protected void appendClassName(StringBuffer buffer, Object object) {
+        if (useClassName && object != null) {
+            register(object);
+            if (useShortClassName) {
+                buffer.append(getShortClassName(object.getClass()));
+            } else {
+                buffer.append(object.getClass().getName());
+            }
+        }
+    }
+
+    protected void appendIdentityHashCode(StringBuffer buffer, Object object) {
+        if (this.isUseIdentityHashCode() && object!=null) {
+            register(object);
+            buffer.append('@');
+            buffer.append(Integer.toHexString(System.identityHashCode(object)));
+        }
+    }
+
+    protected void appendContentStart(StringBuffer buffer) {
+        buffer.append(contentStart);
+    }
+
+    protected void appendContentEnd(StringBuffer buffer) {
+        buffer.append(contentEnd);
+    }
+
+    protected void appendNullText(StringBuffer buffer, String fieldName) {
+        buffer.append(nullText);
+    }
+
+    protected void appendFieldSeparator(StringBuffer buffer) {
+        buffer.append(fieldSeparator);
+    }
+
+    protected void appendFieldStart(StringBuffer buffer, String fieldName) {
+        if (useFieldNames && fieldName != null) {
+            buffer.append(fieldName);
+            buffer.append(fieldNameValueSeparator);
+        }
+    }
+
+    protected void appendFieldEnd(StringBuffer buffer, String fieldName) {
+        appendFieldSeparator(buffer);
+    }
+
+    protected void appendSummarySize(StringBuffer buffer, String fieldName, int size) {
+        buffer.append(sizeStartText);
+        buffer.append(size);
+        buffer.append(sizeEndText);
+    }
+
+    protected boolean isFullDetail(Boolean fullDetailRequest) {
+        if (fullDetailRequest == null) {
+            return defaultFullDetail;
+        }
+        return fullDetailRequest;
+    }
+
+    protected String getShortClassName(Class cls) {
+        return cls.getSimpleName();
+    }
+
+    protected boolean isUseClassName() {
+        return useClassName;
+    }
+
+    protected void setUseClassName(boolean useClassName) {
+        this.useClassName = useClassName;
+    }
+
+    protected boolean isUseShortClassName() {
+        return useShortClassName;
+    }
+
+    protected boolean isShortClassName() {
+        return useShortClassName;
+    }
+
+    protected void setUseShortClassName(boolean useShortClassName) {
+        this.useShortClassName = useShortClassName;
+    }
+
+    protected void setShortClassName(boolean shortClassName) {
+        this.useShortClassName = shortClassName;
+    }
+
+    protected boolean isUseIdentityHashCode() {
+        return useIdentityHashCode;
+    }
+
+    protected void setUseIdentityHashCode(boolean useIdentityHashCode) {
+        this.useIdentityHashCode = useIdentityHashCode;
+    }
+
+    protected boolean isUseFieldNames() {
+        return useFieldNames;
+    }
+
+    protected void setUseFieldNames(boolean useFieldNames) {
+        this.useFieldNames = useFieldNames;
+    }
+
+    protected boolean isDefaultFullDetail() {
+        return defaultFullDetail;
+    }
+
+    protected void setDefaultFullDetail(boolean defaultFullDetail) {
+        this.defaultFullDetail = defaultFullDetail;
+    }
+
+    protected boolean isArrayContentDetail() {
+        return arrayContentDetail;
+    }
+
+    protected void setArrayContentDetail(boolean arrayContentDetail) {
+        this.arrayContentDetail = arrayContentDetail;
+    }
+
+    protected String getArrayStart() {
+        return arrayStart;
+    }
+
+    protected void setArrayStart(String arrayStart) {
+        if (arrayStart == null) {
+            arrayStart = "";
+        }
+        this.arrayStart = arrayStart;
+    }
+
+    protected String getArrayEnd() {
+        return arrayEnd;
+    }
+
+    protected void setArrayEnd(String arrayEnd) {
+        if (arrayEnd == null) {
+            arrayEnd = "";
+        }
+        this.arrayEnd = arrayEnd;
+    }
+
+    protected String getArraySeparator() {
+        return arraySeparator;
+    }
+
+    protected void setArraySeparator(String arraySeparator) {
+        if (arraySeparator == null) {
+            arraySeparator = "";
+        }
+        this.arraySeparator = arraySeparator;
+    }
+
+    protected String getContentStart() {
+        return contentStart;
+    }
+
+    protected void setContentStart(String contentStart) {
+        if (contentStart == null) {
+            contentStart = "";
+        }
+        this.contentStart = contentStart;
+    }
+
+    protected String getContentEnd() {
+        return contentEnd;
+    }
+
+    protected void setContentEnd(String contentEnd) {
+        if (contentEnd == null) {
+            contentEnd = "";
+        }
+        this.contentEnd = contentEnd;
+    }
+
+    protected String getFieldNameValueSeparator() {
+        return fieldNameValueSeparator;
+    }
+
+    protected void setFieldNameValueSeparator(String fieldNameValueSeparator) {
+        if (fieldNameValueSeparator == null) {
+            fieldNameValueSeparator = "";
+        }
+        this.fieldNameValueSeparator = fieldNameValueSeparator;
+    }
+
+    protected String getFieldSeparator() {
+        return fieldSeparator;
+    }
+
+    protected void setFieldSeparator(String fieldSeparator) {
+        if (fieldSeparator == null) {
+            fieldSeparator = "";
+        }
+        this.fieldSeparator = fieldSeparator;
+    }
+
+    protected boolean isFieldSeparatorAtStart() {
+        return fieldSeparatorAtStart;
+    }
+
+    protected void setFieldSeparatorAtStart(boolean fieldSeparatorAtStart) {
+        this.fieldSeparatorAtStart = fieldSeparatorAtStart;
+    }
+
+    protected boolean isFieldSeparatorAtEnd() {
+        return fieldSeparatorAtEnd;
+    }
+
+    protected void setFieldSeparatorAtEnd(boolean fieldSeparatorAtEnd) {
+        this.fieldSeparatorAtEnd = fieldSeparatorAtEnd;
+    }
+
+    protected String getNullText() {
+        return nullText;
+    }
+
+    protected void setNullText(String nullText) {
+        if (nullText == null) {
+            nullText = "";
+        }
+        this.nullText = nullText;
+    }
+
+    protected String getSizeStartText() {
+        return sizeStartText;
+    }
+
+    protected void setSizeStartText(String sizeStartText) {
+        if (sizeStartText == null) {
+            sizeStartText = "";
+        }
+        this.sizeStartText = sizeStartText;
+    }
+
+    protected String getSizeEndText() {
+        return sizeEndText;
+    }
+
+    protected void setSizeEndText(String sizeEndText) {
+        if (sizeEndText == null) {
+            sizeEndText = "";
+        }
+        this.sizeEndText = sizeEndText;
+    }
+
+    protected String getSummaryObjectStartText() {
+        return summaryObjectStartText;
+    }
+
+    protected void setSummaryObjectStartText(String summaryObjectStartText) {
+        if (summaryObjectStartText == null) {
+            summaryObjectStartText = "";
+        }
+        this.summaryObjectStartText = summaryObjectStartText;
+    }
+
+    protected String getSummaryObjectEndText() {
+        return summaryObjectEndText;
+    }
+
+    protected void setSummaryObjectEndText(String summaryObjectEndText) {
+        if (summaryObjectEndText == null) {
+            summaryObjectEndText = "";
+        }
+        this.summaryObjectEndText = summaryObjectEndText;
+    }
+
+    private static final class DefaultToStringStyle extends ToStringStyle {
+
+        /**
+         * Required for serialization support.
+         *
+         * @see java.io.Serializable
+         */
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * <p>Constructor.</p>
+         *
+         * <p>Use the static constant rather than instantiating.</p>
+         */
+        DefaultToStringStyle() {
+            super();
+        }
+
+        /**
+         * <p>Ensure <code>Singleton</code> after serialization.</p>
+         *
+         * @return the singleton
+         */
+        private Object readResolve() {
+            return ToStringStyle.DEFAULT_STYLE;
+        }
+
+    }
+
+    private static final class NoFieldNameToStringStyle extends ToStringStyle {
+
+        private static final long serialVersionUID = 1L;
+
+        NoFieldNameToStringStyle() {
+            super();
+            this.setUseFieldNames(false);
+        }
+
+        private Object readResolve() {
+            return ToStringStyle.NO_FIELD_NAMES_STYLE;
+        }
+    }
+
+    private static final class ShortPrefixToStringStyle extends ToStringStyle {
+
+        private static final long serialVersionUID = 1L;
+
+        ShortPrefixToStringStyle() {
+            super();
+            this.setUseShortClassName(true);
+            this.setUseIdentityHashCode(false);
+        }
+
+        private Object readResolve() {
+            return ToStringStyle.SHORT_PREFIX_STYLE;
+        }
+    }
+
+    private static final class SimpleToStringStyle extends ToStringStyle {
+
+        private static final long serialVersionUID = 1L;
+
+        SimpleToStringStyle() {
+            super();
+            this.setUseClassName(false);
+            this.setUseIdentityHashCode(false);
+            this.setUseFieldNames(false);
+            this.setContentStart("");
+            this.setContentEnd("");
+        }
+        private Object readResolve() {
+            return ToStringStyle.SIMPLE_STYLE;
+        }
+
+    }
+
+    private static final class MultiLineToStringStyle extends ToStringStyle {
+
+        private static final long serialVersionUID = 1L;
+
+        MultiLineToStringStyle() {
+            super();
+            this.setContentStart("[");
+            this.setFieldSeparator(SystemUtils_LINE_SEPARATOR + "  ");
+            this.setFieldSeparatorAtStart(true);
+            this.setContentEnd(SystemUtils_LINE_SEPARATOR + "]");
+        }
+
+        private Object readResolve() {
+            return ToStringStyle.MULTI_LINE_STYLE;
+        }
+    }
+
+    //
+    // NOTE: Unrolled from commons-lang bits
+    //
+
+    private static final String SystemUtils_LINE_SEPARATOR = System.getProperty("line.separator");
+
+    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

Modified: geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/Yarn.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/Yarn.java?rev=697518&r1=697517&r2=697518&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/Yarn.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/Yarn.java Sun Sep 21 06:56:19 2008
@@ -27,6 +27,10 @@
 public class Yarn
 {
     public static String render(final Object target) {
+        //
+        // TODO: Implement YarnRenderer and cache for type
+        //
+
         return ReflectionToStringBuilder.toString(target, ToStringStyle.SHORT_PREFIX_STYLE);
     }
 }
\ No newline at end of file

Modified: geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/YarnStyle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/YarnStyle.java?rev=697518&r1=697517&r2=697518&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/YarnStyle.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-yarn/src/main/java/org/apache/geronimo/gshell/yarn/YarnStyle.java Sun Sep 21 06:56:19 2008
@@ -34,4 +34,10 @@
 public @interface YarnStyle
 {
     YarnStyles value() default YarnStyles.DEFAULT;
+
+    boolean omit() default false;
+
+    boolean include() default true;
+
+    // Renderer
 }



Mime
View raw message