CVS: jcontainer/loom/engine/src/java/org/jcontainer/loom/components/configuration/merger ConfigurationMerger.java,1.3,1.4 ConfigurationSplitter.java,1.4,1.5

Peter Donald <pdonald-yCVjj/[email protected]> Wed, 3 Dec 2003 04:45:17 -0600
Newsgroups gmane.comp.java.jcontainer.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/configuration/merger
In directory hogshead.codehaus.org:/tmp/cvs-serv21491/engine/src/java/org/jcontainer/loom/components/configuration/merger

Modified Files:
	ConfigurationMerger.java ConfigurationSplitter.java 
Log Message:
Styled codebase


Index: ConfigurationMerger.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/configuration/merger/ConfigurationMerger.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ConfigurationMerger.java	5 Oct 2003 03:25:08 -0000	1.3
+++ ConfigurationMerger.java	3 Dec 2003 10:44:40 -0000	1.4
@@ -94,25 +94,22 @@
 import org.jcontainer.dna.impl.DefaultConfiguration;
 
 /**
- * The ConfigurationMerger will take a Configuration object and layer it over another.
+ * The ConfigurationMerger will take a Configuration object and layer it over
+ * another.
  *
- * It will use special attributes on the layer's children to control how children
- * of the layer and base are combined. In order for a child of the layer to be merged with a
- * child of the base, the following must hold true:
- * <ol>
- *   <li>The child in the <b>layer</b> Configuration has an attribute named
- *       <code>phoenix-configuration:merge</code> and its value is equal to a boolean
- *       <code>TRUE</code>
- *   </li>
- *   <li>There must be a single child in both the layer and base with the same getName() <b>OR</b>
- *       there exists an attribute named <code>phoenix-configuration:key-attribute</code>
- *       that names an attribute that exists on both the layer and base that can be used to match
- *       multiple children of the same getName()
- *   </li>
- * </ol>
+ * It will use special attributes on the layer's children to control how
+ * children of the layer and base are combined. In order for a child of the
+ * layer to be merged with a child of the base, the following must hold true:
+ * <ol> <li>The child in the <b>layer</b> Configuration has an attribute named
+ * <code>phoenix-configuration:merge</code> and its value is equal to a boolean
+ * <code>TRUE</code> </li> <li>There must be a single child in both the layer
+ * and base with the same getName() <b>OR</b> there exists an attribute named
+ * <code>phoenix-configuration:key-attribute</code> that names an attribute that
+ * exists on both the layer and base that can be used to match multiple children
+ * of the same getName() </li> </ol>
  *
- * @see ConfigurationSplitter
  * @author <a href="mailto:[email protected]">Peter Royal</a>
+ * @see ConfigurationSplitter
  */
 public class ConfigurationMerger
 {
@@ -121,18 +118,18 @@
      *
      * @param layer Configuration to <i>layer</i> over the base
      * @param base Configuration <i>layer</i> will be merged with
-     *
      * @return Result of merge
-     *
-     * @exception ConfigurationException if unable to merge
+     * @throws ConfigurationException if unable to merge
      */
-    public static Configuration merge( final Configuration layer, final Configuration base )
+    public static Configuration merge( final Configuration layer,
+                                       final Configuration base )
         throws ConfigurationException
     {
         final DefaultConfiguration merged =
             new DefaultConfiguration( base.getName(),
                                       base.getPath(),
-                                      "Merged [layer: " + layer.getLocation()
+                                      "Merged [layer: " +
+                                      layer.getLocation()
                                       + ", base: " + base.getLocation() + "]" );
 
         copyAttributes( base, merged );
@@ -160,7 +157,9 @@
 
         for( int i = 0; i < lc.length; i++ )
         {
-            final Configuration mergeWith = getMergePartner( lc[ i ], layer, base );
+            final Configuration mergeWith = getMergePartner( lc[ i ],
+                                                             layer,
+                                                             base );
 
             if( null == mergeWith )
             {
@@ -190,9 +189,12 @@
     {
         if( toMerge.getAttributeAsBoolean( Constants.MERGE_ATTR, false ) )
         {
-            final String keyAttribute = toMerge.getAttribute( Constants.KEY_ATTR, null );
+            final String keyAttribute = toMerge.getAttribute(
+                Constants.KEY_ATTR, null );
             final String keyvalue =
-                keyAttribute == null ? null : toMerge.getAttribute( keyAttribute );
+                keyAttribute == null ?
+                null :
+                toMerge.getAttribute( keyAttribute );
 
             final Configuration[] layerKids = match( layer,
                                                      toMerge.getName(),
@@ -211,7 +213,8 @@
             else
             {
                 throw new ConfigurationException( "Unable to merge configuration item, "
-                                                  + "multiple matches on child or base [name: "
+                                                  +
+                                                  "multiple matches on child or base [name: "
                                                   + toMerge.getName() + "]",
                                                   toMerge.getPath(),
                                                   toMerge.getLocation() );
@@ -221,7 +224,8 @@
         return null;
     }
 
-    private static String getValue( final Configuration layer, final Configuration base )
+    private static String getValue( final Configuration layer,
+                                    final Configuration base )
     {
         try
         {
@@ -243,16 +247,21 @@
         {
             if( !names[ i ].startsWith( Constants.MERGE_METADATA_PREFIX ) )
             {
-                dest.setAttribute( names[ i ], source.getAttribute( names[ i ] ) );
+                dest.setAttribute( names[ i ],
+                                   source.getAttribute( names[ i ] ) );
             }
         }
     }
 
     /**
-     * Return all occurance of a configuration child containing the supplied attribute name.
+     * Return all occurance of a configuration child containing the supplied
+     * attribute name.
+     *
      * @param config the configuration
-     * @param element the name of child elements to select from the configuration
-     * @param attribute the attribute name to filter (null will match any attribute name)
+     * @param element the name of child elements to select from the
+     * configuration
+     * @param attribute the attribute name to filter (null will match any
+     * attribute name)
      * @return an array of configuration instances matching the query
      */
     public static Configuration[] match( final Configuration config,
@@ -263,11 +272,16 @@
     }
 
     /**
-     * Return occurance of a configuration child containing the supplied attribute name and value.
+     * Return occurance of a configuration child containing the supplied
+     * attribute name and value.
+     *
      * @param config the configuration
-     * @param element the name of child elements to select from the configuration
-     * @param attribute the attribute name to filter (null will match any attribute name )
-     * @param value the attribute value to match (null will match any attribute value)
+     * @param element the name of child elements to select from the
+     * configuration
+     * @param attribute the attribute name to filter (null will match any
+     * attribute name )
+     * @param value the attribute value to match (null will match any attribute
+     * value)
      * @return an array of configuration instances matching the query
      */
     public static Configuration[] match( final Configuration config,

Index: ConfigurationSplitter.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/components/configuration/merger/ConfigurationSplitter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ConfigurationSplitter.java	3 Dec 2003 09:11:18 -0000	1.4
+++ ConfigurationSplitter.java	3 Dec 2003 10:44:40 -0000	1.5
@@ -89,37 +89,36 @@
 import java.util.HashSet;
 import org.jcontainer.dna.Configuration;
 import org.jcontainer.dna.ConfigurationException;
-import org.jcontainer.dna.impl.DefaultConfiguration;
 import org.jcontainer.dna.impl.ConfigurationUtil;
-import org.jcontainer.loom.components.util.ConfigUtil;
+import org.jcontainer.dna.impl.DefaultConfiguration;
 
 /**
- * The ConfigurationSplitter will take two Configuration objects and calculate the
- * differences between them.
+ * The ConfigurationSplitter will take two Configuration objects and calculate
+ * the differences between them.
  *
- * The resulting Configuration will contain special attribute that can be used by the
- * ConfigurationMerger to reconstruct the original Configuration
+ * The resulting Configuration will contain special attribute that can be used
+ * by the ConfigurationMerger to reconstruct the original Configuration
  *
- * @see ConfigurationMerger
  * @author <a href="mailto:[email protected]">Peter Royal</a>
+ * @see ConfigurationMerger
  */
 public class ConfigurationSplitter
 {
     /**
-     * Split a configuration, given a merged configuration and a base configuration.
-     * Functionally equivalent to producing a <i>diff</i> between the merged and base.
-     *
-     * @param merged Configuration that is a combination of the <i>result</i> and
-     *        the <i>base</i> param
-     * @param base Configuration that when merged with the <i>result</i> will yield the
-     *        <i>merged</i> param
-     *
-     * @return a Configuration that when merged with the <i>base</i> will yeild the
-     *         <i>merged</i>
+     * Split a configuration, given a merged configuration and a base
+     * configuration. Functionally equivalent to producing a <i>diff</i> between
+     * the merged and base.
      *
+     * @param merged Configuration that is a combination of the <i>result</i>
+     * and the <i>base</i> param
+     * @param base Configuration that when merged with the <i>result</i> will
+     * yield the <i>merged</i> param
+     * @return a Configuration that when merged with the <i>base</i> will yeild
+     *         the <i>merged</i>
      * @throws ConfigurationException if unable to split
      */
-    public static Configuration split( final Configuration merged, final Configuration base )
+    public static Configuration split( final Configuration merged,
+                                       final Configuration base )
         throws ConfigurationException
     {
         final DefaultConfiguration layer = doSplit( merged, base, false );
@@ -137,7 +136,8 @@
         final DefaultConfiguration layer =
             new DefaultConfiguration( base.getName(),
                                       merged.getPath(),
-                                      "Merged [merged: " + merged.getLocation()
+                                      "Merged [merged: " +
+                                      merged.getLocation()
                                       + ", base: " + base.getLocation() + "]" );
 
         copyAttributes( layer, merged, base );
@@ -212,7 +212,10 @@
                 else
                 {
                     throw new ConfigurationException( "Multiple children in base with name '"
-                                                      + name + "' and attr '" + keyAttr
+                                                      +
+                                                      name +
+                                                      "' and attr '" +
+                                                      keyAttr
                                                       + " = " + keyValue + "'",
                                                       merged.getPath(),
                                                       merged.getLocation() );
@@ -225,7 +228,9 @@
             }
             else if( !ConfigurationUtil.equals( kids[ i ], mergedWith ) )
             {
-                final DefaultConfiguration layerChild = doSplit( kids[ i ], mergedWith, keyAttr );
+                final DefaultConfiguration layerChild = doSplit( kids[ i ],
+                                                                 mergedWith,
+                                                                 keyAttr );
 
                 layerChild.makeReadOnly();
 
@@ -249,7 +254,11 @@
                 final String attr = attrs[ j ];
 
                 if( !testedAttributes.contains( attr )
-                    && isUniqueAttribute( attr, c[ i ].getAttribute( attr ), i, c ) )
+                    &&
+                    isUniqueAttribute( attr,
+                                       c[ i ].getAttribute( attr ),
+                                       i,
+                                       c ) )
                 {
                     if( null == uniqueAttr )
                     {
@@ -257,12 +266,20 @@
                     }
                     else
                     {
-                        throw new ConfigurationException( "Multiple unique attributes for child "
-                                                          + "[name: " + c[ 0 ].getName()
-                                                          + ", unique1: " + uniqueAttr
-                                                          + ", unique2: " + attr + "]",
-                                                          "",
-                                                          "");
+                        throw new ConfigurationException(
+                            "Multiple unique attributes for child "
+                            +
+                            "[name: " +
+                            c[ 0 ].getName()
+                            +
+                            ", unique1: " +
+                            uniqueAttr
+                            +
+                            ", unique2: " +
+                            attr +
+                            "]",
+                            "",
+                            "" );
                     }
                 }
                 else
@@ -274,10 +291,13 @@
 
         if( null == uniqueAttr )
         {
-            throw new ConfigurationException( "Unable to find unique attribute for "
-                                              + "children of name: " + c[ 0 ].getName(),
-                                              c[ 0 ].getPath(),
-                                              c[ 0 ].getLocation() );
+            throw new ConfigurationException(
+                "Unable to find unique attribute for "
+                +
+                "children of name: " +
+                c[ 0 ].getName(),
+                c[ 0 ].getPath(),
+                c[ 0 ].getLocation() );
         }
 
         return uniqueAttr;