public String getDisplayName() {
String name = getTagName();
// Is there only one attribute?
if (getAttributes().getLength() == 1) {
DOMNode onlyNode = getAttributes().item(0);
// Display the only attribute
name += ": " + onlyNode.getNodeValue();
} else {
// Display one of these attributes
// if they are present.
final String[] DISPLAY_ATTRIBUTES =
{
"name",
"id",
"property"
};
for(int i = 0; i < DISPLAY_ATTRIBUTES.length; i++) {
DOMNode testNode =
getAttributes().getNamedItem(DISPLAY_ATTRIBUTES[i]);
if (testNode != null) {
name += ": " + testNode.getNodeValue();
break;
}
}
}