|
From: Dmitry F. <dim...@gm...> - 2013-01-15 07:28:08
|
Thanks, that is what I need.
Unfortunately I missed this.
2013/1/15 <jz...@xi...>
> check out bookMark, which may be what u are looking for...
>
>
>
> ----- Original Message -----
> From:
> Dmitry Frank <dim...@gm...>
>
> To:
> <vtd...@li...>
> Cc:
>
> Sent:
> Mon, 14 Jan 2013 19:39:29 +0400
> Subject:
> [Vtd-xml-users] Randomly save and restore VTDNav's context
>
>
> Hello.
>
> For my app, it's very convinient to save current context of VTDNav and
> restore it whenever I want
>
> But there's only two ways to save/restore context I know from the docs:
> push()/pop(), and NodeRecorder.
>
> Neither of these ways are convinient for me: I need for really random
> access. Not stack way, like push()/pop(), and no NodeRecorder way. that
> can only iterate saved items node-by-node.
>
> I need to be able to get context as a byte array, and to restore it in the
> same manner.
>
> So, I added the following methods to the VTDNav.java :
>
> /** * Return context that can be restored later by calling
> restoreContext(). * by dfrank. */ public int[] getContext() { int[] ret =
> new int[ stackTemp.length ]; for (int i = 0; i < nestingLevel; i++) { ret[
> i] = context[i]; } ret[nestingLevel] = l1index; ret[nestingLevel + 1] =l2index
> ; ret[nestingLevel + 2] = l3index; ret[nestingLevel + 3] = l2lower; ret[nestingLevel
> + 4] = l2upper; ret[nestingLevel + 5] = l3lower; ret[nestingLevel + 6] =l3upper
> ; if (atTerminal) ret[nestingLevel + 7] =1; else ret[nestingLevel + 7] =0;ret
> [nestingLevel+8] = LN; return ret; } /** * Restore context that was
> returned by getContext(). * by dfrank. */ public boolean restoreContext(
> int[] saved_context) { for (int i = 0; i < nestingLevel; i++) { context[i]
> = saved_context[i]; } l1index = saved_context[nestingLevel]; l2index =saved_context
> [nestingLevel + 1]; l3index = saved_context[nestingLevel + 2]; l2lower =saved_context
> [nestingLevel + 3]; l2upper = saved_context[nestingLevel + 4]; l3lower =saved_context
> [nestingLevel + 5]; l3upper = saved_context[nestingLevel + 6]; atTerminal
> = (saved_context[nestingLevel + 7] == 1); LN = saved_context[nestingLevel+
> 8]; return true; }
>
> These methods work nicely, and they help me a lot to do what I need.
>
> So, questions:
> Why there's no similar methods in the release of VTD-XML? Do them break
> anything, or whatever?
>
>
> --
> Dmitry
>
>
|