ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs XmlProperty.java
Date Fri, 21 Jun 2002 06:30:30 GMT
stevel      2002/06/20 23:30:30

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        XmlProperty.java
  Log:
  more javadoc updates.
  
  Added some @todos where it seemed appropriate.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +35 -7     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java
  
  Index: XmlProperty.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- XmlProperty.java	20 May 2002 20:28:36 -0000	1.2.2.1
  +++ XmlProperty.java	21 Jun 2002 06:30:30 -0000	1.2.2.2
  @@ -72,21 +72,26 @@
   import java.util.Vector;
   
   /**
  - * Task that gets property values from a valid xml file.
  + * Task that gets property values from a valid xml file,
  + * generating the property names from the file's element and attribute names.
    * Example:
  + * <pre>
    *   &lt;root-tag myattr="true"&gt;
    *     &lt;inner-tag someattr="val"&gt;Text&lt;/inner-tag&gt;
    *     &lt;a2&gt;&lt;a3&gt;&lt;a4&gt;false&lt;/a4&gt;&lt;/a3&gt;&lt;/a2&gt;
    *   &lt;/root-tag&gt;
  - *
  + *</pre>
  + * this generates
  + * <pre>
    *  root-tag(myattr)=true
    *  root-tag.inner-tag=Text
    *  root-tag.inner-tag(someattr)=val
    *  root-tag.a2.a3.a4=false
  - *
  + * </pre>
    * @author <a href="mailto:nicolaken@apache.org">Nicola Ken Barozzi</a>
    * @author Erik Hatcher
    * @created 14 January 2002
  + * @ant.task name="xmlproperty" category="xml"
    */
   
   public class XmlProperty extends org.apache.tools.ant.Task {
  @@ -115,10 +120,12 @@
   
       /**
        * Run the task.
  -     * @exception org.apache.tools.ant.BuildException The exception raised during task
execution.
  +     * @throws BuildException The exception raised during task execution.
  +     * @todo validate the source file is valid before opening, print a better error message
  +     * @todo add a verbose level log message listing the name of the file being loaded
        */
       public void execute()
  -            throws org.apache.tools.ant.BuildException {
  +            throws BuildException {
               
           BufferedInputStream configurationStream = null;
   
  @@ -172,6 +179,9 @@
           }
       }
   
  +    /**
  +     * add all attributes of a node, and its inner text, and then recursively add all nested
elements
  +     */
   
       void addNodeRecursively(org.w3c.dom.Node node, String prefix) {
   
  @@ -186,8 +196,8 @@
                   }
                   else{
                     attributeName = prefix + (prefix.trim().equals("")?"":".") + node.getNodeName()
+ "(" + attributeNode.getNodeName() + ")";
  -		}              
  -		  
  +                }              
  +          
                   String attributeValue = attributeNode.getNodeValue();
                   log(attributeName + ":" + attributeValue, Project.MSG_DEBUG);
                   project.setNewProperty(attributeName, attributeValue);
  @@ -214,22 +224,40 @@
           }
       }
   
  +    /**
  +     * The XML file to parse; required.
  +     */
       public void setFile(File src) {
           this.src = src;
       }
   
  +    /**
  +     * the prefix to prepend to each property
  +     */
       public void setPrefix(String prefix) {
           this.prefix = prefix.trim();
       }
   
  +    /**
  +     * flag to include the xml root tag as a 
  +     * first value in the property name; optional, 
  +     * default is true
  +     */
       public void setKeeproot(boolean keepRoot) {
           this.keepRoot = keepRoot;
       }
   
  +    /**
  +     * flag to validate the XML file; optional, default false
  +     */
       public void setValidate(boolean validate) {
           this.validate = validate;
       }
   
  +    /**
  +     * flag to treat attributes as nested elements;
  +     * optional, default false
  +     */
       public void setCollapseAttributes(boolean collapseAttributes) {
           this.collapseAttributes = collapseAttributes;
       }
  
  
  

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


Mime
View raw message