directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r998325 - /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Date Fri, 17 Sep 2010 21:09:07 GMT
Author: kayyagari
Date: Fri Sep 17 21:09:07 2010
New Revision: 998325

URL: http://svn.apache.org/viewvc?rev=998325&view=rev
Log:
o made changes to ease extendability
o changes include 
   a. adding a new method getLine()
   b. renamed init(Reader) method to initReader() and added a new init() method with protected
scope

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

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?rev=998325&r1=998324&r2=998325&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Fri Sep 17 21:09:07 2010
@@ -236,9 +236,14 @@ public class LdifReader implements Itera
     }
 
 
-    private void init( BufferedReader reader ) throws LdapException
+    private void initReader( BufferedReader reader ) throws LdapException
     {
         this.reader = reader;
+        init();
+    }
+
+    protected void init() throws LdapException
+    {
         lines = new ArrayList<String>();
         position = 0;
         version = DEFAULT_VERSION;
@@ -250,7 +255,6 @@ public class LdifReader implements Itera
         prefetched = parseEntry();
     }
 
-
     /**
      * A constructor which takes a file name
      * 
@@ -277,7 +281,7 @@ public class LdifReader implements Itera
 
         try
         {
-            init( new BufferedReader( new FileReader( file ) ) );
+            initReader( new BufferedReader( new FileReader( file ) ) );
         }
         catch ( FileNotFoundException fnfe )
         {
@@ -304,7 +308,7 @@ public class LdifReader implements Itera
      */
     public LdifReader( Reader in ) throws LdapException
     {
-        init( new BufferedReader( in ) );
+        initReader( new BufferedReader( in ) );
     }
 
 
@@ -316,7 +320,7 @@ public class LdifReader implements Itera
      */
     public LdifReader( InputStream in ) throws LdapException
     {
-        init( new BufferedReader( new InputStreamReader( in ) ) );
+        initReader( new BufferedReader( new InputStreamReader( in ) ) );
     }
 
 
@@ -344,7 +348,7 @@ public class LdifReader implements Itera
 
         try
         {
-            init( new BufferedReader( new FileReader( file ) ) );
+            initReader( new BufferedReader( new FileReader( file ) ) );
         }
         catch ( FileNotFoundException fnfe )
         {
@@ -1445,6 +1449,18 @@ public class LdifReader implements Itera
 
 
     /**
+     * gets a line from the underlying data store
+     * 
+     * @return a line of characters or null if EOF reached
+     * @throws IOException
+     */
+    protected String getLine() throws IOException
+    {
+        return ( ( BufferedReader ) reader ).readLine();
+    }
+    
+    
+    /**
      * Reads an entry in a ldif buffer, and returns the resulting lines, without
      * comments, and unfolded.
      * 
@@ -1463,7 +1479,7 @@ public class LdifReader implements Itera
 
         try
         {
-            while ( ( line = ( ( BufferedReader ) reader ).readLine() ) != null )
+            while ( ( line = getLine() ) != null )
             {
                 if ( line.length() == 0 )
                 {



Mime
View raw message