directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r471657 - /directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Date Mon, 06 Nov 2006 07:29:42 GMT
Author: elecharny
Date: Sun Nov  5 23:29:41 2006
New Revision: 471657

URL: http://svn.apache.org/viewvc?view=rev&rev=471657
Log:
Used generic

Modified:
    directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java

Modified: directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java?view=diff&rev=471657&r1=471656&r2=471657
==============================================================================
--- directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
(original)
+++ directory/branches/apacheds-schema/shared/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
Sun Nov  5 23:29:41 2006
@@ -48,6 +48,7 @@
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.name.LdapDnParser;
+import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.util.Base64;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -148,7 +149,7 @@
  *  single space before the continued value.
  * </pre>
  */
-public class LdifReader implements Iterator
+public class LdifReader implements Iterator<Entry>
 {
     /** A logger */
     private static final Logger log = LoggerFactory.getLogger( LdifReader.class );
@@ -175,7 +176,7 @@
     }
 
     /** A list of read lines */
-    private List lines;
+    private List<String> lines;
 
     /** The current position */
     private Position position;
@@ -229,7 +230,7 @@
      */
     public LdifReader()
     {
-        lines = new ArrayList();
+        lines = new ArrayList<String>();
         position = new Position();
         version = DEFAULT_VERSION;
     }
@@ -237,7 +238,7 @@
     private void init( BufferedReader in ) throws NamingException
     {
         this.in = in;
-        lines = new ArrayList();
+        lines = new ArrayList<String>();
         position = new Position();
         version = DEFAULT_VERSION;
         containsChanges = false;
@@ -527,7 +528,7 @@
         // Check that the DN is valid. If not, an exception will be thrown
         try
         {
-            LdapDnParser.parseInternal( dn, new ArrayList() );
+            LdapDnParser.parseInternal( dn, new ArrayList<Rdn>() );
         }
         catch (InvalidNameException ine)
         {
@@ -865,13 +866,13 @@
      * @throws NamingException
      *             If anything goes wrong
      */
-    private void parseModRdn( Entry entry, Iterator iter ) throws NamingException
+    private void parseModRdn( Entry entry, Iterator<String> iter ) throws NamingException
     {
         // We must have two lines : one starting with "newrdn:" or "newrdn::",
         // and the second starting with "deleteoldrdn:"
         if ( iter.hasNext() )
         {
-            String line = (String) iter.next();
+            String line = iter.next();
             String lowerLine = line.toLowerCase();
 
             if ( lowerLine.startsWith( "newrdn::" ) || lowerLine.startsWith( "newrdn:" )
)
@@ -936,7 +937,7 @@
      * @param iter
      *            The lines
      */
-    private void parseModify( Entry entry, Iterator iter ) throws NamingException
+    private void parseModify( Entry entry, Iterator<String> iter ) throws NamingException
     {
         int state = MOD_SPEC;
         String modified = null;
@@ -947,7 +948,7 @@
 
         while ( iter.hasNext() )
         {
-            String line = (String) iter.next();
+            String line = iter.next();
             String lowerLine = line.toLowerCase();
 
             if ( lowerLine.startsWith( "-" ) )
@@ -1077,7 +1078,7 @@
      *            The associated control, if any
      * @return A modification entry
      */
-    private void parseChange( Entry entry, Iterator iter, int operation, Control control
) throws NamingException
+    private void parseChange( Entry entry, Iterator<String> iter, int operation, Control
control ) throws NamingException
     {
         // The changetype and operation has already been parsed.
         entry.setChangeType( operation );
@@ -1093,7 +1094,7 @@
                 // We will iterate through all attribute/value pairs
                 while ( iter.hasNext() )
                 {
-                    String line = (String) iter.next();
+                    String line = iter.next();
                     String lowerLine = line.toLowerCase();
                     parseAttributeValue( entry, line, lowerLine );
                 }
@@ -1112,7 +1113,7 @@
                 // The next line should be the new superior
                 if ( iter.hasNext() )
                 {
-                    String line = (String) iter.next();
+                    String line = iter.next();
                     String lowerLine = line.toLowerCase();
 
                     if ( lowerLine.startsWith( "newsuperior:" ) )
@@ -1168,7 +1169,7 @@
         }
 
         // The entry must start with a dn: or a dn::
-        String line = ( (String) lines.get( 0 ) );
+        String line = lines.get( 0 );
 
         String dn = parseDn( line );
 
@@ -1180,7 +1181,7 @@
         lines.remove( 0 );
 
         // Now, let's iterate through the other lines
-        Iterator iter = lines.iterator();
+        Iterator<String> iter = lines.iterator();
 
         // This flag is used to distinguish between an entry and a change
         int type = UNKNOWN;
@@ -1201,7 +1202,7 @@
         {
             // Each line could start either with an OID, an attribute type, with
             // "control:" or with "changetype:"
-            line = (String) iter.next();
+            line = iter.next();
             lowerLine = line.toLowerCase();
 
             // We have three cases :
@@ -1473,7 +1474,7 @@
      * @throws NamingException
      *             If the parsing fails
      */
-    public List parseLdifFile( String fileName ) throws NamingException
+    public List<Entry> parseLdifFile( String fileName ) throws NamingException
     {
         return parseLdifFile( fileName, Charset.forName( StringTools.getDefaultCharsetName()
).toString() );
     }
@@ -1489,7 +1490,7 @@
      * @throws NamingException
      *             If the parsing fails
      */
-    public List parseLdifFile( String fileName, String encoding ) throws NamingException
+    public List<Entry> parseLdifFile( String fileName, String encoding ) throws NamingException
     {
         if ( StringTools.isEmpty( fileName ) )
         {
@@ -1530,13 +1531,13 @@
      * @throws NamingException
      *             If something went wrong
      */
-    public List parseLdif( String ldif ) throws NamingException
+    public List<Entry> parseLdif( String ldif ) throws NamingException
     {
         log.debug( "Starts parsing ldif buffer" );
 
         if ( StringTools.isEmpty( ldif ) )
         {
-            return new ArrayList();
+            return new ArrayList<Entry>();
         }
 
         StringReader strIn = new StringReader( ldif );
@@ -1544,7 +1545,7 @@
 
         try
         {
-            List entries = parseLdif( in );
+            List<Entry> entries = parseLdif( in );
 
             if ( log.isDebugEnabled() )
             {
@@ -1569,7 +1570,7 @@
      * 
      * @return the next LDIF as a String.
      */
-    public Object next()
+    public Entry next()
     {
         try
         {
@@ -1624,11 +1625,11 @@
     /**
      * @return An iterator on the file
      */
-    public Iterator iterator()
+    public Iterator<Entry> iterator()
     {
         return this;
     }
-
+    
     /**
      * @return True if an error occured during parsing
      */
@@ -1655,10 +1656,10 @@
      * @throws NamingException
      *             If something went wrong
      */
-    public List parseLdif( BufferedReader in ) throws NamingException
+    public List<Entry> parseLdif( BufferedReader in ) throws NamingException
     {
         // Create a list that will contain the read entries
-        List entries = new ArrayList();
+        List<Entry> entries = new ArrayList<Entry>();
 
         this.in = in;
 
@@ -1669,7 +1670,7 @@
         // When done, get the entries one by one.
         while ( hasNext() )
         {
-            Entry entry = (Entry) next();
+            Entry entry = next();
 
             if ( error != null )
             {



Mime
View raw message