[jdom-interest] Having a ListIterator as child cursor ??
bob mcwhirter
bob at werken.com
Wed Nov 21 18:13:53 PST 2001
It may be sub-optimal, but you can always do something like this.
Element element = getMyElementDamnit();
Element parent = e.getParent();
List children = parent.getContent();
int pos = children.indexOf( element );
ListIterator listIter = children.listIterator( pos );
Ta-da.
-bob
On Thu, 22 Nov 2001, Paul Libbrecht wrote:
>
> Hi JDOMmers,
>
> As mentionned in my earlier mails about events (or recipes), a delicate
> problem with Jdom is to be given an element object and wanting to remove
> that element, to replace it, to remove its neighbour or anything such...
>
> I suggested to have an int getPositionInParent()... maybe this is a bit
> crazy...
> An alternative would be to have method like ListIterator
> getCursorInParentContent() for all the "nodes" object (e.g. those that can
> be added as content) that would return a listIterator positionned at that
> element.
>
> It would still require the children to know their positions and the update
> of such would still require some shifts each time a child-node is added
> (at least as long ArrayList is used, using something like GapVector would
> lower the updates by a good amount, LinkedList would have no problem), but
> it would be way more expressive and directly useful:
>
> to remove: node.getCursorInParentContent().remove()
> to replace: node.getCursorInParentContent().set(newNode)
> // with a subclassing to call setParent
> and so on...
>
> Is this non-reasonnable ??
> Thanks.
>
> Paul
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list