[jdom-interest] RE: Redundance in getAttributeType() and setAttributeType()

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue May 7 00:55:57 PDT 2002


Hi,

 > The following two methods in Attribute strike me as redundantly named:
 >
 > public int *getAttributeType*()
 > public Attribute *setAttributeType*(int type)
 >
 > There's no need to repeat the classname here. We don't use
 > setElementText() and getElementText() in Element or setTextValue() and
 > getTextValue() in Text. In Attribute itself we say setName() and
 > getName(), not setAttributeName() and getAttributeName().

Indeed, these names look weird... until you knwo the whole story!

Here it is: I've been trying for months to convince Jason that JDOM needs a 
Node interface. In my (many) proposals, this interface defines a getType 
method that would return the node type as an interger value, as a replacement 
of the instanceof tests when one needs to access class specific features.
When I started working on attribute type support, I realized a getType method 
would conflict with the one defined by the Node interface.
Thus I renamed getType to getNodeType in the Node proposal and choose 
getAttributeType for Attribute.

The same applies to the naming scheme of the attribute type constants: As both 
Node and Attribute have a CDATA type, the constants were suffixed with 
_ATTRIBUTE for the attribute types (CDATA_ATTRIBUTE) and _NODE for the node 
types (CDATA_NODE).

Jason may be able to give you a status on whether there will ever be a Node 
interface and whether it will include a get(Node)Type method. I do not know!

Now that you know the whole story, you can wisely choose whether to rename 
these methods and constants.

Laurent




More information about the jdom-interest mailing list