jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1464583 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
Date Thu, 04 Apr 2013 14:58:09 GMT
Author: thomasm
Date: Thu Apr  4 14:58:09 2013
New Revision: 1464583

URL: http://svn.apache.org/r1464583
Log:
OAK-741 Better toString() methods

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java?rev=1464583&r1=1464582&r2=1464583&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/kernel/KernelNodeState.java
Thu Apr  4 14:58:09 2013
@@ -64,8 +64,6 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 
-import static com.google.common.base.Preconditions.checkArgument;
-
 /**
  * Basic {@link NodeState} implementation based on the {@link MicroKernel}
  * interface. This class makes an attempt to load data lazily.
@@ -671,11 +669,11 @@ public final class KernelNodeState exten
                     String value = TypeCodes.decodeName(split, jsonString);
                     if (type == PropertyType.BINARY) {
                         values.add(new KernelBlob(new String(value), kernel));
-                    } else if(type == PropertyType.DOUBLE) {
+                    } else if (type == PropertyType.DOUBLE) {
                         values.add(Conversions.convert(value).toDouble());
-                    } else if(type == PropertyType.DECIMAL) {
+                    } else if (type == PropertyType.DECIMAL) {
                         values.add(Conversions.convert(value).toDecimal());
-                    } else if(type == PropertyType.DATE) {
+                    } else if (type == PropertyType.DATE) {
                         values.add(Conversions.convert(value).toCalendar().getTimeInMillis());
                     } else {
                         values.add(StringCache.get(value));
@@ -691,5 +689,44 @@ public final class KernelNodeState exten
         }
         return createProperty(name, values, Type.fromTag(type, true));
     }
+    
+    @Override
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        builder.append(path).append('@').append(revision);
+        if (childNodeCount >= 0) {
+            builder.append(" children: ").append(childNodeCount);
+        }
+        if (hash != null) {
+            builder.append(" hash: ").append(hash);
+        }
+        if (id != null) {
+            builder.append(" id: ").append(id);
+        }
+        builder.append(" {");
+        int count = 0;
+        if (properties == null) {
+            builder.append(" /* props not initialized */");
+        } else {
+            for (PropertyState property : getProperties()) {
+                if (count++ > 0) {
+                    builder.append(',');
+                }
+                builder.append(' ').append(property);
+            }
+        }
+        if (childNames == null) {
+            builder.append(" /* child node names not initialized */");
+        } else {
+            for (String s : childNames) {
+                if (count++ > 0) {
+                    builder.append(',');
+                }
+                builder.append(' ').append(s);
+            }
+        }
+        builder.append(" }");
+        return builder.toString();
+    }
 
 }



Mime
View raw message