directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1089107 - in /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model: entry/Attribute.java entry/DefaultAttribute.java entry/DefaultEntry.java name/Rdn.java
Date Tue, 05 Apr 2011 16:15:16 GMT
Author: elecharny
Date: Tue Apr  5 16:15:15 2011
New Revision: 1089107

URL: http://svn.apache.org/viewvc?rev=1089107&view=rev
Log:
Fixed some Sonar warnings

Modified:
    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/name/Rdn.java

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=1089107&r1=1089106&r2=1089107&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
Tue Apr  5 16:15:15 2011
@@ -30,7 +30,7 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public interface Attribute extends Iterable<Value<?>>, Cloneable, Externalizable
+public interface Attribute extends Iterable<Value<?>>, Externalizable
 {
     /**
      * Adds some values to this attribute. If the new values are already present in

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=1089107&r1=1089106&r2=1089107&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
Tue Apr  5 16:15:15 2011
@@ -47,7 +47,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class DefaultAttribute implements Attribute
+public class DefaultAttribute implements Attribute, Cloneable
 {
     /** logger for reporting errors that might not be handled properly upstream */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultAttribute.class );
@@ -494,15 +494,12 @@ public class DefaultAttribute implements
         }
         else
         {
-            if ( isHR )
+            if ( isHR && ( value != null ) )
             {
                 // Try to convert the value from a byte[] to a String
-                if ( value != null )
-                {
-                    String valueStr = Strings.utf8ToString((byte[]) value.getReference());
-                
-                    return valueStr;
-                }
+                String valueStr = Strings.utf8ToString((byte[]) value.getReference());
+            
+                return valueStr;
             }
             
             String message = I18n.err( I18n.ERR_04131 );
@@ -545,7 +542,7 @@ public class DefaultAttribute implements
     private boolean areCompatible( String id, AttributeType attributeType )
     {
         // First, get rid of the options, if any
-        int optPos = id.indexOf( ";" );
+        int optPos = id.indexOf( ';' );
         String idNoOption = id;
         
         if ( optPos != -1 )

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=1089107&r1=1089106&r2=1089107&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
Tue Apr  5 16:15:15 2011
@@ -465,7 +465,7 @@ public final class DefaultEntry implemen
 
 
     /**
-     * Get the UpId if it was null.
+     * Get the UpId if it is null.
      * 
      * @param upId The ID
      */
@@ -481,18 +481,24 @@ public final class DefaultEntry implemen
                 LOG.error( message );
                 throw new IllegalArgumentException( message );
             }
+            
+            return upId;
         }
         else if ( Strings.isEmpty( normUpId ) )
         {
-            upId = attributeType.getName();
+            String id = attributeType.getName();
 
-            if ( Strings.isEmpty( upId ) )
+            if ( Strings.isEmpty( id ) )
             {
-                upId = attributeType.getOid();
+                id = attributeType.getOid();
             }
+            
+            return id;
+        }
+        else
+        {     
+            return upId;
         }
-
-        return upId;
     }
 
 
@@ -516,11 +522,11 @@ public final class DefaultEntry implemen
         
         try
         {
-            if ( objectClassAttributeType == null )
+            synchronized ( MUTEX )
             {
-                synchronized ( MUTEX )
+                if ( objectClassAttributeType == null )
                 {
-                    objectClassAttributeType = schemaManager.lookupAttributeTypeRegistry(
SchemaConstants.OBJECT_CLASS_AT );
+                        objectClassAttributeType = schemaManager.lookupAttributeTypeRegistry(
SchemaConstants.OBJECT_CLASS_AT );
                 }
             }
         }
@@ -759,20 +765,20 @@ public final class DefaultEntry implemen
 
         Attribute attribute = attributes.get( attributeType.getOid() );
 
-        upId = getUpId( upId, attributeType );
+        String id = getUpId( upId, attributeType );
 
         if ( attribute != null )
         {
             // This Attribute already exist, we add the values
             // into it
             attribute.add( values );
-            attribute.setUpId( upId, attributeType );
+            attribute.setUpId( id, attributeType );
         }
         else
         {
             // We have to create a new Attribute and set the values
             // and the upId
-            createAttribute( upId, attributeType, values );
+            createAttribute( id, attributeType, values );
         }
     }
 
@@ -789,7 +795,7 @@ public final class DefaultEntry implemen
             throw new IllegalArgumentException( message );
         }
 
-        upId = getUpId( upId, attributeType );
+        String id = getUpId( upId, attributeType );
 
         Attribute attribute = attributes.get( attributeType.getOid() );
 
@@ -798,11 +804,11 @@ public final class DefaultEntry implemen
             // This Attribute already exist, we add the values
             // into it
             attribute.add( values );
-            attribute.setUpId( upId, attributeType );
+            attribute.setUpId( id, attributeType );
         }
         else
         {
-            createAttribute( upId, attributeType, values );
+            createAttribute( id, attributeType, values );
         }
     }
 
@@ -819,7 +825,7 @@ public final class DefaultEntry implemen
             throw new IllegalArgumentException( message );
         }
 
-        upId = getUpId( upId, attributeType );
+        String id = getUpId( upId, attributeType );
 
         Attribute attribute = attributes.get( attributeType.getOid() );
 
@@ -828,13 +834,13 @@ public final class DefaultEntry implemen
             // This Attribute already exist, we add the values
             // into it
             attribute.add( values );
-            attribute.setUpId( upId, attributeType );
+            attribute.setUpId( id, attributeType );
         }
         else
         {
             // We have to create a new Attribute and set the values
             // and the upId
-            createAttribute( upId, attributeType, values );
+            createAttribute( id, attributeType, values );
         }
     }
 
@@ -2745,7 +2751,7 @@ public final class DefaultEntry implemen
                 {
                     AttributeType attributeType = schemaManager.getAttributeType( id );
 
-                    if ( attributeType != objectClassAttributeType )
+                    if ( !attributeType.equals( objectClassAttributeType ) )
                     {
                         sb.append( attribute );
                         continue;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java?rev=1089107&r1=1089106&r2=1089107&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
Tue Apr  5 16:15:15 2011
@@ -1003,7 +1003,7 @@ public class Rdn implements Cloneable, E
                         }
                     }
 
-                    if ( equals == false )
+                    if ( !equals )
                     {
                         return false;
                     }
@@ -1494,9 +1494,9 @@ public class Rdn implements Cloneable, E
                 break;
 
             default:
-                for ( Ava ava : avas )
+                for ( Ava localAva : avas )
                 {
-                    ava.writeExternal( out );
+                    localAva.writeExternal( out );
                 }
 
                 break;



Mime
View raw message