ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/proposal/sandbox/svn/src/main/org/apache/tools/ant/taskdefs/svn SvnChangeLogWriter.java
Date Tue, 15 Mar 2005 14:05:46 GMT
bodewig     2005/03/15 06:05:46

  Modified:    proposal/sandbox/svn/src/main/org/apache/tools/ant/taskdefs/svn
                        SvnChangeLogWriter.java
  Log:
  Use DOMUtils
  
  Revision  Changes    Path
  1.4       +13 -46    ant/proposal/sandbox/svn/src/main/org/apache/tools/ant/taskdefs/svn/SvnChangeLogWriter.java
  
  Index: SvnChangeLogWriter.java
  ===================================================================
  RCS file: /home/cvs/ant/proposal/sandbox/svn/src/main/org/apache/tools/ant/taskdefs/svn/SvnChangeLogWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SvnChangeLogWriter.java	14 Mar 2005 20:08:55 -0000	1.3
  +++ SvnChangeLogWriter.java	15 Mar 2005 14:05:46 -0000	1.4
  @@ -22,12 +22,10 @@
   import javax.xml.parsers.DocumentBuilder;
   
   import org.apache.tools.ant.util.DOMElementWriter;
  -import org.apache.tools.ant.util.JAXPUtils;
  +import org.apache.tools.ant.util.DOMUtils;
   
  -import org.w3c.dom.CDATASection;
   import org.w3c.dom.Document;
   import org.w3c.dom.Element;
  -import org.w3c.dom.Text;
   
   /**
    * Class used to generate an XML changelog.
  @@ -51,7 +49,7 @@
       public void printChangeLog(final PrintWriter output,
                                  final SvnEntry[] entries) throws IOException {
           output.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  -        Document doc = JAXPUtils.getDocumentBuilder().newDocument();
  +        Document doc = DOMUtils.newDocument();
           Element root = doc.createElement("changelog");
           DOM_WRITER.openElement(root, output, 0, "\t");
           output.println();
  @@ -77,53 +75,22 @@
           Document doc = element.getOwnerDocument();
   
           Element ent = doc.createElement("entry");
  -        appendTextElement(ent, "date", OUTPUT_DATE.format(entry.getDate()));
  -        appendTextElement(ent, "time", OUTPUT_TIME.format(entry.getDate()));
  -        appendCDATAElement(ent, "author", entry.getAuthor());
  -        appendTextElement(ent, "revision", entry.getRevision());
  +        DOMUtils.appendTextElement(ent, "date",
  +                                   OUTPUT_DATE.format(entry.getDate()));
  +        DOMUtils.appendTextElement(ent, "time",
  +                                   OUTPUT_TIME.format(entry.getDate()));
  +        DOMUtils.appendCDATAElement(ent, "author", entry.getAuthor());
  +        DOMUtils.appendTextElement(ent, "revision", entry.getRevision());
   
           SvnEntry.Path[] paths = entry.getPaths();
           for (int i = 0; i < paths.length; i++) {
  -            Element path = doc.createElement("path");
  -            ent.appendChild(path);
  -            appendCDATAElement(path, "name", paths[i].getName());
  -            appendTextElement(path, "action", paths[i].getActionDescription());
  +            Element path = DOMUtils.createChildElement(ent, "path");
  +            DOMUtils.appendCDATAElement(path, "name", paths[i].getName());
  +            DOMUtils.appendTextElement(path, "action",
  +                                       paths[i].getActionDescription());
           }
  -        appendCDATAElement(ent, "message", entry.getMessage());
  +        DOMUtils.appendCDATAElement(ent, "message", entry.getMessage());
           DOM_WRITER.write(ent, output, 1, "\t");
       }
  -
  -    /**
  -     * Creates a named element with nested text as child of the given element.
  -     *
  -     * @param parent the parent element
  -     * @param name name of the child element
  -     * @param content the content of the nested text
  -     */
  -    private static void appendTextElement(Element parent, String name,
  -                                          String content) {
  -        Document doc = parent.getOwnerDocument();
  -        Element e = doc.createElement(name);
  -        parent.appendChild(e);
  -        Text t = doc.createTextNode(content);
  -        e.appendChild(t);
  -    }
  -
  -    /**
  -     * Creates a named element with a nested CDATA section as child of
  -     * the given element.
  -     *
  -     * @param parent the parent element
  -     * @param name name of the child element
  -     * @param content the content of the nested text
  -     */
  -    private static void appendCDATAElement(Element parent, String name,
  -                                           String content) {
  -        Document doc = parent.getOwnerDocument();
  -        Element e = doc.createElement(name);
  -        parent.appendChild(e);
  -        CDATASection c  = doc.createCDATASection(content);
  -        e.appendChild(c);
  -    }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message