[jdom-interest] Element.addContent(CDATA cdata)
Elliotte Rusty Harold
elharo at metalab.unc.edu
Fri Jul 19 06:23:43 PDT 2002
At 12:11 PM +0900 7/19/02, Xuemin Guan wrote:
>The JDOM 0.9 has deprecated the addContent(CDATA cdata) method of
>Element. But the online Java doc does not reflect this. I looked into
>the source code, and found a comment said addContent(Text text)
>method is the reason to deprecate it.
>
The online JavaDoc is out of date with respect to CVS. It ocvers
beta-8. CVS has the latest code that will become beta-9.
>I wonder how I should do if I have have CDATA object and want to add
>it to an Element.
>
In CVS, CDATA has become a subclass of Text, so addContent(Text text)
works for CDATA sections too. That said, I wonder if we shouldn't
just remove that method now rather than giving it the usual one-beta
deprecation cycle. I don't think removing it immediately would not
break anybody's existing code; certainly not at the source level. At
the compile byte code level, would it be a problem? i.e. if somebody
had compiled code that called addContent(CDATA cdata) and loaded a
new version of JDOM without that method, would their code break? i.e.
how tightly does Java link?
There's really no good way an end user can avoid the deprecation
message on addContent(CDATA cdata) as long as it's there, because
the compiler will still pick it. The replacement method has the same
name. You could always cast the CDATA to a Text, but that's a
pointless operation just to get rid of a deprecation message. This is
a slightly unusual situation.
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| XML in a Nutshell, 2nd Edition (O'Reilly, 2002) |
| http://www.cafeconleche.org/books/xian2/ |
| http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list