Hi Mike
 
Thanks for spotting the String[] bug, I've fixed that now,
 
I agree about making the getNodeName() public, though I've called it getNodeTypeName() which I think is more accurate. DOM uses the getNodeName() method to indicate the name of an element or attribute, rather than "Element" or "Attribute".
 
I can see getNodeTypeName() as a useful alternative to getNodeType(). The former returns a String literal which is an Object so works well with Java collections (and Map) as well as debugging, whereas the latter is useful for doing fast switch() statements when tree walking.
 
I added the MAX_NODE_TYPE variable too.
 
Finally I added a JUnit test case to ensure all this getNodeType() and getNodeTypeName() stuff works.
 
I should have checked in all these changes by the time you get this email.
 
James
----- Original Message -----
Sent: Friday, June 08, 2001 8:02 AM
Subject: [dom4j-dev] Node.getNodeName()

3 issues

  1. the current implementation in AbstractNode is protected, it would be useful to make it public, and to put the getNodeName into the Node interface
  2. the String[] in AbstractNode has incorrect values. I think that the values in NODE_TYPE_NAMES should be

    "Node", "Element", "Attribute", "Text", "CDATA", "Entity", "", “Processing Instruction",
    "Comment", "Document", "Document Type","","","Namespace","Unknown"
  3. It would be useful to have a Node.MAX_NODE_TYPE for sizing purposes

 

Mike Skells

 

Reply via email to