I think the current way is better:

If the javadoc was right, code to work on nodes found would be:

Object o=doc.selectObject(//something);
If(o instanceof Node) {
 Big chunk of code to work on Nodes
} Else if (o instanceof List) {
 Same big bunch of code, with a for loop around it.
}...

However, if people normally only get a single Node, the List idea forces the
extra loop even when you know you'll get 1 return, which might be a bit
slower.

I really don't care, just would like the code to match the javadoc, so I
thought I would bring it up.

Jim


Jim Brain, [EMAIL PROTECTED]
"Researching tomorrow's decisions today."
(319) 369-2070 (work)
SYSTEMS ARCHITECT, INDIVIDUAL ITS, LIFE INVESTORS INSURANCE COMPANY OF
AMERICA

 -----Original Message-----
From:   James Strachan [mailto:[EMAIL PROTECTED]] 
Sent:   Monday, December 03, 2001 2:38 PM
To:     Brain, Jim; DOM4J Mailing List (E-mail)
Subject:        Re: [dom4j-user] Issue with dom4j 1.1

From: "Brain, Jim" <[EMAIL PROTECTED]>
> True, but the javadoc for selectObject says that I will either get a
String,
> Number, Node, or List of Nodes.  If there is only one item, why return the
> list?

Ah I understand your issue now. It just happens to return a List purely as
this is how Jaxen has worked up to now.

You're right, its probably better to only return a single Node if the XPath
only matches a single node. Either that or say in the Javadoc that it will
only return a scalar result (Boolean, Number, String) or a List of Nodes.

I don't have a strong opinion either way; which would you prefer?

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to