You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2002/06/21 08:30:30 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs XmlProperty.java
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>
* <root-tag myattr="true">
* <inner-tag someattr="val">Text</inner-tag>
* <a2><a3><a4>false</a4></a3></a2>
* </root-tag>
- *
+ *</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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>