directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r529958 - /directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/ServerConfigurationParser.java
Date Wed, 18 Apr 2007 10:39:52 GMT
Author: pamarcelot
Date: Wed Apr 18 03:39:51 2007
New Revision: 529958

URL: http://svn.apache.org/viewvc?view=rev&rev=529958
Log:
Code cleaning.

Modified:
    directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/ServerConfigurationParser.java

Modified: directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/ServerConfigurationParser.java
URL: http://svn.apache.org/viewvc/directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/ServerConfigurationParser.java?view=diff&rev=529958&r1=529957&r2=529958
==============================================================================
--- directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/ServerConfigurationParser.java
(original)
+++ directory/ldapstudio/trunk/ldapstudio-apacheds-configuration/src/main/java/org/apache/directory/ldapstudio/apacheds/configuration/model/ServerConfigurationParser.java
Wed Apr 18 03:39:51 2007
@@ -302,17 +302,7 @@
     private void readOtherPartitions( Element configurationBean, ServerConfiguration serverConfiguration
)
         throws NumberFormatException, BooleanFormatException
     {
-        Element propertyElement = null;
-        for ( Iterator i = configurationBean.elementIterator( "property" ); i.hasNext();
)
-        {
-            Element element = ( Element ) i.next();
-            Attribute nameAttribute = element.attribute( "name" );
-            if ( nameAttribute != null && ( nameAttribute.getValue().equals( "partitionConfigurations"
) ) )
-            {
-                propertyElement = element;
-                break;
-            }
-        }
+        Element propertyElement = getBeanPropertyElement( "partitionConfigurations", configurationBean
);
         if ( propertyElement != null )
         {
             Element setElement = propertyElement.element( "set" );
@@ -419,17 +409,7 @@
     {
         List<IndexedAttribute> indexedAttributes = new ArrayList<IndexedAttribute>();
 
-        Element propertyElement = null;
-        for ( Iterator i = partitionBean.elementIterator( "property" ); i.hasNext(); )
-        {
-            Element element = ( Element ) i.next();
-            Attribute nameAttribute = element.attribute( "name" );
-            if ( nameAttribute != null && ( nameAttribute.getValue().equals( "indexedAttributes"
) ) )
-            {
-                propertyElement = element;
-                break;
-            }
-        }
+        Element propertyElement = getBeanPropertyElement( "indexedAttributes", partitionBean
);
         if ( propertyElement != null )
         {
             Element setElement = propertyElement.element( "set" );
@@ -490,17 +470,7 @@
      */
     private Attributes readPartitionContextEntry( Element partitionBean )
     {
-        Element propertyElement = null;
-        for ( Iterator i = partitionBean.elementIterator( "property" ); i.hasNext(); )
-        {
-            Element element = ( Element ) i.next();
-            Attribute nameAttribute = element.attribute( "name" );
-            if ( nameAttribute != null && ( nameAttribute.getValue().equals( "contextEntry"
) ) )
-            {
-                propertyElement = element;
-                break;
-            }
-        }
+        Element propertyElement = getBeanPropertyElement( "contextEntry", partitionBean );
         if ( propertyElement != null )
         {
             Element valueElement = propertyElement.element( "value" );
@@ -585,17 +555,7 @@
      */
     private void readInterceptors( Element configurationBean, ServerConfiguration serverConfiguration
)
     {
-        Element propertyElement = null;
-        for ( Iterator i = configurationBean.elementIterator( "property" ); i.hasNext();
)
-        {
-            Element element = ( Element ) i.next();
-            Attribute nameAttribute = element.attribute( "name" );
-            if ( nameAttribute != null && ( nameAttribute.getValue().equals( "interceptorConfigurations"
) ) )
-            {
-                propertyElement = element;
-                break;
-            }
-        }
+        Element propertyElement = getBeanPropertyElement( "interceptorConfigurations", configurationBean
);
         if ( propertyElement != null )
         {
             Element listElement = propertyElement.element( "list" );
@@ -666,17 +626,7 @@
      */
     private void readExtendedOperations( Element configurationBean, ServerConfiguration serverConfiguration
)
     {
-        Element propertyElement = null;
-        for ( Iterator i = configurationBean.elementIterator( "property" ); i.hasNext();
)
-        {
-            Element element = ( Element ) i.next();
-            Attribute nameAttribute = element.attribute( "name" );
-            if ( nameAttribute != null && ( nameAttribute.getValue().equals( "extendedOperationHandlers"
) ) )
-            {
-                propertyElement = element;
-                break;
-            }
-        }
+        Element propertyElement = getBeanPropertyElement( "extendedOperationHandlers", configurationBean
);
         if ( propertyElement != null )
         {
             Element listElement = propertyElement.element( "list" );
@@ -742,34 +692,56 @@
 
 
     /**
-     * Reads the given property in the Bean and returns it.
+     * Reads the given property in the Bean and returns its value.
      *
      * @param property
      *      the property
      * @param element
-     *      the Configuration Bean Element
+     *      the Bean Element
      * @return
      *      the value of the property, or null if the property has not been found
      */
     private String readBeanProperty( String property, Element element )
     {
+        Element propertyElement = getBeanPropertyElement( property, element );
+        if ( propertyElement != null )
+        {
+            Attribute valueAttribute = propertyElement.attribute( "value" );
+            if ( valueAttribute != null )
+            {
+                return valueAttribute.getValue();
+            }
+
+            Attribute refAttribute = propertyElement.attribute( "ref" );
+            if ( refAttribute != null )
+            {
+                return refAttribute.getValue();
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
+     * Gets the given property Element in the the bean
+     *
+     * @param property
+     *      the propery
+     * @param element
+     *      the bean Element
+     * @return
+     *      the associated property, or null if the property has not been found
+     */
+    private Element getBeanPropertyElement( String property, Element element )
+    {
         for ( Iterator i = element.elementIterator( "property" ); i.hasNext(); )
         {
             Element propertyElement = ( Element ) i.next();
             Attribute nameAttribute = propertyElement.attribute( "name" );
             if ( nameAttribute != null && ( nameAttribute.getValue().equals( property
) ) )
             {
-                Attribute valueAttribute = propertyElement.attribute( "value" );
-                if ( valueAttribute != null )
-                {
-                    return valueAttribute.getValue();
-                }
-
-                Attribute refAttribute = propertyElement.attribute( "ref" );
-                if ( refAttribute != null )
-                {
-                    return refAttribute.getValue();
-                }
+                return propertyElement;
             }
         }
 



Mime
View raw message