[jdom-interest] Element instanceof stacks
Elliotte Rusty Harold
elharo at metalab.unc.edu
Fri Apr 19 13:26:26 PDT 2002
I found some more places where we can delete code now that CDATA is a
subclass of Text. In Element.java in line 546 I think we can change
if (obj instanceof Text) {
return ((Text) obj).getText();
} else if (obj instanceof CDATA) {
return ((CDATA) obj).getText();
} else {
return "";
}
to
if (obj instanceof Text) {
return ((Text) obj).getText();
} else {
return "";
}
A little later at line 561 we can change
if (obj instanceof Text) {
textContent.append(((Text) obj).getText());
hasText = true;
} else if (obj instanceof CDATA) {
textContent.append(((CDATA) obj).getText());
hasText = true;
}
to
if (obj instanceof Text) {
textContent.append(((Text) obj).getText());
hasText = true;
}
Along similar lines I think we can delete the following methods in Element:
public Element *addContent(*CDATA cdata)
public boolean *removeContent(*CDATA cdata)
Since these will both be replaced by their Text equivalents, I don't
think we'll break anybody's code if we don't deprecate first. The net
effect should be a small simplification to the Element class.
--
+-----------------------+------------------------+-------------------+
| 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/ |
+----------------------------------+---------------------------------+
More information about the jdom-interest
mailing list