diff options
author | frsyuki <frsyuki@users.sourceforge.jp> | 2009-10-25 02:41:55 +0900 |
---|---|---|
committer | frsyuki <frsyuki@users.sourceforge.jp> | 2009-10-25 02:41:55 +0900 |
commit | d39c016e1d84765a50ae3c7cbfc3d6869faa9c07 (patch) | |
tree | 169ca4fb6fcfb6c40d33ae9bf4afa7e9e46209ec /java-plan1/Unpacker.java | |
parent | 5393a0df16f3bbdf296222b6337db5d57fe7c3a6 (diff) | |
download | msgpack-python-d39c016e1d84765a50ae3c7cbfc3d6869faa9c07.tar.gz |
java: fix streaming de/serializer
Diffstat (limited to 'java-plan1/Unpacker.java')
-rw-r--r-- | java-plan1/Unpacker.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/java-plan1/Unpacker.java b/java-plan1/Unpacker.java index be86344..32945de 100644 --- a/java-plan1/Unpacker.java +++ b/java-plan1/Unpacker.java @@ -50,13 +50,26 @@ public class Unpacker { return finished; } + public void reset() + { + for(int i=0; i <= top; ++top) { + stack_ct[top] = 0; + stack_count[top] = 0; + stack_obj[top] = null; + stack_map_key[top] = null; + } + cs = CS_HEADER; + trail = 0; + top = -1; + finished = false; + } @SuppressWarnings("unchecked") public int execute(byte[] src, int off, int length) throws IOException { if(off >= length) { return off; } - int limit = off + length; + int limit = length; int i = off; int count; @@ -64,7 +77,7 @@ public class Unpacker { _out: do { _header_again: { - //System.out.println("while i:"+i); + //System.out.println("while i:"+i+" limit:"+limit); int b = src[i]; @@ -349,6 +362,7 @@ public class Unpacker { ((ArrayList)(stack_obj[top])).add(obj); if(--stack_count[top] == 0) { obj = stack_obj[top]; + stack_obj[top] = null; --top; break _push; } @@ -363,6 +377,8 @@ public class Unpacker { ((HashMap)(stack_obj[top])).put(stack_map_key[top], obj); if(--stack_count[top] == 0) { obj = stack_obj[top]; + stack_map_key[top] = null; + stack_obj[top] = null; --top; break _push; } @@ -379,7 +395,7 @@ public class Unpacker { ++i; } while(i < limit); // _out - return i - off; + return i; } } |