[jdom-interest] CDATA patch
Elliotte Rusty Harold
elharo at metalab.unc.edu
Wed May 15 19:45:11 PDT 2002
I've attached a patch for the CDATA class that accomplishes two things:
1. It adds @throws JavaDoc comments for the IllegalDataException
setText() and append() already throw.
2. It modifies the constructor so it calls setText() rather than setting
the value field directly. This means the constructor verifies its
arguments where it did not previously do so.
I've tested that the code builds and the tests run and the JavaDoc looks
OK.
This doesn't change any method signatures, and shouldn't cause problems
for anyone unless they're doing something really weird with CDATA
sections that they really shouldn't be doing in the first place. This
does close off a loophole that allowed CDATA sections to be malformed
(though only if the text was provided via the constructor rather than
setText() and append()) All I've done is make sure the constructor does
the same check as setText().
Side note: is there any standard three-letter extension for patch files?
I've just been using .txt.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (IDG Books, 2001) |
| http://www.cafeconleche.org/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
-------------- next part --------------
Index: src/java/org/jdom/CDATA.java
===================================================================
RCS file: /home/cvspublic/jdom/src/java/org/jdom/CDATA.java,v
retrieving revision 1.24
diff -d -u -r1.24 CDATA.java
--- src/java/org/jdom/CDATA.java 2002/04/29 13:38:15 1.24
+++ src/java/org/jdom/CDATA.java 2002/05/16 10:50:57
@@ -89,15 +89,23 @@
* supplied string value as it's character content.
*
* @param str the node's character content.
+ * @throws IllegalDataException if <code>str</code> contains an
+ * illegal character such as a vertical tab (as determined
+ * by {@link org.jdom.Verifier#checkCharacterData})
+ * or the CDATA end delimiter <code>]]></code>.
*/
public CDATA(String str) {
- super(str);
+ setText(str);
}
/**
* This will set the value of this <code>CDATA</code> node.
*
* @param str value for node's content.
+ * @throws IllegalDataException if <code>str</code> contains an
+ * illegal character such as a vertical tab (as determined
+ * by {@link org.jdom.Verifier#checkCharacterData})
+ * or the CDATA end delimiter <code>]]></code>.
*/
public Text setText(String str) {
// Overrides Text.setText() because this needs to check CDATA
@@ -123,6 +131,10 @@
* exists within this <code>CDATA</code> node.
*
* @param str character content to append.
+ * @throws IllegalDataException if <code>str</code> contains an
+ * illegal character such as a vertical tab (as determined
+ * by {@link org.jdom.Verifier#checkCharacterData})
+ * or the CDATA end delimiter <code>]]></code>.
*/
public void append(String str) {
// Overrides Text.setText() because this needs to check CDATA
More information about the jdom-interest
mailing list