You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2016/05/17 11:48:13 UTC
svn commit: r1744254 -
/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Author: elecharny
Date: Tue May 17 11:48:13 2016
New Revision: 1744254
URL: http://svn.apache.org/viewvc?rev=1744254&view=rev
Log:
Some warning removals
Modified:
directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
Modified: directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java?rev=1744254&r1=1744253&r2=1744254&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java (original)
+++ directory/shared/branches/shared-value/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifReader.java Tue May 17 11:48:13 2016
@@ -256,7 +256,7 @@ public class LdifReader implements Itera
*/
public LdifReader()
{
- lines = new ArrayList<String>();
+ lines = new ArrayList<>();
position = 0;
version = DEFAULT_VERSION;
}
@@ -267,39 +267,10 @@ public class LdifReader implements Itera
*/
public LdifReader( SchemaManager schemaManager )
{
- lines = new ArrayList<String>();
- position = 0;
- version = DEFAULT_VERSION;
- this.schemaManager = schemaManager;
- }
-
-
- /**
- * Store the reader and intialize the LdifReader
- */
- private void initReader( BufferedReader reader ) throws LdapException
- {
- this.reader = reader;
- init();
- }
-
-
- /**
- * Initialize the LdifReader
- *
- * @throws LdapException If the initialization failed
- */
- public void init() throws LdapException
- {
lines = new ArrayList<>();
position = 0;
version = DEFAULT_VERSION;
- containsChanges = false;
- containsEntries = false;
-
- // First get the version - if any -
- version = parseVersion();
- prefetched = parseEntry();
+ this.schemaManager = schemaManager;
}
@@ -399,6 +370,35 @@ public class LdifReader implements Itera
/**
+ * Store the reader and intialize the LdifReader
+ */
+ private void initReader( BufferedReader reader ) throws LdapException
+ {
+ this.reader = reader;
+ init();
+ }
+
+
+ /**
+ * Initialize the LdifReader
+ *
+ * @throws LdapException If the initialization failed
+ */
+ public void init() throws LdapException
+ {
+ lines = new ArrayList<>();
+ position = 0;
+ version = DEFAULT_VERSION;
+ containsChanges = false;
+ containsEntries = false;
+
+ // First get the version - if any -
+ version = parseVersion();
+ prefetched = parseEntry();
+ }
+
+
+ /**
* @return The ldif file version
*/
public int getVersion()
@@ -1108,8 +1108,7 @@ public class LdifReader implements Itera
* <pre>
* <changerecord> ::= "changetype:" FILL "modify" SEP <mod-spec> <mod-specs-e>
* <mod-spec> ::= "add:" <mod-val> | "delete:" <mod-val-del> | "replace:" <mod-val>
- * <mod-specs-e> ::= <mod-spec>
- * <mod-specs-e> | e
+ * <mod-specs-e> ::= <mod-spec> | e
* <mod-val> ::= FILL ATTRIBUTE-DESCRIPTION SEP ATTRVAL-SPEC <attrval-specs-e> "-" SEP
* <mod-val-del> ::= FILL ATTRIBUTE-DESCRIPTION SEP <attrval-specs-e> "-" SEP
* <attrval-specs-e> ::= ATTRVAL-SPEC <attrval-specs> | e
@@ -1398,7 +1397,7 @@ public class LdifReader implements Itera
*/
protected LdifEntry parseEntry() throws LdapException
{
- if ( ( lines == null ) || ( lines.size() == 0 ) )
+ if ( ( lines == null ) || lines.isEmpty() )
{
LOG.debug( "The entry is empty : end of ldif file" );
return null;
@@ -1588,7 +1587,7 @@ public class LdifReader implements Itera
// First, read a list of lines
readLines();
- if ( lines.size() == 0 )
+ if ( lines.isEmpty() )
{
LOG.warn( "The ldif file is empty" );
return ver;
@@ -1632,7 +1631,7 @@ public class LdifReader implements Itera
lines.remove( 0 );
// and read the next lines if the current buffer is empty
- if ( lines.size() == 0 )
+ if ( lines.isEmpty() )
{
// include the version line as part of the first entry
int tmpEntryLen = entryLen;
@@ -1681,7 +1680,7 @@ public class LdifReader implements Itera
entryLen = 0;
entryOffset = offset;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
try
{
@@ -1741,7 +1740,7 @@ public class LdifReader implements Itera
lines.add( sb.toString() );
}
- sb = new StringBuffer( line );
+ sb = new StringBuilder( line );
insideComment = false;
break;
}
@@ -1852,7 +1851,7 @@ public class LdifReader implements Itera
if ( Strings.isEmpty( ldif ) )
{
- return new ArrayList<LdifEntry>();
+ return new ArrayList<>();
}
BufferedReader bufferReader = new BufferedReader( new StringReader( ldif ) );
@@ -2015,16 +2014,19 @@ public class LdifReader implements Itera
/**
* @return An iterator on the file
*/
+ @Override
public Iterator<LdifEntry> iterator()
{
return new Iterator<LdifEntry>()
{
+ @Override
public boolean hasNext()
{
return hasNextInternal();
}
+ @Override
public LdifEntry next()
{
try
@@ -2039,6 +2041,7 @@ public class LdifReader implements Itera
}
+ @Override
public void remove()
{
throw new UnsupportedOperationException();
@@ -2076,7 +2079,7 @@ public class LdifReader implements Itera
public List<LdifEntry> parseLdif( BufferedReader reader ) throws LdapException
{
// Create a list that will contain the read entries
- List<LdifEntry> entries = new ArrayList<LdifEntry>();
+ List<LdifEntry> entries = new ArrayList<>();
this.reader = reader;
@@ -2168,6 +2171,7 @@ public class LdifReader implements Itera
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
if ( reader != null )