directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1621899 - /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Date Mon, 01 Sep 2014 23:47:10 GMT
Author: elecharny
Date: Mon Sep  1 23:47:10 2014
New Revision: 1621899

URL: http://svn.apache.org/r1621899
Log:
Made the LdifReader class Schema aware

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1621899&r1=1621898&r2=1621899&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Mon Sep  1 23:47:10 2014
@@ -51,6 +51,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Base64;
 import org.apache.directory.api.util.Chars;
 import org.apache.directory.api.util.Strings;
@@ -217,6 +218,9 @@ public class LdifReader implements Itera
 
     /** A flag set if the ldif contains changes */
     protected boolean containsChanges;
+    
+    /** The SchemaManager instance, if any */
+    protected SchemaManager schemaManager;
 
     /**
      * An Exception to handle error message, has Iterator.next() can't throw
@@ -249,6 +253,18 @@ public class LdifReader implements Itera
         version = DEFAULT_VERSION;
     }
 
+    
+    /**
+     * Constructors
+     */
+    public LdifReader( SchemaManager schemaManager )
+    {
+        lines = new ArrayList<String>();
+        position = 0;
+        version = DEFAULT_VERSION;
+        this.schemaManager = schemaManager;
+    }
+
 
     /**
      * Store the reader and intialize the LdifReader
@@ -1323,10 +1339,10 @@ public class LdifReader implements Itera
 
         String name = parseDn( line );
 
-        Dn dn = new Dn( name );
+        Dn dn = new Dn( schemaManager, name );
 
         // Ok, we have found a Dn
-        LdifEntry entry = createLdifEntry();
+        LdifEntry entry = createLdifEntry( schemaManager );
         entry.setLengthBeforeParsing( entryLen );
         entry.setOffset( entryOffset );
 
@@ -1833,6 +1849,17 @@ public class LdifReader implements Itera
 
 
     /**
+     * Gets the current entry, but don't move forward.
+     *
+     * @return the pre-fetched entry 
+     */
+    public LdifEntry fetch()
+    {
+        return prefetched;
+    }
+
+
+    /**
      * Tests to see if another LDIF is on the input channel.
      *
      * @return true if another LDIF is available false otherwise.
@@ -1991,9 +2018,16 @@ public class LdifReader implements Itera
      * creates a non-schemaaware LdifEntry
      * @return an LdifEntry that is not schemaaware
      */
-    protected LdifEntry createLdifEntry()
+    protected LdifEntry createLdifEntry( SchemaManager schemaManager )
     {
-        return new LdifEntry();
+        if ( schemaManager != null )
+        {
+            return new LdifEntry( schemaManager );
+        }
+        else
+        {
+            return new LdifEntry();
+        }
     }
     
     /**
@@ -2017,6 +2051,15 @@ public class LdifReader implements Itera
 
 
     /**
+     * @param schemaManager the schemaManager to set
+     */
+    public void setSchemaManager( SchemaManager schemaManager )
+    {
+        this.schemaManager = schemaManager;
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     public void close() throws IOException



Mime
View raw message