directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1418305 - in /directory/shared/trunk: integ/src/test/java/org/apache/directory/shared/ldap/entry/ ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/
Date Fri, 07 Dec 2012 13:30:11 GMT
Author: elecharny
Date: Fri Dec  7 13:30:08 2012
New Revision: 1418305

URL: http://svn.apache.org/viewvc?rev=1418305&view=rev
Log:
Added the toString( String tabs ) methods which pretty-print 

Modified:
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareAttributeTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Attribute.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java
    directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareAttributeTest.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareAttributeTest.java
(original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareAttributeTest.java
Fri Dec  7 13:30:08 2012
@@ -1506,17 +1506,17 @@ public class SchemaAwareAttributeTest
     {
         Attribute attr = new DefaultAttribute( atEMail );
 
-        assertEquals( "    email: (null)\n", attr.toString() );
+        assertEquals( "email: (null)\n", attr.toString() );
 
         attr.setUpId( "EMail" );
-        assertEquals( "    EMail: (null)\n", attr.toString() );
+        assertEquals( "EMail: (null)\n", attr.toString() );
 
         attr.add( ( String ) null );
-        assertEquals( "    EMail: ''\n", attr.toString() );
+        assertEquals( "EMail: ''\n", attr.toString() );
 
         attr.clear();
         attr.add( "a", "b" );
-        assertEquals( "    EMail: a\n    EMail: b\n", attr.toString() );
+        assertEquals( "EMail: a\nEMail: b\n", attr.toString() );
     }
 
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Attribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Attribute.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Attribute.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Attribute.java
Fri Dec  7 13:30:08 2012
@@ -421,4 +421,13 @@ public interface Attribute extends Itera
      * @throws LdapInvalidAttributeValueException if there is a failure to check syntaxes
of values
      */
     boolean isValid( AttributeType attributeType ) throws LdapInvalidAttributeValueException;
+    
+    
+    /**
+     * A pretty-pinter for Attribute
+     * 
+     * @param tabs The tabs to add before any output
+     * @return The pretty-printed entry
+     */
+    String toString( String tabs );
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java
Fri Dec  7 13:30:08 2012
@@ -1954,40 +1954,6 @@ public class DefaultAttribute implements
 
 
     /**
-     * @see Object#toString()
-     */
-    public String toString()
-    {
-        StringBuilder sb = new StringBuilder();
-
-        if ( ( values != null ) && ( values.size() != 0 ) )
-        {
-            for ( Value<?> value : values )
-            {
-                sb.append( "    " ).append( upId ).append( ": " );
-
-                if ( value.isNull() )
-                {
-                    sb.append( "''" );
-                }
-                else
-                {
-                    sb.append( value );
-                }
-
-                sb.append( '\n' );
-            }
-        }
-        else
-        {
-            sb.append( "    " ).append( upId ).append( ": (null)\n" );
-        }
-
-        return sb.toString();
-    }
-
-
-    /**
      * This is the place where we serialize attributes, and all theirs
      * elements.
      * 
@@ -2067,4 +2033,47 @@ public class DefaultAttribute implements
             }
         }
     }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return toString( "" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        if ( ( values != null ) && ( values.size() != 0 ) )
+        {
+            for ( Value<?> value : values )
+            {
+                sb.append( tabs ).append( upId ).append( ": " );
+
+                if ( value.isNull() )
+                {
+                    sb.append( "''" );
+                }
+                else
+                {
+                    sb.append( value );
+                }
+
+                sb.append( '\n' );
+            }
+        }
+        else
+        {
+            sb.append( tabs ).append( upId ).append( ": (null)\n" );
+        }
+
+        return sb.toString();
+    }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
Fri Dec  7 13:30:08 2012
@@ -2550,10 +2550,19 @@ public final class DefaultEntry implemen
      */
     public String toString()
     {
+        return toString( "" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString( String tabs )
+    {
         StringBuilder sb = new StringBuilder();
 
-        sb.append( "Entry\n" );
-        sb.append( "    dn" );
+        sb.append( tabs ).append( "Entry\n" );
+        sb.append( tabs ).append( "    dn" );
 
         if ( dn.isSchemaAware() )
         {
@@ -2572,7 +2581,7 @@ public final class DefaultEntry implemen
             {
                 Attribute objectClass = get( objectClassAttributeType );
 
-                sb.append( objectClass );
+                sb.append( objectClass.toString( tabs + "    " ) );
             }
         }
         else
@@ -2581,7 +2590,7 @@ public final class DefaultEntry implemen
             {
                 Attribute objectClass = get( "objectclass" );
 
-                sb.append( objectClass );
+                sb.append( objectClass.toString( tabs + "    " ) );
             }
         }
 
@@ -2597,7 +2606,7 @@ public final class DefaultEntry implemen
 
                     if ( !attributeType.equals( objectClassAttributeType ) )
                     {
-                        sb.append( attribute );
+                        sb.append( attribute.toString( tabs + "    " ) );
                         continue;
                     }
                 }
@@ -2606,7 +2615,7 @@ public final class DefaultEntry implemen
                     if ( !id.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT )
                         && !id.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
                     {
-                        sb.append( attribute );
+                        sb.append( attribute.toString( tabs + "    " ) );
                         continue;
                     }
                 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java
Fri Dec  7 13:30:08 2012
@@ -832,4 +832,13 @@ public interface Entry extends Cloneable
      * @return true if the Entry is schema aware
      */
     boolean isSchemaAware();
+    
+    
+    /**
+     * A pretty-pinter for Entries
+     * 
+     * @param tabs The tabs to add before any output
+     * @return The pretty-printed entry
+     */
+    String toString( String tabs );
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java
Fri Dec  7 13:30:08 2012
@@ -734,4 +734,13 @@ public class ImmutableEntry implements E
     {
         return entry.toString();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String toString( String tabs )
+    {
+        return entry.toString( tabs );
+    }
 }

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java?rev=1418305&r1=1418304&r2=1418305&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java
(original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultAttributeTest.java
Fri Dec  7 13:30:08 2012
@@ -1285,21 +1285,21 @@ public class DefaultAttributeTest
     {
         Attribute attr1 = new DefaultAttribute( "test" );
 
-        assertEquals( "    test: (null)\n", attr1.toString() );
+        assertEquals( "test: (null)\n", attr1.toString() );
 
         attr1.add( "a" );
-        assertEquals( "    test: a\n", attr1.toString() );
+        assertEquals( "test: a\n", attr1.toString() );
 
         attr1.add( "b" );
-        assertEquals( "    test: a\n    test: b\n", attr1.toString() );
+        assertEquals( "test: a\ntest: b\n", attr1.toString() );
 
         Attribute attr2 = new DefaultAttribute( "test" );
 
         attr2.add( BYTES1 );
-        assertEquals( "    test: '0x61 0x62 '\n", attr2.toString() );
+        assertEquals( "test: '0x61 0x62 '\n", attr2.toString() );
 
         attr2.add( BYTES3 );
-        assertEquals( "    test: '0x61 0x62 '\n    test: '0x63 '\n", attr2.toString() );
+        assertEquals( "test: '0x61 0x62 '\ntest: '0x63 '\n", attr2.toString() );
     }
 
 



Mime
View raw message