James,
I for one prefer the List return for selectNodes et al, and the Node return
for selectSingleNode et al.
When calling selectNodes() I usually follow the call with an iteration of
the List contents. If it returned
a List sometimes and a Node at other times I would have to put in
conditional logic to determine
which Object type was returned. I would rather have the deterministic
behaviour and live with the
minor overhead of a loop to process a single element List and not have to
add conditional logic.
Chuck Simpson
[EMAIL PROTECTED]
|--------+-------------------------------------->
| | "James Strachan" |
| | <[EMAIL PROTECTED]>|
| | Sent by: |
| | [EMAIL PROTECTED]|
| | eforge.net |
| | |
| | |
| | 12/03/01 02:38 PM |
| | |
|--------+-------------------------------------->
>--------------------------------------------------------------------------------------------------------------|
|
|
| To: "Brain, Jim" <[EMAIL PROTECTED]>, "DOM4J Mailing List \(E-mail\)"
|
| <[EMAIL PROTECTED]>
|
| cc:
|
| 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
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user