jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1032651 - in /jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi: ./ nodetype/ util/
Date Mon, 08 Nov 2010 17:53:58 GMT
Author: jukka
Date: Mon Nov  8 17:53:58 2010
New Revision: 1032651

URL: http://svn.apache.org/viewvc?rev=1032651&view=rev
Log:
JCR-2763: Drop the Dumpable interface

Replace the Dumpable interface with toString() methods also in jcr2spi.

This time I made sure to avoid the "..." + this + "..." -trap in toString()...

Removed:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/util/Dumpable.java
Modified:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java?rev=1032651&r1=1032650&r2=1032651&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemCacheImpl.java
Mon Nov  8 17:53:58 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi;
 
-import java.io.PrintStream;
 import java.util.Map;
 
 import javax.jcr.Item;
@@ -24,14 +23,13 @@ import javax.jcr.RepositoryException;
 
 import org.apache.commons.collections.map.LRUMap;
 import org.apache.jackrabbit.jcr2spi.state.ItemState;
-import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * <code>ItemCacheImpl</code>...
  */
-public class ItemCacheImpl implements ItemCache, Dumpable {
+public class ItemCacheImpl implements ItemCache {
 
     private static Logger log = LoggerFactory.getLogger(ItemCacheImpl.class);
 
@@ -137,25 +135,27 @@ public class ItemCacheImpl implements It
         cache.remove(itemState);
     }
 
-    //-----------------------------------------------------------< Dumpable >---
+    //--------------------------------------------------------==---< Object >---
+
     /**
-     * @see Dumpable#dump(PrintStream)
+     * Returns the the state of this instance in a human readable format.
      */
-    public void dump(PrintStream ps) {
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
         for (Map.Entry<ItemState, Item> entry : cache.entrySet()) {
             ItemState state = entry.getKey();
             Item item = entry.getValue();
             if (item.isNode()) {
-                ps.print("Node: ");
+                builder.append("Node: ");
             } else {
-                ps.print("Property: ");
+                builder.append("Property: ");
             }
             if (item.isNew()) {
-                ps.print("new ");
+                builder.append("new ");
             } else if (item.isModified()) {
-                ps.print("modified ");
+                builder.append("modified ");
             } else {
-                ps.print("- ");
+                builder.append("- ");
             }
             String path;
             try {
@@ -163,7 +163,8 @@ public class ItemCacheImpl implements It
             } catch (RepositoryException e) {
                 path = "-";
             }
-            ps.println(state + "\t" + path + " (" + item + ")");
+            builder.append(state + "\t" + path + " (" + item + ")\n");
         }
+        return builder.toString();
     }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java?rev=1032651&r1=1032650&r2=1032651&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/ItemManagerImpl.java
Mon Nov  8 17:53:58 2010
@@ -25,7 +25,6 @@ import org.apache.jackrabbit.jcr2spi.sta
 import org.apache.jackrabbit.jcr2spi.state.NodeState;
 import org.apache.jackrabbit.jcr2spi.state.PropertyState;
 import org.apache.jackrabbit.jcr2spi.state.Status;
-import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.jcr2spi.util.LogUtil;
 import org.apache.jackrabbit.jcr2spi.version.VersionHistoryImpl;
 import org.apache.jackrabbit.jcr2spi.version.VersionImpl;
@@ -44,13 +43,12 @@ import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Workspace;
-import java.io.PrintStream;
 import java.util.Iterator;
 
 /**
  * <code>ItemManagerImpl</code> implements the <code>ItemManager</code>
interface.
  */
-public class ItemManagerImpl implements Dumpable, ItemManager, ItemStateCreationListener
{
+public class ItemManagerImpl implements ItemManager, ItemStateCreationListener {
 
     private static Logger log = LoggerFactory.getLogger(ItemManagerImpl.class);
 
@@ -287,20 +285,17 @@ public class ItemManagerImpl implements 
         return new LazyItemIterator(this, propEntries);
     }
 
-    //-----------------------------------------------------------< Dumpable >---
+    //-------------------------------------------------------------< Object >---
+
     /**
-     * @see Dumpable#dump(PrintStream)
+     * Returns the the state of this instance in a human readable format.
      */
-    public void dump(PrintStream ps) {
-        ps.println("ItemManager (" + this + ")");
-        ps.println();
-        ps.println("Items in cache:");
-        ps.println();
-        if (itemCache instanceof Dumpable) {
-            ((Dumpable) itemCache).dump(ps);
-        } else {
-            ps.println("ItemCache (" + itemCache.toString() + ")");
-        }
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("ItemManager (" + super.toString() + ")\n");
+        builder.append("Items in cache:\n");
+        builder.append(itemCache);
+        return builder.toString();
     }
 
     //----------------------------------------------------< private methods >---

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java?rev=1032651&r1=1032650&r2=1032651&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/BitsetENTCacheImpl.java
Mon Nov  8 17:53:58 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.TreeSet;
@@ -227,19 +226,20 @@ class BitsetENTCacheImpl implements Effe
         return clone;
     }
 
-    //-----------------------------------------------------------< Dumpable >---
+    //-------------------------------------------------------------< Object >---
+
     /**
-     * @see org.apache.jackrabbit.jcr2spi.util.Dumpable#dump(PrintStream)
+     * Returns the the state of this instance in a human readable format.
      */
-    public void dump(PrintStream ps) {
-        ps.println("EffectiveNodeTypeCache (" + this + ")");
-        ps.println();
-        ps.println("EffectiveNodeTypes in cache:");
-        ps.println();
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("EffectiveNodeTypeCache (" + super.toString() + ")\n");
+        builder.append("EffectiveNodeTypes in cache:\n");
         for (Key k : sortedKeys) {
-            //EffectiveNodeType ent = (EffectiveNodeType) aggregates.get(k);
-            ps.println(k);
+            builder.append(k);
+            builder.append('\n');
         }
+        return builder.toString();
     }
 
     //----------------------------------------------------------------< Key >---

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java?rev=1032651&r1=1032650&r2=1032651&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/EffectiveNodeTypeCache.java
Mon Nov  8 17:53:58 2010
@@ -17,13 +17,12 @@
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
 import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 
 /**
  * <code>EffectiveNodeTypeCache</code> defines the interface for a cache for
  * effective node types. Effective node types are addressed by {@link Key}s.
  */
-public interface EffectiveNodeTypeCache extends Cloneable, Dumpable {
+public interface EffectiveNodeTypeCache extends Cloneable {
 
     /**
      * Puts an effective node type to the cache. The key is internally generated

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java?rev=1032651&r1=1032650&r2=1032651&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeManagerImpl.java
Mon Nov  8 17:53:58 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -41,7 +40,6 @@ import javax.jcr.version.OnParentVersion
 import org.apache.commons.collections.map.ReferenceMap;
 import org.apache.jackrabbit.commons.iterator.NodeTypeIteratorAdapter;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
-import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
@@ -59,7 +57,7 @@ import org.slf4j.LoggerFactory;
  * A <code>NodeTypeManagerImpl</code> implements a session dependant
  * NodeTypeManager.
  */
-public class NodeTypeManagerImpl extends AbstractNodeTypeManager implements NodeTypeDefinitionProvider,
NodeTypeRegistryListener, Dumpable {
+public class NodeTypeManagerImpl extends AbstractNodeTypeManager implements NodeTypeDefinitionProvider,
NodeTypeRegistryListener {
 
     /**
      * Logger instance for this class
@@ -405,33 +403,33 @@ public class NodeTypeManagerImpl extends
         getNodeTypeRegistry().unregisterNodeTypes(ntNames);
     }
 
-    //-----------------------------------------------------------< Dumpable >---
+    //-------------------------------------------------------------< Object >---
+
     /**
-     * {@inheritDoc}
+     * Returns the the state of this instance in a human readable format.
      */
-    public void dump(PrintStream ps) {
-        ps.println("NodeTypeManager (" + this + ")");
-        ps.println();
-        ps.println("All NodeTypes:");
-        ps.println();
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("NodeTypeManager (" + super.toString() + ")\n");
+        builder.append("All NodeTypes:\n");
         try {
             NodeTypeIterator iter = this.getAllNodeTypes();
             while (iter.hasNext()) {
                 NodeType nt = iter.nextNodeType();
-                ps.println(nt.getName());
-                ps.println("\tSupertypes");
+                builder.append(nt.getName());
+                builder.append("\n\tSupertypes");
                 for (NodeType supertype : nt.getSupertypes()) {
-                    ps.println("\t\t" + supertype.getName());
+                    builder.append("\n\t\t" + supertype.getName());
                 }
-                ps.println("\tMixin\t" + nt.isMixin());
-                ps.println("\tOrderableChildNodes\t" + nt.hasOrderableChildNodes());
-                ps.println("\tPrimaryItemName\t" + (nt.getPrimaryItemName() == null ? "<null>"
: nt.getPrimaryItemName()));
+                builder.append("\n\tMixin\t" + nt.isMixin());
+                builder.append("\n\tOrderableChildNodes\t" + nt.hasOrderableChildNodes());
+                builder.append("\n\tPrimaryItemName\t" + (nt.getPrimaryItemName() == null
? "<null>" : nt.getPrimaryItemName()));
                 for (PropertyDefinition aPd : nt.getPropertyDefinitions()) {
-                    ps.print("\tPropertyDefinition");
-                    ps.println(" (declared in " + aPd.getDeclaringNodeType().getName() +
") ");
-                    ps.println("\t\tName\t\t" + (aPd.getName()));
+                    builder.append("\n\tPropertyDefinition");
+                    builder.append(" (declared in " + aPd.getDeclaringNodeType().getName()
+ ") ");
+                    builder.append("\n\t\tName\t\t" + (aPd.getName()));
                     String type = aPd.getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(aPd.getRequiredType());
-                    ps.println("\t\tRequiredType\t" + type);
+                    builder.append("\n\t\tRequiredType\t" + type);
                     String[] vca = aPd.getValueConstraints();
                     StringBuffer constraints = new StringBuffer();
                     if (vca == null) {
@@ -444,7 +442,7 @@ public class NodeTypeManagerImpl extends
                             constraints.append(aVca);
                         }
                     }
-                    ps.println("\t\tValueConstraints\t" + constraints.toString());
+                    builder.append("\n\t\tValueConstraints\t" + constraints.toString());
                     Value[] defVals = aPd.getDefaultValues();
                     StringBuffer defaultValues = new StringBuffer();
                     if (defVals == null) {
@@ -457,37 +455,37 @@ public class NodeTypeManagerImpl extends
                             defaultValues.append(defVal.getString());
                         }
                     }
-                    ps.println("\t\tDefaultValue\t" + defaultValues.toString());
-                    ps.println("\t\tAutoCreated\t" + aPd.isAutoCreated());
-                    ps.println("\t\tMandatory\t" + aPd.isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aPd.getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + aPd.isProtected());
-                    ps.println("\t\tMultiple\t" + aPd.isMultiple());
+                    builder.append("\n\t\tDefaultValue\t" + defaultValues.toString());
+                    builder.append("\n\t\tAutoCreated\t" + aPd.isAutoCreated());
+                    builder.append("\n\t\tMandatory\t" + aPd.isMandatory());
+                    builder.append("\n\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aPd.getOnParentVersion()));
+                    builder.append("\n\t\tProtected\t" + aPd.isProtected());
+                    builder.append("\n\t\tMultiple\t" + aPd.isMultiple());
                 }
                 for (NodeDefinition aNd : nt.getChildNodeDefinitions()) {
-                    ps.print("\tNodeDefinition");
-                    ps.println(" (declared in " + aNd.getDeclaringNodeType() + ") ");
-                    ps.println("\t\tName\t\t" + aNd.getName());
+                    builder.append("\n\tNodeDefinition");
+                    builder.append(" (declared in " + aNd.getDeclaringNodeType() + ") ");
+                    builder.append("\n\t\tName\t\t" + aNd.getName());
                     NodeType[] reqPrimaryTypes = aNd.getRequiredPrimaryTypes();
                     if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0)
{
                         for (NodeType reqPrimaryType : reqPrimaryTypes) {
-                            ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryType.getName());
+                            builder.append("\n\t\tRequiredPrimaryType\t" + reqPrimaryType.getName());
                         }
                     }
                     NodeType defPrimaryType = aNd.getDefaultPrimaryType();
                     if (defPrimaryType != null) {
-                        ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType.getName());
+                        builder.append("\n\t\tDefaultPrimaryType\t" + defPrimaryType.getName());
                     }
-                    ps.println("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
-                    ps.println("\t\tMandatory\t" + aNd.isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + aNd.isProtected());
-                    ps.println("\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
+                    builder.append("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
+                    builder.append("\n\t\tMandatory\t" + aNd.isMandatory());
+                    builder.append("\n\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
+                    builder.append("\n\t\tProtected\t" + aNd.isProtected());
+                    builder.append("\n\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
                 }
             }
-            ps.println();
         } catch (RepositoryException e) {
-            e.printStackTrace(ps);
+            builder.append(e.getMessage());
         }
+        return builder.toString();
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=1032651&r1=1032650&r2=1032651&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
Mon Nov  8 17:53:58 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.jackrabbit.jcr2spi.nodetype;
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -39,7 +38,6 @@ import javax.jcr.nodetype.NodeTypeExists
 import javax.jcr.version.OnParentVersionAction;
 
 import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.jackrabbit.jcr2spi.util.Dumpable;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.QItemDefinition;
 import org.apache.jackrabbit.spi.QNodeDefinition;
@@ -54,7 +52,7 @@ import org.slf4j.LoggerFactory;
 /**
  * A <code>NodeTypeRegistry</code> ...
  */
-public class NodeTypeRegistryImpl implements Dumpable, NodeTypeRegistry, EffectiveNodeTypeProvider
{
+public class NodeTypeRegistryImpl implements NodeTypeRegistry, EffectiveNodeTypeProvider
{
 
     private static Logger log = LoggerFactory.getLogger(NodeTypeRegistryImpl.class);
 
@@ -639,19 +637,19 @@ public class NodeTypeRegistryImpl implem
         }
     }
 
-    //-----------------------------------------------------------< Dumpable >---
+    //-------------------------------------------------------------< Object >---
+
     /**
-     * {@inheritDoc}
+     * Returns the the state of this instance in a human readable format.
      */
-    public void dump(PrintStream ps) {
-        ps.println("NodeTypeRegistry (" + this + ")");
-        ps.println();
-        ps.println("Known NodeTypes:");
-        ps.println();
-        registeredNTDefs.dump(ps);
-        ps.println();
-
-        entCache.dump(ps);
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append("NodeTypeRegistry (" + this + ")\n");
+        builder.append("Known NodeTypes:\n");
+        builder.append(registeredNTDefs);
+        builder.append("\n");
+        builder.append(entCache);
+        return builder.toString();
     }
 
     //--------------------------------------------------------< inner class >---
@@ -659,7 +657,7 @@ public class NodeTypeRegistryImpl implem
      * Inner class representing the map of <code>QNodeTypeDefinition</code>s
      * that have been loaded yet.
      */
-    private class NodeTypeDefinitionMap implements Map<Name, QNodeTypeDefinition>,
Dumpable {
+    private class NodeTypeDefinitionMap implements Map<Name, QNodeTypeDefinition> {
 
         // map of node type names and node type definitions
         private final ConcurrentHashMap<Name, QNodeTypeDefinition> nodetypeDefinitions
=
@@ -791,39 +789,45 @@ public class NodeTypeRegistryImpl implem
             return nodetypeDefinitions.remove(key);
         }
 
-        //-------------------------------------------------------< Dumpable >---
-        public void dump(PrintStream ps) {
+        //---------------------------------------------------------< Object >---
+
+        /**
+         * Returns the the state of this instance in a human readable format.
+         */
+        public String toString() {
+            StringBuilder builder = new StringBuilder();
             for (QNodeTypeDefinition ntd : getValues()) {
-                ps.println(ntd.getName());
+                builder.append(ntd.getName());
                 Name[] supertypes = ntd.getSupertypes();
-                ps.println("\tSupertypes");
+                builder.append("\n\tSupertypes");
                 for (int i = 0; i < supertypes.length; i++) {
-                    ps.println("\t\t" + supertypes[i]);
+                    builder.append("\n\t\t" + supertypes[i]);
                 }
-                ps.println("\tMixin\t" + ntd.isMixin());
-                ps.println("\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
-                ps.println("\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null ? "<null>"
: ntd.getPrimaryItemName().toString()));
-                QPropertyDefinition[] pd = ntd.getPropertyDefs();
-                for (int i = 0; i < pd.length; i++) {
-                    ps.print("\tPropertyDefinition");
-                    ps.println(" (declared in " + pd[i].getDeclaringNodeType() + ") ");
-                    ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getName().toString()));
-                    String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
-                    ps.println("\t\tRequiredType\t" + type);
-                    QValueConstraint[] vca = pd[i].getValueConstraints();
-                    StringBuffer constraints = new StringBuffer();
+                builder.append("\n\tMixin\t" + ntd.isMixin());
+                builder.append("\n\tOrderableChildNodes\t" + ntd.hasOrderableChildNodes());
+                builder.append("\n\tPrimaryItemName\t" + (ntd.getPrimaryItemName() == null
? "<null>" : ntd.getPrimaryItemName().toString()));
+                for (QPropertyDefinition pd : ntd.getPropertyDefs()) {
+                    builder.append("\n\tPropertyDefinition");
+                    builder.append(" (declared in " + pd.getDeclaringNodeType() + ") ");
+                    builder.append("\n\t\tName\t\t" + (pd.definesResidual() ? "*" : pd.getName().toString()));
+                    String type = "null";
+                        if (pd.getRequiredType() != 0) {
+                            type = PropertyType.nameFromValue(pd.getRequiredType());
+                        }
+                    builder.append("\n\t\tRequiredType\t" + type);
+                    builder.append("\n\t\tValueConstraints\t");
+                    QValueConstraint[] vca = pd.getValueConstraints();
                     if (vca == null) {
-                        constraints.append("<null>");
+                        builder.append("<null>");
                     } else {
                         for (int n = 0; n < vca.length; n++) {
-                            if (constraints.length() > 0) {
-                                constraints.append(", ");
+                            if (n > 0) {
+                                builder.append(", ");
                             }
-                            constraints.append(vca[n].getString());
+                            builder.append(vca[n].getString());
                         }
                     }
-                    ps.println("\t\tValueConstraints\t" + constraints.toString());
-                    QValue[] defVals = pd[i].getDefaultValues();
+                    QValue[] defVals = pd.getDefaultValues();
                     StringBuffer defaultValues = new StringBuffer();
                     if (defVals == null) {
                         defaultValues.append("<null>");
@@ -839,35 +843,38 @@ public class NodeTypeRegistryImpl implem
                             }
                         }
                     }
-                    ps.println("\t\tDefaultValue\t" + defaultValues.toString());
-                    ps.println("\t\tAutoCreated\t" + pd[i].isAutoCreated());
-                    ps.println("\t\tMandatory\t" + pd[i].isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(pd[i].getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + pd[i].isProtected());
-                    ps.println("\t\tMultiple\t" + pd[i].isMultiple());
+                    builder.append("\n\t\tDefaultValue\t" + defaultValues.toString());
+                    builder.append("\n\t\tAutoCreated\t" + pd.isAutoCreated());
+                    builder.append("\n\t\tMandatory\t" + pd.isMandatory());
+                    builder.append("\n\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(pd.getOnParentVersion()));
+                    builder.append("\n\t\tProtected\t" + pd.isProtected());
+                    builder.append("\n\t\tMultiple\t" + pd.isMultiple());
                 }
                 QNodeDefinition[] nd = ntd.getChildNodeDefs();
                 for (QNodeDefinition aNd : nd) {
-                    ps.print("\tNodeDefinition");
-                    ps.println(" (declared in " + aNd.getDeclaringNodeType() + ") ");
-                    ps.println("\t\tName\t\t" + (aNd.definesResidual() ? "*" : aNd.getName().toString()));
+                    builder.append("\n\tNodeDefinition");
+                    builder.append(" (declared in " + aNd.getDeclaringNodeType() + ") ");
+                    builder.append("\n\t\tName\t\t" + (aNd.definesResidual() ? "*" : aNd.getName().toString()));
                     Name[] reqPrimaryTypes = aNd.getRequiredPrimaryTypes();
                     if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0)
{
                         for (int n = 0; n < reqPrimaryTypes.length; n++) {
-                            ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryTypes[n]);
+                            builder.append("\n\t\tRequiredPrimaryType\t" + reqPrimaryTypes[n]);
                         }
                     }
                     Name defPrimaryType = aNd.getDefaultPrimaryType();
                     if (defPrimaryType != null) {
-                        ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType);
+                        builder.append("\n\t\tDefaultPrimaryType\t" + defPrimaryType);
                     }
-                    ps.println("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
-                    ps.println("\t\tMandatory\t" + aNd.isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + aNd.isProtected());
-                    ps.println("\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
+                    builder.append("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
+                    builder.append("\n\t\tMandatory\t" + aNd.isMandatory());
+                    builder.append("\n\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
+                    builder.append("\n\t\tProtected\t" + aNd.isProtected());
+                    builder.append("\n\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
                 }
             }
+            return builder.toString();
         }
+
     }
+
 }



Mime
View raw message