commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Orlov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JXPATH-134) NodeIterator usage in AttributeContext
Date Wed, 03 Mar 2010 20:04:27 GMT

    [ https://issues.apache.org/jira/browse/JXPATH-134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12840846#action_12840846
] 

Vladimir Orlov commented on JXPATH-134:
---------------------------------------

Hello, Matt.
In general I would change the interface of the NodeIterator: there are two much obscurity
around it and this is why its implementations may differ so far in the behavioral contract
they provide. 

Another option is to introduce boolean state flag method for the NodeIterator instead of returning
the same boolean value as result of setPosition() method call. I mean something like boolean
NodePointer.isInRange().

And the most easiest one that does the fix for this particular case only. It definitely dumb
but has to work.

if (!iterator.setPosition(iterator.getPosition())) { return false; }


> NodeIterator usage in AttributeContext
> --------------------------------------
>
>                 Key: JXPATH-134
>                 URL: https://issues.apache.org/jira/browse/JXPATH-134
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: JDK 1.5.0_12
>            Reporter: Vladimir Orlov
>
> There is the following piece of code in AttributeContext class, nextNode() method:
>         if (!iterator.setPosition(iterator.getPosition() + 1)) {
>             return false;
>         }
> It implies that the following precondition is satisfied in the NodeIterator implementation:
in its initial state NodeIterator implementation has the position set in 0 when the first
position index is actually 1. At the same time NodeIterator interface implies that the client
code should call the setPosition() method of the NodeIterator first and only after that it
can call the getPosition()  or getNodePointer(). There is no any information about such a
strange condition to satisfy for the NodeIterator implementation in the Javadoc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message