You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jl...@apache.org on 2014/01/14 09:27:43 UTC

svn commit: r1557968 [13/26] - in /ant/ivy/core/trunk: src/java/org/apache/ivy/ src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/ src/java/org/apache/ivy/core/cache/ src/java/org/apache/ivy/core/check/ src/java/org/apache/ivy/core/deliver/ src...

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java Tue Jan 14 08:27:37 2014
@@ -72,14 +72,15 @@ import org.xml.sax.helpers.DefaultHandle
  * possible the original syntax
  */
 public final class XmlModuleDescriptorUpdater {
-    //CheckStyle:StaticVariableName| OFF    
-    //LINE_SEPARATOR is actually a constant, but we have to modify it for the tests
+    // CheckStyle:StaticVariableName| OFF
+    // LINE_SEPARATOR is actually a constant, but we have to modify it for the tests
     public static String LINE_SEPARATOR = System.getProperty("line.separator");
-    //CheckStyle:StaticVariableName| ON
-    
+
+    // CheckStyle:StaticVariableName| ON
+
     private XmlModuleDescriptorUpdater() {
     }
-    
+
     /**
      * used to copy a module descriptor xml file (also known as ivy file) and update the revisions
      * of its dependencies, its status and revision
@@ -89,8 +90,8 @@ public final class XmlModuleDescriptorUp
      * @param destFile
      *            The file to which the updated module descriptor should be output
      */
-    public static void update(URL srcURL, File destFile, UpdateOptions options) 
-            throws IOException, SAXException {
+    public static void update(URL srcURL, File destFile, UpdateOptions options) throws IOException,
+            SAXException {
         if (destFile.getParentFile() != null) {
             destFile.getParentFile().mkdirs();
         }
@@ -106,7 +107,7 @@ public final class XmlModuleDescriptorUp
         }
     }
 
-    public static void update(URL srcURL, OutputStream destFile, UpdateOptions options) 
+    public static void update(URL srcURL, OutputStream destFile, UpdateOptions options)
             throws IOException, SAXException {
         InputStream in = srcURL.openStream();
         try {
@@ -126,15 +127,14 @@ public final class XmlModuleDescriptorUp
 
     }
 
-    
-    public static void update(InputStream in, Resource res, 
-            File destFile, UpdateOptions options) throws IOException, SAXException {
+    public static void update(InputStream in, Resource res, File destFile, UpdateOptions options)
+            throws IOException, SAXException {
         if (destFile.getParentFile() != null) {
             destFile.getParentFile().mkdirs();
         }
         OutputStream fos = new FileOutputStream(destFile);
         try {
-            //TODO: use resource as input stream context?
+            // TODO: use resource as input stream context?
             URL inputStreamContext = null;
             if (res instanceof URLResource) {
                 inputStreamContext = ((URLResource) res).getURL();
@@ -163,11 +163,13 @@ public final class XmlModuleDescriptorUp
                 "module", "branch", "revision", "status", "publication", "namespace"});
 
         /** elements that may appear inside ivy-module, in expected order */
-        private static final List MODULE_ELEMENTS = Arrays.asList(new String[] {
-                "info", "configurations", "publications", "dependencies", "conflicts"
-        });
+        private static final List MODULE_ELEMENTS = Arrays.asList(new String[] {"info",
+                "configurations", "publications", "dependencies", "conflicts"});
+
         /** element position of "configurations" inside "ivy-module" */
-        private static final int CONFIGURATIONS_POSITION = MODULE_ELEMENTS.indexOf("configurations");
+        private static final int CONFIGURATIONS_POSITION = MODULE_ELEMENTS
+                .indexOf("configurations");
+
         /** element position of "dependencies" inside "ivy-module" */
         private static final int DEPENDENCIES_POSITION = MODULE_ELEMENTS.indexOf("dependencies");
 
@@ -180,7 +182,7 @@ public final class XmlModuleDescriptorUp
         private final PrintWriter out;
 
         private final Map resolvedRevisions;
-        
+
         private final Map resolvedBranches;
 
         private final String status;
@@ -192,7 +194,7 @@ public final class XmlModuleDescriptorUp
         private final Namespace ns;
 
         private final boolean replaceInclude;
-        
+
         private final boolean generateRevConstraint;
 
         private boolean inHeader = true;
@@ -200,7 +202,7 @@ public final class XmlModuleDescriptorUp
         private final List confs;
 
         private final URL relativePathCtx;
-        
+
         private final UpdateOptions options;
 
         public UpdaterHandler(URL relativePathCtx, PrintWriter out, final UpdateOptions options) {
@@ -229,33 +231,37 @@ public final class XmlModuleDescriptorUp
         private String organisation = null;
 
         // defaultConfMapping of imported configurations, if any
-        private String defaultConfMapping = null; 
+        private String defaultConfMapping = null;
 
         // confMappingOverride of imported configurations, if any
-        private Boolean confMappingOverride = null; 
+        private Boolean confMappingOverride = null;
 
-        // used to know if the last open tag was empty, to adjust termination 
+        // used to know if the last open tag was empty, to adjust termination
         // with /> instead of ></qName>
         private String justOpen = null;
-        
-        //track the size of the left indent, so that inserted elements are formatted
-        //like nearby elements.
 
-        //true when we're reading indent whitespace
+        // track the size of the left indent, so that inserted elements are formatted
+        // like nearby elements.
+
+        // true when we're reading indent whitespace
         private boolean indenting;
+
         private StringBuffer currentIndent = new StringBuffer();
+
         private ArrayList indentLevels = new ArrayList(); // ArrayList<String>
 
-        //true if an ivy-module/info/description element has been found in the published descriptor
+        // true if an ivy-module/info/description element has been found in the published descriptor
         private boolean hasDescription = false;
-        //true if merged configurations have been written
+
+        // true if merged configurations have been written
         private boolean mergedConfigurations = false;
-        //true if merged deps have been written
+
+        // true if merged deps have been written
         private boolean mergedDependencies = false;
 
         // the new value of the defaultconf attribute on the publications tag
         private String newDefaultConf = null;
-        
+
         private Stack context = new Stack();
 
         private Stack buffers = new Stack();
@@ -271,14 +277,12 @@ public final class XmlModuleDescriptorUp
             }
 
             flushMergedElementsBefore(qName);
-            
+
             // according to ivy.xsd, all <dependency> elements must occur before
             // the <exclude>, <override> or <conflict> elements
-            if (options.isMerge() 
-                    && ("exclude".equals(localName)
-                            || "override".equals(localName)
-                            || "conflict".equals(localName))
-                    && "ivy-module/dependencies".equals(getContext())) {
+            if (options.isMerge()
+                    && ("exclude".equals(localName) || "override".equals(localName) || "conflict"
+                            .equals(localName)) && "ivy-module/dependencies".equals(getContext())) {
                 ModuleDescriptor merged = options.getMergedDescriptor();
                 writeInheritedDependencies(merged);
                 out.println();
@@ -292,8 +296,8 @@ public final class XmlModuleDescriptorUp
                 infoStarted(attributes);
             } else if (replaceInclude && "include".equals(qName)
                     && context.contains("configurations")) {
-                //TODO, in the case of !replaceInclude, we should still replace the relative path
-                //by an absolute path. 
+                // TODO, in the case of !replaceInclude, we should still replace the relative path
+                // by an absolute path.
                 includeStarted(attributes);
             } else if ("ivy-module/info/extends".equals(path)) {
                 startExtends(attributes);
@@ -365,16 +369,16 @@ public final class XmlModuleDescriptorUp
                 if (options.isMerge() && path.startsWith("ivy-module/info")) {
                     ModuleDescriptor merged = options.getMergedDescriptor();
                     if (path.equals("ivy-module/info/description")) {
-                        //if the descriptor already contains a description, don't bother printing
-                        //the merged version.
+                        // if the descriptor already contains a description, don't bother printing
+                        // the merged version.
                         hasDescription = true;
                     } else if (!INFO_ELEMENTS.contains(qName)) {
-                        //according to the XSD, we should write description after all of the other
-                        //standard <info> elements but before any extended elements.
+                        // according to the XSD, we should write description after all of the other
+                        // standard <info> elements but before any extended elements.
                         writeInheritedDescription(merged);
                     }
                 }
-                
+
                 // copy
                 write("<" + qName);
                 for (int i = 0; i < attributes.getLength(); i++) {
@@ -402,7 +406,7 @@ public final class XmlModuleDescriptorUp
                 String value = null;
 
                 if ("revision".equals(name)) {
-                    //replace inline revision with resolved parent revision
+                    // replace inline revision with resolved parent revision
                     ModuleDescriptor merged = options.getMergedDescriptor();
                     if (merged != null) {
                         ExtendsDescriptor[] parents = merged.getInheritedDescriptors();
@@ -458,8 +462,8 @@ public final class XmlModuleDescriptorUp
             for (int i = 0; i < attributes.getLength(); i++) {
                 String attName = attributes.getQName(i);
                 if ("defaultconfmapping".equals(attName)) {
-                    String newMapping = removeConfigurationsFromMapping(substitute(settings,
-                        attributes.getValue("defaultconfmapping")), confs);
+                    String newMapping = removeConfigurationsFromMapping(
+                        substitute(settings, attributes.getValue("defaultconfmapping")), confs);
                     if (newMapping.length() > 0) {
                         write(" " + attributes.getQName(i) + "=\"" + newMapping + "\"");
                     }
@@ -469,27 +473,25 @@ public final class XmlModuleDescriptorUp
                 }
             }
             // add default conf mapping if needed
-            if (defaultConfMapping != null
-                    && attributes.getValue("defaultconfmapping") == null) {
+            if (defaultConfMapping != null && attributes.getValue("defaultconfmapping") == null) {
                 String newMapping = removeConfigurationsFromMapping(defaultConfMapping, confs);
                 if (newMapping.length() > 0) {
                     write(" defaultconfmapping=\"" + newMapping + "\"");
                 }
             }
             // add confmappingoverride if needed
-            if (confMappingOverride != null
-                    && attributes.getValue("confmappingoverride") == null) {
+            if (confMappingOverride != null && attributes.getValue("confmappingoverride") == null) {
                 write(" confmappingoverride=\"" + confMappingOverride.toString() + "\"");
             }
         }
-        
+
         private void startPublications(Attributes attributes) {
             write("<publications");
             for (int i = 0; i < attributes.getLength(); i++) {
                 String attName = attributes.getQName(i);
                 if ("defaultconf".equals(attName)) {
-                    newDefaultConf = removeConfigurationsFromList(substitute(settings,
-                        attributes.getValue("defaultconf")), confs);
+                    newDefaultConf = removeConfigurationsFromList(
+                        substitute(settings, attributes.getValue("defaultconf")), confs);
                     if (newDefaultConf.length() > 0) {
                         write(" " + attributes.getQName(i) + "=\"" + newDefaultConf + "\"");
                     }
@@ -505,7 +507,7 @@ public final class XmlModuleDescriptorUp
             buffers.push(buffer);
             confAttributeBuffers.push(buffer);
             buffer.setDefaultPrint(attributes.getValue("conf") == null
-                || attributes.getValue("conf").trim().length() == 0);
+                    || attributes.getValue("conf").trim().length() == 0);
             write("<dependency");
             String org = substitute(settings, attributes.getValue("org"));
             org = org == null ? organisation : org;
@@ -513,7 +515,7 @@ public final class XmlModuleDescriptorUp
             String branch = substitute(settings, attributes.getValue("branch"));
             String branchConstraint = substitute(settings, attributes.getValue("branchConstraint"));
             branchConstraint = branchConstraint == null ? branch : branchConstraint;
-            
+
             // look for the branch used in resolved revisions
             if (branch == null) {
                 ModuleId mid = ModuleId.newInstance(org, module);
@@ -528,7 +530,7 @@ public final class XmlModuleDescriptorUp
                     }
                 }
             }
-            
+
             String revision = substitute(settings, attributes.getValue("rev"));
             String revisionConstraint = substitute(settings, attributes.getValue("revConstraint"));
             Map extraAttributes = ExtendableItemHelper.getExtraAttributes(settings, attributes,
@@ -537,7 +539,7 @@ public final class XmlModuleDescriptorUp
                 revision, extraAttributes);
             ModuleRevisionId systemMrid = ns == null ? localMrid : ns.getToSystemTransformer()
                     .transform(localMrid);
-            
+
             String newBranch = (String) resolvedBranches.get(systemMrid);
 
             for (int i = 0; i < attributes.getLength(); i++) {
@@ -546,7 +548,7 @@ public final class XmlModuleDescriptorUp
                     String rev = (String) resolvedRevisions.get(systemMrid);
                     if (rev != null) {
                         write(" rev=\"" + rev + "\"");
-                        if (attributes.getIndex("branchConstraint") == -1 
+                        if (attributes.getIndex("branchConstraint") == -1
                                 && branchConstraint != null) {
                             write(" branchConstraint=\"" + branchConstraint + "\"");
                         }
@@ -564,13 +566,11 @@ public final class XmlModuleDescriptorUp
                 } else if ("name".equals(attName)) {
                     write(" name=\"" + systemMrid.getName() + "\"");
                 } else if ("branch".equals(attName)) {
-                    if(newBranch != null) {                        
+                    if (newBranch != null) {
                         write(" branch=\"" + newBranch + "\"");
-                    }                    
-                    else if(!resolvedBranches.containsKey(systemMrid)) {
+                    } else if (!resolvedBranches.containsKey(systemMrid)) {
                         write(" branch=\"" + systemMrid.getBranch() + "\"");
-                    }
-                    else {
+                    } else {
                         // if resolvedBranches contains the systemMrid, but the new branch is null,
                         // the branch attribute will be removed altogether
                     }
@@ -590,16 +590,15 @@ public final class XmlModuleDescriptorUp
                             + substitute(settings, attributes.getValue(attName)) + "\"");
                 }
             }
-            
-            if(attributes.getIndex("branch") == -1)
-            {            
+
+            if (attributes.getIndex("branch") == -1) {
                 if (newBranch != null) {
                     // erase an existing branch attribute if its new value is blank
-                    if(!newBranch.trim().equals(""))
+                    if (!newBranch.trim().equals(""))
                         write(" branch=\"" + newBranch + "\"");
-                }            
-                else if (options.isUpdateBranch() && systemMrid.getBranch() != null) {
-                    // this dependency is on a specific branch, we set it explicitly in the updated file
+                } else if (options.isUpdateBranch() && systemMrid.getBranch() != null) {
+                    // this dependency is on a specific branch, we set it explicitly in the updated
+                    // file
                     write(" branch=\"" + systemMrid.getBranch() + "\"");
                 }
             }
@@ -615,8 +614,8 @@ public final class XmlModuleDescriptorUp
                         settings.substitute(attributes.getValue("file")),
                         settings.substitute(attributes.getValue("url")));
                 } else {
-                    //TODO : settings can be null, but I don't why.  
-                    //Check if the next code is correct in that case
+                    // TODO : settings can be null, but I don't why.
+                    // Check if the next code is correct in that case
                     String fileName = attributes.getValue("file");
                     if (fileName == null) {
                         String urlStr = attributes.getValue("url");
@@ -634,13 +633,13 @@ public final class XmlModuleDescriptorUp
                             Attributes attributes) throws SAXException {
                         if ("configurations".equals(qName)) {
                             insideConfigurations = true;
-                            String defaultconf = substitute(settings, attributes
-                                    .getValue("defaultconfmapping"));
+                            String defaultconf = substitute(settings,
+                                attributes.getValue("defaultconfmapping"));
                             if (defaultconf != null) {
                                 defaultConfMapping = defaultconf;
                             }
-                            String mappingOverride = substitute(settings, attributes
-                                    .getValue("confmappingoverride"));
+                            String mappingOverride = substitute(settings,
+                                attributes.getValue("confmappingoverride"));
                             if (mappingOverride != null) {
                                 confMappingOverride = Boolean.valueOf(mappingOverride);
                             }
@@ -651,14 +650,13 @@ public final class XmlModuleDescriptorUp
                                 if (doIndent) {
                                     write("/>\n\t\t");
                                 }
-                                String extend = substitute(settings, 
-                                    attributes.getValue("extends"));
+                                String extend = substitute(settings, attributes.getValue("extends"));
                                 if (extend != null) {
-                                    for (StringTokenizer tok = new StringTokenizer(extend, ", "); 
-                                            tok.hasMoreTokens();) {
+                                    for (StringTokenizer tok = new StringTokenizer(extend, ", "); tok
+                                            .hasMoreTokens();) {
                                         String current = tok.nextToken();
                                         if (confs.contains(current)) {
-                                            throw new IllegalArgumentException("Cannot exclude a " 
+                                            throw new IllegalArgumentException("Cannot exclude a "
                                                     + "configuration which is extended.");
                                         }
                                     }
@@ -668,8 +666,7 @@ public final class XmlModuleDescriptorUp
                                 write("<" + qName);
                                 for (int i = 0; i < attributes.getLength(); i++) {
                                     write(" " + attributes.getQName(i) + "=\""
-                                            + substitute(settings, attributes.getValue(i))
-                                            + "\"");
+                                            + substitute(settings, attributes.getValue(i)) + "\"");
                                 }
                                 doIndent = true;
                             }
@@ -684,12 +681,11 @@ public final class XmlModuleDescriptorUp
                     }
                 });
             } catch (Exception e) {
-                Message.warn("exception occurred while importing configurations: "
-                        + e.getMessage());
+                Message.warn("exception occurred while importing configurations: " + e.getMessage());
                 throw new SAXException(e);
             }
         }
-        
+
         private void infoStarted(Attributes attributes) {
 
             String module = substitute(settings, attributes.getValue("module"));
@@ -697,10 +693,10 @@ public final class XmlModuleDescriptorUp
             String branch = null;
             String status = null;
             String namespace = null;
-            Map/*<String,String>*/ extraAttributes = null;
+            Map/* <String,String> */extraAttributes = null;
 
             if (options.isMerge()) {
-                //get attributes from merged descriptor, ignoring raw XML
+                // get attributes from merged descriptor, ignoring raw XML
                 ModuleDescriptor merged = options.getMergedDescriptor();
                 ModuleRevisionId mergedMrid = merged.getModuleRevisionId();
                 organisation = mergedMrid.getOrganisation();
@@ -708,7 +704,7 @@ public final class XmlModuleDescriptorUp
                 rev = mergedMrid.getRevision();
                 status = merged.getStatus();
 
-                //TODO: should namespace be added to ModuleDescriptor interface, so we don't
+                // TODO: should namespace be added to ModuleDescriptor interface, so we don't
                 // have to do this kind of check?
                 if (merged instanceof DefaultModuleDescriptor) {
                     Namespace ns = ((DefaultModuleDescriptor) merged).getNamespace();
@@ -722,7 +718,7 @@ public final class XmlModuleDescriptorUp
 
                 extraAttributes = merged.getQualifiedExtraAttributes();
             } else {
-                //get attributes from raw XML, performing property substitution
+                // get attributes from raw XML, performing property substitution
                 organisation = substitute(settings, attributes.getValue("organisation"));
                 rev = substitute(settings, attributes.getValue("revision"));
                 branch = substitute(settings, attributes.getValue("branch"));
@@ -736,8 +732,8 @@ public final class XmlModuleDescriptorUp
                     }
                 }
             }
-            
-            //apply override values provided in options
+
+            // apply override values provided in options
             if (revision != null) {
                 rev = revision;
             }
@@ -747,12 +743,12 @@ public final class XmlModuleDescriptorUp
             if (this.status != null) {
                 status = this.status;
             }
-            
-            //if necessary translate mrid using optional namespace argument
+
+            // if necessary translate mrid using optional namespace argument
             ModuleRevisionId localMid = ModuleRevisionId.newInstance(organisation, module, branch,
-                rev, ExtendableItemHelper.getExtraAttributes(settings, attributes,
-                    new String[] {"organisation", "module", "revision", "status", "publication",
-                        "namespace"}));
+                rev, ExtendableItemHelper
+                        .getExtraAttributes(settings, attributes, new String[] {"organisation",
+                                "module", "revision", "status", "publication", "namespace"}));
             ModuleRevisionId systemMid = ns == null ? localMid : ns.getToSystemTransformer()
                     .transform(localMid);
 
@@ -771,8 +767,8 @@ public final class XmlModuleDescriptorUp
             if (pubdate != null) {
                 write(" publication=\"" + DateUtil.format(pubdate) + "\"");
             } else if (attributes.getValue("publication") != null) {
-                write(" publication=\""
-                        + substitute(settings, attributes.getValue("publication")) + "\"");
+                write(" publication=\"" + substitute(settings, attributes.getValue("publication"))
+                        + "\"");
             }
             if (namespace != null) {
                 write(" namespace=\"" + namespace + "\"");
@@ -780,14 +776,14 @@ public final class XmlModuleDescriptorUp
 
             for (Iterator extras = extraAttributes.entrySet().iterator(); extras.hasNext();) {
                 Map.Entry extra = (Map.Entry) extras.next();
-                write(" " + extra.getKey() + "=\"" + extra.getValue() +  "\"");
+                write(" " + extra.getKey() + "=\"" + extra.getValue() + "\"");
             }
         }
 
         private void write(String content) {
             getWriter().print(content);
         }
-        
+
         private PrintWriter getWriter() {
             return buffers.isEmpty() ? out : ((ExtendedBuffer) buffers.peek()).getWriter();
         }
@@ -869,17 +865,17 @@ public final class XmlModuleDescriptorUp
                 justOpen = null;
             }
             write(XMLHelper.escape(String.valueOf(ch, start, length)));
-            
-            //examine characters for current indent level, keeping in mind
-            //that our indent might be split across multiple calls to characters()
+
+            // examine characters for current indent level, keeping in mind
+            // that our indent might be split across multiple calls to characters()
             for (int i = start, end = start + length; i < end; ++i) {
                 char c = ch[i];
                 if (c == '\r' || c == '\n') {
-                    //newline resets the indent level
+                    // newline resets the indent level
                     currentIndent.setLength(0);
                     indenting = true;
                 } else if (indenting) {
-                    //indent continues until first non-whitespace character
+                    // indent continues until first non-whitespace character
                     if (Character.isWhitespace(c)) {
                         currentIndent.append(c);
                     } else {
@@ -892,16 +888,16 @@ public final class XmlModuleDescriptorUp
         /** record the current indent level for future elements that appear at the same depth */
         private void endIndent() {
             if (indenting) {
-                //record the indent at this level.  if we insert any elements at
-                //this level, we'll use the same indent.
+                // record the indent at this level. if we insert any elements at
+                // this level, we'll use the same indent.
                 setIndent(context.size() - 1, currentIndent.toString());
                 indenting = false;
             }
         }
 
         /**
-         * Set the indent for the given depth.  Indents less than the provided depth
-         * will be calculated automatically, if they have not already been defined.
+         * Set the indent for the given depth. Indents less than the provided depth will be
+         * calculated automatically, if they have not already been defined.
          */
         private void setIndent(int level, String indent) {
             fillIndents(level);
@@ -909,13 +905,13 @@ public final class XmlModuleDescriptorUp
         }
 
         /**
-         * Guarantee that indent levels have been calculated up to and including the
-         * given depth (starting at 0).
+         * Guarantee that indent levels have been calculated up to and including the given depth
+         * (starting at 0).
          */
         private void fillIndents(int level) {
             if (indentLevels.isEmpty()) {
-                //add a default single-level indent until we see indents in the document
-                indentLevels.add("    "); 
+                // add a default single-level indent until we see indents in the document
+                indentLevels.add("    ");
             }
             String oneLevel = (String) indentLevels.get(0);
             for (int fill = indentLevels.size(); fill <= level; ++fill) {
@@ -933,19 +929,24 @@ public final class XmlModuleDescriptorUp
         /**
          * Write XML elements that do not appear in the source descriptor, but have been copied in
          * from a parent module descriptor via &lt;extends&gt; declaration.
-         * @param merged child descriptor containing the merged data
-         * @param items the list of inherited items to print
-         * @param printer a printer that knows how to write the given type of item
-         * @param itemName the name of the container element, e.g. "configurations"
-         * @param includeContainer if true, include an enclosing element named
-         *   <code>itemName</code>. Otherwise just write the inherited items inline,
-         *   with a comment indicating where they came from.
+         * 
+         * @param merged
+         *            child descriptor containing the merged data
+         * @param items
+         *            the list of inherited items to print
+         * @param printer
+         *            a printer that knows how to write the given type of item
+         * @param itemName
+         *            the name of the container element, e.g. "configurations"
+         * @param includeContainer
+         *            if true, include an enclosing element named <code>itemName</code>. Otherwise
+         *            just write the inherited items inline, with a comment indicating where they
+         *            came from.
          */
-        private void writeInheritedItems(ModuleDescriptor merged, 
-                InheritableItem[] items, ItemPrinter printer, String itemName,
-                boolean includeContainer) {
-            //first categorize inherited items by their source module, so that 
-            //we can add some useful comments
+        private void writeInheritedItems(ModuleDescriptor merged, InheritableItem[] items,
+                ItemPrinter printer, String itemName, boolean includeContainer) {
+            // first categorize inherited items by their source module, so that
+            // we can add some useful comments
             PrintWriter out = getWriter();
 
             Map inheritedItems = collateInheritedItems(merged, items);
@@ -967,7 +968,7 @@ public final class XmlModuleDescriptorUp
 
                 if (justOpen != null) {
                     out.println(">");
-                    justOpen = null; //helps endElement() decide how to write close tags
+                    justOpen = null; // helps endElement() decide how to write close tags
                 }
                 writeInheritanceComment(itemName, parent);
                 for (int c = 0; c < list.size(); ++c) {
@@ -983,35 +984,38 @@ public final class XmlModuleDescriptorUp
                     out.println(getIndent() + "</" + itemName + ">");
                     out.println();
                 }
-                //restore the prior indent
+                // restore the prior indent
                 out.print(currentIndent);
             }
         }
 
-
         private void writeInheritanceComment(String itemDescription, Object parentInfo) {
             PrintWriter out = getWriter();
             out.println();
-            out.println(getIndent() + "<!-- " + itemDescription + " inherited from "
-                + parentInfo + " -->");
+            out.println(getIndent() + "<!-- " + itemDescription + " inherited from " + parentInfo
+                    + " -->");
         }
 
         /**
-         * Collect the given list of inherited descriptor items into lists keyed by parent Id.
-         * Thus all of the items inherited from parent A can be written together, then all of
-         * the items from parent B, and so on.
-         * @param merged the merged child descriptor
-         * @param items the inherited items to collate
-         * @return maps parent ModuleRevisionId to a List of InheritedItems imported from that parent
+         * Collect the given list of inherited descriptor items into lists keyed by parent Id. Thus
+         * all of the items inherited from parent A can be written together, then all of the items
+         * from parent B, and so on.
+         * 
+         * @param merged
+         *            the merged child descriptor
+         * @param items
+         *            the inherited items to collate
+         * @return maps parent ModuleRevisionId to a List of InheritedItems imported from that
+         *         parent
          */
-        private Map/*<ModuleRevisionId,List>*/ collateInheritedItems(ModuleDescriptor merged, 
+        private Map/* <ModuleRevisionId,List> */collateInheritedItems(ModuleDescriptor merged,
                 InheritableItem[] items) {
-            LinkedHashMap/*<ModuleRevisionId,List>*/ inheritedItems = new LinkedHashMap();
+            LinkedHashMap/* <ModuleRevisionId,List> */inheritedItems = new LinkedHashMap();
             for (int i = 0; i < items.length; ++i) {
                 ModuleRevisionId source = items[i].getSourceModule();
-                //ignore items that are defined directly in the child descriptor
-                if (source != null 
-                    && !source.getModuleId().equals(merged.getModuleRevisionId().getModuleId())) {
+                // ignore items that are defined directly in the child descriptor
+                if (source != null
+                        && !source.getModuleId().equals(merged.getModuleRevisionId().getModuleId())) {
                     List accum = (List) inheritedItems.get(source);
                     if (accum == null) {
                         accum = new ArrayList();
@@ -1025,7 +1029,7 @@ public final class XmlModuleDescriptorUp
 
         /**
          * If no info/description element has yet been written, write the description inherited from
-         * the parent descriptor, if any.  Calling this method more than once has no affect.
+         * the parent descriptor, if any. Calling this method more than once has no affect.
          */
         private void writeInheritedDescription(ModuleDescriptor merged) {
             if (!hasDescription) {
@@ -1037,8 +1041,9 @@ public final class XmlModuleDescriptorUp
                         writer.println(">");
                     }
                     writeInheritanceComment("description", "parent");
-                    writer.println(getIndent() + "<description>" + XMLHelper.escape(description) + "</description>");
-                    //restore the indent that existed before we wrote the extra elements
+                    writer.println(getIndent() + "<description>" + XMLHelper.escape(description)
+                            + "</description>");
+                    // restore the indent that existed before we wrote the extra elements
                     writer.print(currentIndent);
                     justOpen = null;
                 }
@@ -1056,81 +1061,87 @@ public final class XmlModuleDescriptorUp
         private void writeInheritedDependencies(ModuleDescriptor merged) {
             if (!mergedDependencies) {
                 mergedDependencies = true;
-                writeInheritedItems(merged, merged.getDependencies(),
-                    DependencyPrinter.INSTANCE, "dependencies", false);
+                writeInheritedItems(merged, merged.getDependencies(), DependencyPrinter.INSTANCE,
+                    "dependencies", false);
             }
         }
 
         /**
-         * <p>If publishing in merge mode, guarantee that any merged elements appearing
-         * before <code>moduleElement</code> have been written.  This method should
-         * be called <i>before</i> we write the start tag of <code>moduleElement</code>.
-         * This covers cases where merged elements like "configurations" and "dependencies" appear
-         * in the parent descriptor, but are completely missing in the child descriptor.</p>
-         *
-         * <p>For example, if "moduleElement" is "dependencies", guarantees that "configurations"
-         * has been written.  If <code>moduleElement</code> is <code>null</code>, then all
-         * missing merged elements will be flushed.</p>
-         *
-         * @param moduleElement a descriptor element name, for example "configurations" or "info"
+         * <p>
+         * If publishing in merge mode, guarantee that any merged elements appearing before
+         * <code>moduleElement</code> have been written. This method should be called <i>before</i>
+         * we write the start tag of <code>moduleElement</code>. This covers cases where merged
+         * elements like "configurations" and "dependencies" appear in the parent descriptor, but
+         * are completely missing in the child descriptor.
+         * </p>
+         * 
+         * <p>
+         * For example, if "moduleElement" is "dependencies", guarantees that "configurations" has
+         * been written. If <code>moduleElement</code> is <code>null</code>, then all missing merged
+         * elements will be flushed.
+         * </p>
+         * 
+         * @param moduleElement
+         *            a descriptor element name, for example "configurations" or "info"
          */
         private void flushMergedElementsBefore(String moduleElement) {
             if (options.isMerge() && context.size() == 1 && "ivy-module".equals(context.peek())
-                && !(mergedConfigurations && mergedDependencies)) {
+                    && !(mergedConfigurations && mergedDependencies)) {
 
-                //calculate the position of the element in ivy-module
-                int position = moduleElement == null ? MODULE_ELEMENTS.size()
-                        : MODULE_ELEMENTS.indexOf(moduleElement);
+                // calculate the position of the element in ivy-module
+                int position = moduleElement == null ? MODULE_ELEMENTS.size() : MODULE_ELEMENTS
+                        .indexOf(moduleElement);
 
                 ModuleDescriptor merged = options.getMergedDescriptor();
 
-                //see if we should write <configurations>
+                // see if we should write <configurations>
                 if (!mergedConfigurations && position > CONFIGURATIONS_POSITION
                         && merged.getConfigurations().length > 0) {
 
                     mergedConfigurations = true;
                     writeInheritedItems(merged, merged.getConfigurations(),
-                            ConfigurationPrinter.INSTANCE, "configurations", true);
+                        ConfigurationPrinter.INSTANCE, "configurations", true);
 
                 }
-                //see if we should write <dependencies>
+                // see if we should write <dependencies>
                 if (!mergedDependencies && position > DEPENDENCIES_POSITION
-                    && merged.getDependencies().length > 0) {
+                        && merged.getDependencies().length > 0) {
 
                     mergedDependencies = true;
                     writeInheritedItems(merged, merged.getDependencies(),
-                            DependencyPrinter.INSTANCE, "dependencies", true);
+                        DependencyPrinter.INSTANCE, "dependencies", true);
 
                 }
             }
         }
+
         private void flushAllMergedElements() {
             flushMergedElementsBefore(null);
         }
 
         public void endElement(String uri, String localName, String qName) throws SAXException {
-            
+
             String path = getContext();
             if (options.isMerge()) {
                 ModuleDescriptor merged = options.getMergedDescriptor();
 
                 if ("ivy-module/info".equals(path)) {
-                    //guarantee that inherited description has been written before
-                    //info element closes.
+                    // guarantee that inherited description has been written before
+                    // info element closes.
                     writeInheritedDescription(merged);
                 } else if ("ivy-module/configurations".equals(path)) {
-                    //write inherited configurations after all child configurations
+                    // write inherited configurations after all child configurations
                     writeInheritedConfigurations(merged);
                 } else if ("ivy-module/dependencies".equals(path)) {
-                    //write inherited dependencies after all child dependencies
+                    // write inherited dependencies after all child dependencies
                     writeInheritedDependencies(merged);
                 } else if ("ivy-module".equals(path)) {
-                    //write any remaining inherited data before we close the
-                    //descriptor.
+                    // write any remaining inherited data before we close the
+                    // descriptor.
                     flushAllMergedElements();
                 }
             }
-            
+
             if (qName.equals(justOpen)) {
                 write("/>");
             } else {
@@ -1154,7 +1165,7 @@ public final class XmlModuleDescriptorUp
                 }
             }
 
-            //<extends> element is commented out when in merge mode.
+            // <extends> element is commented out when in merge mode.
             if (options.isMerge() && "ivy-module/info/extends".equals(path)) {
                 write(" -->");
             }
@@ -1168,7 +1179,7 @@ public final class XmlModuleDescriptorUp
             out.flush();
             out.close();
         }
-        
+
         public void processingInstruction(String target, String data) throws SAXException {
             write("<?");
             write(target);
@@ -1227,13 +1238,12 @@ public final class XmlModuleDescriptorUp
 
     }
 
-    public static void update(URL inStreamCtx, InputStream inStream,
-            OutputStream outStream, final UpdateOptions options) 
-            throws IOException, SAXException {
+    public static void update(URL inStreamCtx, InputStream inStream, OutputStream outStream,
+            final UpdateOptions options) throws IOException, SAXException {
         final PrintWriter out = new PrintWriter(new OutputStreamWriter(outStream, "UTF-8"));
         out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
         out.write(LINE_SEPARATOR);
-        
+
         try {
             UpdaterHandler updaterHandler = new UpdaterHandler(inStreamCtx, out, options);
             InputSource inSrc = new InputSource(new BufferedInputStream(inStream));
@@ -1257,7 +1267,7 @@ public final class XmlModuleDescriptorUp
         private boolean defaultPrint = false;
 
         private StringWriter buffer = new StringWriter();
-        
+
         private PrintWriter writer = new PrintWriter(buffer);
 
         ExtendedBuffer(String context) {
@@ -1286,39 +1296,42 @@ public final class XmlModuleDescriptorUp
         String getContext() {
             return context;
         }
-        
+
         public String toString() {
             writer.flush();
             return buffer.toString();
         }
     }
-    
+
     /**
      * Prints a descriptor item's XML representation
      */
     protected static interface ItemPrinter {
         /**
          * Print an XML representation of <code>item</code> to <code>out</code>.
-         * @param parent the module descriptor containing <code>item</code>
-         * @param item subcomponent of the descriptor, for example a {@link DependencyDescriptor} 
-         *   or {@link Configuration}
+         * 
+         * @param parent
+         *            the module descriptor containing <code>item</code>
+         * @param item
+         *            subcomponent of the descriptor, for example a {@link DependencyDescriptor} or
+         *            {@link Configuration}
          */
         public void print(ModuleDescriptor parent, Object item, PrintWriter out);
     }
-    
+
     protected static class DependencyPrinter implements ItemPrinter {
-        
+
         public static final DependencyPrinter INSTANCE = new DependencyPrinter();
-        
+
         public void print(ModuleDescriptor parent, Object item, PrintWriter out) {
             XmlModuleDescriptorWriter.printDependency(parent, (DependencyDescriptor) item, out);
         }
     }
-    
+
     protected static class ConfigurationPrinter implements ItemPrinter {
-        
+
         public static final ConfigurationPrinter INSTANCE = new ConfigurationPrinter();
-        
+
         public void print(ModuleDescriptor parent, Object item, PrintWriter out) {
             XmlModuleDescriptorWriter.printConfiguration((Configuration) item, out);
         }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java Tue Jan 14 08:27:37 2014
@@ -53,11 +53,11 @@ import org.apache.ivy.util.extendable.Ex
  *
  */
 public final class XmlModuleDescriptorWriter {
-    
+
     private XmlModuleDescriptorWriter() {
-        //Utility class
+        // Utility class
     }
-    
+
     public static void write(ModuleDescriptor md, File output) throws IOException {
         write(md, null, output);
     }
@@ -79,14 +79,14 @@ public final class XmlModuleDescriptorWr
             for (Iterator iter = namespaces.entrySet().iterator(); iter.hasNext();) {
                 Entry ns = (Entry) iter.next();
                 xmlNamespace.append(" xmlns:").append(ns.getKey()).append("=\"")
-                            .append(ns.getValue()).append("\"");
+                        .append(ns.getValue()).append("\"");
             }
-            
+
             String version = "2.0";
             if (md.getInheritedDescriptors().length > 0) {
                 version = "2.2";
             }
-            
+
             out.println("<ivy-module version=\"" + version + "\"" + xmlNamespace + ">");
             printInfoTag(md, out);
             printConfigurations(md, out);
@@ -112,28 +112,28 @@ public final class XmlModuleDescriptorWr
             out.println("\t</dependencies>");
         }
     }
-    
-    protected static void printDependency(ModuleDescriptor md, DependencyDescriptor dep, 
+
+    protected static void printDependency(ModuleDescriptor md, DependencyDescriptor dep,
             PrintWriter out) {
         out.print("<dependency");
-        out.print(" org=\"" 
-            + XMLHelper.escape(dep.getDependencyRevisionId().getOrganisation()) + "\"");
-        out.print(" name=\"" 
-            + XMLHelper.escape(dep.getDependencyRevisionId().getName()) + "\"");
+        out.print(" org=\"" + XMLHelper.escape(dep.getDependencyRevisionId().getOrganisation())
+                + "\"");
+        out.print(" name=\"" + XMLHelper.escape(dep.getDependencyRevisionId().getName()) + "\"");
         if (dep.getDependencyRevisionId().getBranch() != null) {
-            out.print(" branch=\"" 
-                + XMLHelper.escape(dep.getDependencyRevisionId().getBranch()) + "\"");
+            out.print(" branch=\"" + XMLHelper.escape(dep.getDependencyRevisionId().getBranch())
+                    + "\"");
         }
-        out.print(" rev=\"" 
-            + XMLHelper.escape(dep.getDependencyRevisionId().getRevision()) + "\"");
-        if (!dep.getDynamicConstraintDependencyRevisionId()
-                .equals(dep.getDependencyRevisionId())) {
+        out.print(" rev=\"" + XMLHelper.escape(dep.getDependencyRevisionId().getRevision()) + "\"");
+        if (!dep.getDynamicConstraintDependencyRevisionId().equals(dep.getDependencyRevisionId())) {
             if (dep.getDynamicConstraintDependencyRevisionId().getBranch() != null) {
-                out.print(" branchConstraint=\"" + XMLHelper.escape(
-                     dep.getDynamicConstraintDependencyRevisionId().getBranch()) + "\"");
-            }
-            out.print(" revConstraint=\"" + XMLHelper.escape(
-                dep.getDynamicConstraintDependencyRevisionId().getRevision()) + "\"");
+                out.print(" branchConstraint=\""
+                        + XMLHelper.escape(dep.getDynamicConstraintDependencyRevisionId()
+                                .getBranch()) + "\"");
+            }
+            out.print(" revConstraint=\""
+                    + XMLHelper
+                            .escape(dep.getDynamicConstraintDependencyRevisionId().getRevision())
+                    + "\"");
         }
         if (dep.isForce()) {
             out.print(" force=\"" + dep.isForce() + "\"");
@@ -160,24 +160,24 @@ public final class XmlModuleDescriptorWr
             }
         }
         out.print("\"");
-        
+
         printExtraAttributes(dep, out, " ");
-        
+
         DependencyArtifactDescriptor[] depArtifacts = dep.getAllDependencyArtifacts();
         if (depArtifacts.length > 0) {
             out.println(">");
         }
         printDependencyArtefacts(md, out, depArtifacts);
-        
+
         IncludeRule[] includes = dep.getAllIncludeRules();
         if (includes.length > 0 && depArtifacts.length == 0) {
-                out.println(">");
-            }
+            out.println(">");
+        }
         printDependencyIncludeRules(md, out, includes);
-        
+
         ExcludeRule[] excludes = dep.getAllExcludeRules();
         if (excludes.length > 0 && includes.length == 0 && depArtifacts.length == 0) {
-             out.println(">");
+            out.println(">");
         }
         printDependencyExcludeRules(md, out, excludes);
         if (includes.length + excludes.length + depArtifacts.length == 0) {
@@ -188,29 +188,27 @@ public final class XmlModuleDescriptorWr
     }
 
     private static void printAllMediators(ModuleDescriptor md, PrintWriter out) {
-        Map/*<MapMatcher, DependencyDescriptorMediator>*/ mediators 
-            = md.getAllDependencyDescriptorMediators().getAllRules();
-        
+        Map/* <MapMatcher, DependencyDescriptorMediator> */mediators = md
+                .getAllDependencyDescriptorMediators().getAllRules();
+
         for (Iterator iterator = mediators.entrySet().iterator(); iterator.hasNext();) {
             Map.Entry mediatorRule = (Map.Entry) iterator.next();
             MapMatcher matcher = (MapMatcher) mediatorRule.getKey();
-            DependencyDescriptorMediator mediator = 
-                (DependencyDescriptorMediator) mediatorRule.getValue();
-            
+            DependencyDescriptorMediator mediator = (DependencyDescriptorMediator) mediatorRule
+                    .getValue();
+
             if (mediator instanceof OverrideDependencyDescriptorMediator) {
-                OverrideDependencyDescriptorMediator oddm = 
-                    (OverrideDependencyDescriptorMediator) mediator;
-                
+                OverrideDependencyDescriptorMediator oddm = (OverrideDependencyDescriptorMediator) mediator;
+
                 out.print("\t\t<override");
-                out.print(" org=\"" + XMLHelper.escape(
-                    (String) matcher.getAttributes().get(IvyPatternHelper.ORGANISATION_KEY)) 
-                    + "\"");
-                out.print(" module=\"" + XMLHelper.escape(
-                    (String) matcher.getAttributes().get(IvyPatternHelper.MODULE_KEY)) 
-                    + "\"");
-                out.print(" matcher=\"" + XMLHelper.escape(
-                    matcher.getPatternMatcher().getName()) 
-                    + "\"");
+                out.print(" org=\""
+                        + XMLHelper.escape((String) matcher.getAttributes().get(
+                            IvyPatternHelper.ORGANISATION_KEY)) + "\"");
+                out.print(" module=\""
+                        + XMLHelper.escape((String) matcher.getAttributes().get(
+                            IvyPatternHelper.MODULE_KEY)) + "\"");
+                out.print(" matcher=\"" + XMLHelper.escape(matcher.getPatternMatcher().getName())
+                        + "\"");
                 if (oddm.getBranch() != null) {
                     out.print(" branch=\"" + XMLHelper.escape(oddm.getBranch()) + "\"");
                 }
@@ -219,8 +217,8 @@ public final class XmlModuleDescriptorWr
                 }
                 out.println("/>");
             } else {
-                Message.verbose("ignoring unhandled DependencyDescriptorMediator: " 
-                    + mediator.getClass());
+                Message.verbose("ignoring unhandled DependencyDescriptorMediator: "
+                        + mediator.getClass());
             }
         }
     }
@@ -231,17 +229,15 @@ public final class XmlModuleDescriptorWr
             for (int j = 0; j < excludes.length; j++) {
                 out.print("\t\t<exclude");
                 out.print(" org=\""
-                        + XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation()) 
-                        + "\"");
-                out.print(" module=\"" 
-                    + XMLHelper.escape(excludes[j].getId().getModuleId().getName())
+                        + XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation())
                         + "\"");
+                out.print(" module=\""
+                        + XMLHelper.escape(excludes[j].getId().getModuleId().getName()) + "\"");
                 out.print(" artifact=\"" + XMLHelper.escape(excludes[j].getId().getName()) + "\"");
                 out.print(" type=\"" + XMLHelper.escape(excludes[j].getId().getType()) + "\"");
                 out.print(" ext=\"" + XMLHelper.escape(excludes[j].getId().getExt()) + "\"");
                 String[] ruleConfs = excludes[j].getConfigurations();
-                if (!Arrays.asList(ruleConfs).equals(
-                    Arrays.asList(md.getConfigurationsNames()))) {
+                if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < ruleConfs.length; k++) {
                         out.print(XMLHelper.escape(ruleConfs[k]));
@@ -251,8 +247,8 @@ public final class XmlModuleDescriptorWr
                     }
                     out.print("\"");
                 }
-                out.print(" matcher=\"" 
-                    + XMLHelper.escape(excludes[j].getMatcher().getName()) + "\"");
+                out.print(" matcher=\"" + XMLHelper.escape(excludes[j].getMatcher().getName())
+                        + "\"");
                 out.println("/>");
             }
         }
@@ -264,17 +260,15 @@ public final class XmlModuleDescriptorWr
             for (int j = 0; j < excludes.length; j++) {
                 out.print("\t\t\t<exclude");
                 out.print(" org=\""
-                        + XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation()) 
-                        + "\"");
-                out.print(" module=\"" 
-                    + XMLHelper.escape(excludes[j].getId().getModuleId().getName())
+                        + XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation())
                         + "\"");
+                out.print(" module=\""
+                        + XMLHelper.escape(excludes[j].getId().getModuleId().getName()) + "\"");
                 out.print(" name=\"" + XMLHelper.escape(excludes[j].getId().getName()) + "\"");
                 out.print(" type=\"" + XMLHelper.escape(excludes[j].getId().getType()) + "\"");
                 out.print(" ext=\"" + XMLHelper.escape(excludes[j].getId().getExt()) + "\"");
                 String[] ruleConfs = excludes[j].getConfigurations();
-                if (!Arrays.asList(ruleConfs).equals(
-                    Arrays.asList(md.getConfigurationsNames()))) {
+                if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < ruleConfs.length; k++) {
                         out.print(XMLHelper.escape(ruleConfs[k]));
@@ -284,8 +278,8 @@ public final class XmlModuleDescriptorWr
                     }
                     out.print("\"");
                 }
-                out.print(" matcher=\"" 
-                    + XMLHelper.escape(excludes[j].getMatcher().getName()) + "\"");
+                out.print(" matcher=\"" + XMLHelper.escape(excludes[j].getMatcher().getName())
+                        + "\"");
                 out.println("/>");
             }
         }
@@ -300,8 +294,7 @@ public final class XmlModuleDescriptorWr
                 out.print(" type=\"" + XMLHelper.escape(includes[j].getId().getType()) + "\"");
                 out.print(" ext=\"" + XMLHelper.escape(includes[j].getId().getExt()) + "\"");
                 String[] ruleConfs = includes[j].getConfigurations();
-                if (!Arrays.asList(ruleConfs).equals(
-                    Arrays.asList(md.getConfigurationsNames()))) {
+                if (!Arrays.asList(ruleConfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < ruleConfs.length; k++) {
                         out.print(XMLHelper.escape(ruleConfs[k]));
@@ -311,14 +304,14 @@ public final class XmlModuleDescriptorWr
                     }
                     out.print("\"");
                 }
-                out.print(" matcher=\"" 
-                    + XMLHelper.escape(includes[j].getMatcher().getName()) + "\"");
+                out.print(" matcher=\"" + XMLHelper.escape(includes[j].getMatcher().getName())
+                        + "\"");
                 out.println("/>");
             }
         }
     }
 
-    private static void printDependencyArtefacts(ModuleDescriptor md, PrintWriter out, 
+    private static void printDependencyArtefacts(ModuleDescriptor md, PrintWriter out,
             DependencyArtifactDescriptor[] depArtifacts) {
         if (depArtifacts.length > 0) {
             for (int j = 0; j < depArtifacts.length; j++) {
@@ -327,8 +320,7 @@ public final class XmlModuleDescriptorWr
                 out.print(" type=\"" + XMLHelper.escape(depArtifacts[j].getType()) + "\"");
                 out.print(" ext=\"" + XMLHelper.escape(depArtifacts[j].getExt()) + "\"");
                 String[] dadconfs = depArtifacts[j].getConfigurations();
-                if (!Arrays.asList(dadconfs).equals(
-                    Arrays.asList(md.getConfigurationsNames()))) {
+                if (!Arrays.asList(dadconfs).equals(Arrays.asList(md.getConfigurationsNames()))) {
                     out.print(" conf=\"");
                     for (int k = 0; k < dadconfs.length; k++) {
                         out.print(XMLHelper.escape(dadconfs[k]));
@@ -345,35 +337,41 @@ public final class XmlModuleDescriptorWr
     }
 
     /**
-     * Writes the extra attributes of the given {@link ExtendableItem} to the
-     * given <tt>PrintWriter</tt>.
+     * Writes the extra attributes of the given {@link ExtendableItem} to the given
+     * <tt>PrintWriter</tt>.
      * 
-     * @param item the {@link ExtendableItem}, cannot be <tt>null</tt>
-     * @param out the writer to use
-     * @param prefix the string to write before writing the attributes (if any)
+     * @param item
+     *            the {@link ExtendableItem}, cannot be <tt>null</tt>
+     * @param out
+     *            the writer to use
+     * @param prefix
+     *            the string to write before writing the attributes (if any)
      */
     private static void printExtraAttributes(ExtendableItem item, PrintWriter out, String prefix) {
         printExtraAttributes(item.getQualifiedExtraAttributes(), out, prefix);
     }
 
     /**
-     * Writes the specified <tt>Map</tt> containing the extra attributes to the
-     * given <tt>PrintWriter</tt>.
+     * Writes the specified <tt>Map</tt> containing the extra attributes to the given
+     * <tt>PrintWriter</tt>.
      * 
-     * @param extra the extra attributes, can be <tt>null</tt>
-     * @param out the writer to use
-     * @param prefix the string to write before writing the attributes (if any)
+     * @param extra
+     *            the extra attributes, can be <tt>null</tt>
+     * @param out
+     *            the writer to use
+     * @param prefix
+     *            the string to write before writing the attributes (if any)
      */
     private static void printExtraAttributes(Map extra, PrintWriter out, String prefix) {
         if (extra == null) {
             return;
         }
-        
+
         String delim = prefix;
         for (Iterator iter = extra.entrySet().iterator(); iter.hasNext();) {
             Map.Entry entry = (Map.Entry) iter.next();
-            out.print(delim + entry.getKey() + "=\"" 
-                + XMLHelper.escape(entry.getValue().toString()) + "\"");
+            out.print(delim + entry.getKey() + "=\""
+                    + XMLHelper.escape(entry.getValue().toString()) + "\"");
             delim = " ";
         }
     }
@@ -405,15 +403,13 @@ public final class XmlModuleDescriptorWr
             out.println("\t</configurations>");
         }
     }
-    
+
     protected static void printConfiguration(Configuration conf, PrintWriter out) {
         out.print("<conf");
         out.print(" name=\"" + XMLHelper.escape(conf.getName()) + "\"");
-        out.print(" visibility=\"" 
-            + XMLHelper.escape(conf.getVisibility().toString()) + "\"");
+        out.print(" visibility=\"" + XMLHelper.escape(conf.getVisibility().toString()) + "\"");
         if (conf.getDescription() != null) {
-            out.print(" description=\"" 
-                + XMLHelper.escape(conf.getDescription()) + "\"");
+            out.print(" description=\"" + XMLHelper.escape(conf.getDescription()) + "\"");
         }
         String[] exts = conf.getExtends();
         if (exts.length > 0) {
@@ -437,9 +433,8 @@ public final class XmlModuleDescriptorWr
     }
 
     private static void printInfoTag(ModuleDescriptor md, PrintWriter out) {
-        out.println("\t<info organisation=\"" 
-            + XMLHelper.escape(md.getModuleRevisionId().getOrganisation())
-                + "\"");
+        out.println("\t<info organisation=\""
+                + XMLHelper.escape(md.getModuleRevisionId().getOrganisation()) + "\"");
         out.println("\t\tmodule=\"" + XMLHelper.escape(md.getModuleRevisionId().getName()) + "\"");
         String branch = md.getResolvedModuleRevisionId().getBranch();
         if (branch != null) {
@@ -450,16 +445,15 @@ public final class XmlModuleDescriptorWr
             out.println("\t\trevision=\"" + XMLHelper.escape(revision) + "\"");
         }
         out.println("\t\tstatus=\"" + XMLHelper.escape(md.getStatus()) + "\"");
-        out.println("\t\tpublication=\""
-                + DateUtil.format(md.getResolvedPublicationDate()) + "\"");
+        out.println("\t\tpublication=\"" + DateUtil.format(md.getResolvedPublicationDate()) + "\"");
         if (md.isDefault()) {
             out.println("\t\tdefault=\"true\"");
         }
         if (md instanceof DefaultModuleDescriptor) {
             DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
             if (dmd.getNamespace() != null && !dmd.getNamespace().getName().equals("system")) {
-                out.println("\t\tnamespace=\"" 
-                    + XMLHelper.escape(dmd.getNamespace().getName()) + "\"");
+                out.println("\t\tnamespace=\"" + XMLHelper.escape(dmd.getNamespace().getName())
+                        + "\"");
             }
         }
         if (!md.getExtraAttributes().isEmpty()) {
@@ -472,8 +466,8 @@ public final class XmlModuleDescriptorWr
             for (int i = 0; i < parents.length; i++) {
                 ExtendsDescriptor parent = parents[i];
                 ModuleRevisionId mrid = parent.getParentRevisionId();
-                out.print("\t\t<extends organisation=\"" + XMLHelper.escape(mrid.getOrganisation()) + "\""
-                        + " module=\"" + XMLHelper.escape(mrid.getName()) + "\""
+                out.print("\t\t<extends organisation=\"" + XMLHelper.escape(mrid.getOrganisation())
+                        + "\"" + " module=\"" + XMLHelper.escape(mrid.getName()) + "\""
                         + " revision=\"" + XMLHelper.escape(mrid.getRevision()) + "\"");
 
                 String location = parent.getLocation();
@@ -513,11 +507,11 @@ public final class XmlModuleDescriptorWr
             }
             out.println("\t</info>");
         } else {
-            out.println("\t/>");            
+            out.println("\t/>");
         }
 
     }
-    
+
     private static void printExtraInfoElement(PrintWriter out, ExtraInfoHolder extraInfo, int indent) {
         for (int i = 1; i <= indent; i++) {
             out.print("\t");
@@ -559,12 +553,10 @@ public final class XmlModuleDescriptorWr
     }
 
     private static boolean requireInnerInfoElement(ModuleDescriptor md) {
-        return md.getExtraInfo().size() > 0 
-                || md.getExtraInfos().size() > 0
-                || md.getHomePage() != null 
-                || (md.getDescription() != null && md.getDescription().trim().length() > 0) 
-                || md.getLicenses().length > 0
-                || md.getInheritedDescriptors().length > 0;
+        return md.getExtraInfo().size() > 0 || md.getExtraInfos().size() > 0
+                || md.getHomePage() != null
+                || (md.getDescription() != null && md.getDescription().trim().length() > 0)
+                || md.getLicenses().length > 0 || md.getInheritedDescriptors().length > 0;
     }
 
     private static String getConfs(ModuleDescriptor md, Artifact artifact) {

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/LogReportOutputter.java Tue Jan 14 08:27:37 2014
@@ -44,8 +44,7 @@ public class LogReportOutputter implemen
         return CONSOLE;
     }
 
-    public void output(
-            ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options) 
+    public void output(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options)
             throws IOException {
         IvySettings settings = IvyContext.getContext().getSettings();
 
@@ -63,15 +62,13 @@ public class LogReportOutputter implemen
                     List nodeConfs = new ArrayList(confs.length);
                     for (int j = 0; j < confs.length; j++) {
                         String conf = confs[j];
-                        if (report.getConfigurationReport(conf).getModuleRevisionIds().contains(
-                            node.getResolvedId())) {
+                        if (report.getConfigurationReport(conf).getModuleRevisionIds()
+                                .contains(node.getResolvedId())) {
                             nodeConfs.add(conf);
                         }
                     }
-                    Message
-                            .info("\t" + node + " from "
-                                    + node.getModuleRevision().getResolver().getName() + " in "
-                                    + nodeConfs);
+                    Message.info("\t" + node + " from "
+                            + node.getModuleRevision().getResolver().getName() + " in " + nodeConfs);
                 }
             }
         }
@@ -105,7 +102,7 @@ public class LogReportOutputter implemen
         }
 
         if (ResolveOptions.LOG_DEFAULT.equals(options.getLog())) {
-            //CheckStyle:MagicNumber| OFF
+            // CheckStyle:MagicNumber| OFF
             char[] sep = new char[69];
             Arrays.fill(sep, '-');
             Message.rawinfo("\t" + new String(sep));
@@ -116,7 +113,7 @@ public class LogReportOutputter implemen
             append(line, "artifacts", 15);
             line.append("|");
             Message.rawinfo(line.toString());
-    
+
             line = new StringBuffer("\t");
             append(line, "conf", 18);
             append(line, "number", 7);
@@ -126,11 +123,11 @@ public class LogReportOutputter implemen
             line.append("|");
             append(line, "number", 7);
             append(line, "dwnlded", 7);
-            //CheckStyle:MagicNumber| ON
+            // CheckStyle:MagicNumber| ON
             line.append("|");
             Message.rawinfo(line.toString());
             Message.rawinfo("\t" + new String(sep));
-    
+
             String[] confs = report.getConfigurations();
             for (int i = 0; i < confs.length; i++) {
                 output(report.getConfigurationReport(confs[i]));
@@ -168,7 +165,7 @@ public class LogReportOutputter implemen
 
     public void output(ConfigurationResolveReport report) {
         StringBuffer line = new StringBuffer("\t");
-        //CheckStyle:MagicNumber| OFF
+        // CheckStyle:MagicNumber| OFF
         append(line, report.getConfiguration(), 18);
         append(line, String.valueOf(report.getNodesNumber()), 7);
         append(line, String.valueOf(report.getSearchedNodes().length), 7);
@@ -177,7 +174,7 @@ public class LogReportOutputter implemen
         line.append("|");
         append(line, String.valueOf(report.getArtifactsNumber()), 7);
         append(line, String.valueOf(report.getDownloadedArtifactsReports().length), 7);
-        //CheckStyle:MagicNumber| ON
+        // CheckStyle:MagicNumber| ON
         line.append("|");
 
         Message.rawinfo(line.toString());

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ReportOutputter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ReportOutputter.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ReportOutputter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/ReportOutputter.java Tue Jan 14 08:27:37 2014
@@ -31,9 +31,8 @@ public interface ReportOutputter {
 
     public static final String XML = "xml";
 
-    public abstract void output(
-            ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options) 
-            throws IOException;
+    public abstract void output(ResolveReport report, ResolutionCacheManager cacheMgr,
+            ResolveOptions options) throws IOException;
 
     public abstract String getName();
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportOutputter.java Tue Jan 14 08:27:37 2014
@@ -35,13 +35,12 @@ import org.apache.ivy.util.Message;
  */
 public class XmlReportOutputter implements ReportOutputter {
     private XmlReportWriter writer = new XmlReportWriter();
-    
+
     public String getName() {
         return XML;
     }
 
-    public void output(
-            ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options) 
+    public void output(ResolveReport report, ResolutionCacheManager cacheMgr, ResolveOptions options)
             throws IOException {
         String[] confs = report.getConfigurations();
         for (int i = 0; i < confs.length; i++) {
@@ -49,29 +48,28 @@ public class XmlReportOutputter implemen
         }
     }
 
-    public void output(ConfigurationResolveReport report, String resolveId, 
-            String[] confs, ResolutionCacheManager cacheMgr) 
-            throws IOException {
-        File reportFile = cacheMgr.getConfigurationResolveReportInCache(
-            resolveId, report.getConfiguration());
+    public void output(ConfigurationResolveReport report, String resolveId, String[] confs,
+            ResolutionCacheManager cacheMgr) throws IOException {
+        File reportFile = cacheMgr.getConfigurationResolveReportInCache(resolveId,
+            report.getConfiguration());
         File reportParentDir = reportFile.getParentFile();
         reportParentDir.mkdirs();
         OutputStream stream = new FileOutputStream(reportFile);
         writer.output(report, confs, stream);
         stream.close();
 
-        Message.verbose("\treport for " + report.getModuleDescriptor().getModuleRevisionId()
-            + " " + report.getConfiguration() + " produced in " + reportFile);
+        Message.verbose("\treport for " + report.getModuleDescriptor().getModuleRevisionId() + " "
+                + report.getConfiguration() + " produced in " + reportFile);
 
         File reportXsl = new File(reportParentDir, "ivy-report.xsl");
         File reportCss = new File(reportParentDir, "ivy-report.css");
         if (!reportXsl.exists()) {
-            FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.xsl"), reportXsl,
-                null);
+            FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.xsl"),
+                reportXsl, null);
         }
         if (!reportCss.exists()) {
-            FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.css"), reportCss,
-                null);
+            FileUtil.copy(XmlReportOutputter.class.getResourceAsStream("ivy-report.css"),
+                reportCss, null);
         }
     }
 }

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java?rev=1557968&r1=1557967&r2=1557968&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java Tue Jan 14 08:27:37 2014
@@ -91,17 +91,16 @@ public class XmlReportParser {
                         skip = true;
                     } else {
                         revisionsMap.put(new Integer(position), revisionArtifacts);
-                        mrid = ModuleRevisionId.newInstance(organisation, module, branch,
-                            revision, ExtendableItemHelper.getExtraAttributes(attributes,
-                                "extra-"));
+                        mrid = ModuleRevisionId.newInstance(organisation, module, branch, revision,
+                            ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
                         mrids.add(mrid);
                         if (isDefault) {
                             defaultMrids.add(mrid);
                         } else {
-                            Artifact metadataArtifact = 
-                                DefaultArtifact.newIvyArtifact(mrid, pubdate);
-                            MetadataArtifactDownloadReport madr = 
-                                new MetadataArtifactDownloadReport(metadataArtifact);
+                            Artifact metadataArtifact = DefaultArtifact.newIvyArtifact(mrid,
+                                pubdate);
+                            MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(
+                                    metadataArtifact);
                             metadataReports.put(mrid, madr);
                             realMrids.add(mrid);
                         }
@@ -121,11 +120,11 @@ public class XmlReportParser {
                     if (skip) {
                         return;
                     }
-                    MetadataArtifactDownloadReport madr = 
-                        (MetadataArtifactDownloadReport) metadataReports.get(mrid);
+                    MetadataArtifactDownloadReport madr = (MetadataArtifactDownloadReport) metadataReports
+                            .get(mrid);
                     if (madr != null) {
-                        madr.setDownloadStatus(
-                            DownloadStatus.fromString(attributes.getValue("status")));
+                        madr.setDownloadStatus(DownloadStatus.fromString(attributes
+                                .getValue("status")));
                         madr.setDownloadDetails(attributes.getValue("details"));
                         madr.setSize(Long.parseLong(attributes.getValue("size")));
                         madr.setDownloadTimeMillis(Long.parseLong(attributes.getValue("time")));
@@ -134,16 +133,14 @@ public class XmlReportParser {
                             madr.setLocalFile(new File(attributes.getValue("location")));
                         }
                         if (attributes.getValue("original-local-location") != null) {
-                            madr.setOriginalLocalFile(
-                                new File(attributes.getValue("original-local-location")));
+                            madr.setOriginalLocalFile(new File(attributes
+                                    .getValue("original-local-location")));
                         }
                         if (attributes.getValue("origin-location") != null) {
                             if (ArtifactOrigin.isUnknown(attributes.getValue("origin-location"))) {
                                 madr.setArtifactOrigin(ArtifactOrigin.unkwnown(madr.getArtifact()));
                             } else {
-                                madr.setArtifactOrigin(
-                                    new ArtifactOrigin(
-                                        madr.getArtifact(),
+                                madr.setArtifactOrigin(new ArtifactOrigin(madr.getArtifact(),
                                         parseBoolean(attributes.getValue("origin-is-local")),
                                         attributes.getValue("origin-location")));
                             }
@@ -157,9 +154,8 @@ public class XmlReportParser {
                     String artifactName = attributes.getValue("name");
                     String type = attributes.getValue("type");
                     String ext = attributes.getValue("ext");
-                    Artifact artifact = new DefaultArtifact(mrid, pubdate, artifactName,
-                            type, ext, ExtendableItemHelper.getExtraAttributes(attributes,
-                                "extra-"));
+                    Artifact artifact = new DefaultArtifact(mrid, pubdate, artifactName, type, ext,
+                            ExtendableItemHelper.getExtraAttributes(attributes, "extra-"));
                     ArtifactDownloadReport aReport = new ArtifactDownloadReport(artifact);
                     aReport.setDownloadStatus(DownloadStatus.fromString(status));
                     aReport.setDownloadDetails(attributes.getValue("details"));
@@ -169,25 +165,22 @@ public class XmlReportParser {
                         aReport.setLocalFile(new File(attributes.getValue("location")));
                     }
                     if (attributes.getValue("unpackedFile") != null) {
-                        aReport.setUnpackedLocalFile(new File(attributes
-                                .getValue("unpackedFile")));
+                        aReport.setUnpackedLocalFile(new File(attributes.getValue("unpackedFile")));
                     }
                     revisionArtifacts.add(aReport);
                 } else if ("origin-location".equals(qName)) {
                     if (skip) {
                         return;
                     }
-                    ArtifactDownloadReport aReport = (ArtifactDownloadReport) 
-                        revisionArtifacts.get(revisionArtifacts.size() - 1);
-                    
+                    ArtifactDownloadReport aReport = (ArtifactDownloadReport) revisionArtifacts
+                            .get(revisionArtifacts.size() - 1);
+
                     if (ArtifactOrigin.isUnknown(attributes.getValue("location"))) {
                         aReport.setArtifactOrigin(ArtifactOrigin.unkwnown(aReport.getArtifact()));
                     } else {
-                        aReport.setArtifactOrigin(
-                            new ArtifactOrigin(
-                                aReport.getArtifact(),
-                                parseBoolean(attributes.getValue("is-local")),
-                                attributes.getValue("location")));
+                        aReport.setArtifactOrigin(new ArtifactOrigin(aReport.getArtifact(),
+                                parseBoolean(attributes.getValue("is-local")), attributes
+                                        .getValue("location")));
                     }
                 } else if ("info".equals(qName)) {
                     String organisation = attributes.getValue("organisation");
@@ -208,8 +201,7 @@ public class XmlReportParser {
                 }
             }
 
-            public void endElement(String uri, String localName, String qname)
-                    throws SAXException {
+            public void endElement(String uri, String localName, String qname) throws SAXException {
                 if ("dependencies".equals(qname)) {
                     // add the artifacts in the correct order
                     for (List<ArtifactDownloadReport> artifactReports : revisionsMap.values()) {
@@ -219,14 +211,15 @@ public class XmlReportParser {
                                 artifacts.add(artifactReport.getArtifact());
                             }
                         }
-                        
+
                     }
                 }
             }
 
             private int getMaxPos() {
-                return revisionsMap.isEmpty() ? -1 : ((Integer) revisionsMap.keySet()
-                        .toArray()[revisionsMap.size() - 1]).intValue();
+                return revisionsMap.isEmpty() ? -1
+                        : ((Integer) revisionsMap.keySet().toArray()[revisionsMap.size() - 1])
+                                .intValue();
             }
         }
 
@@ -247,7 +240,7 @@ public class XmlReportParser {
         private File report;
 
         private boolean hasError = false;
-        
+
         SaxXmlReportParser(File report) {
             this.report = report;
         }
@@ -256,7 +249,7 @@ public class XmlReportParser {
             SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
             saxParser.parse(report, new XmlReportParserHandler());
         }
-        
+
         private static boolean parseBoolean(String str) {
             return (str != null) && str.equalsIgnoreCase("true");
         }