jrjackson 0.3.9-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.__jrubyrc +433 -0
  3. data/.gitignore +10 -0
  4. data/.mvn/extensions.xml +8 -0
  5. data/Gemfile +10 -0
  6. data/Mavenfile +32 -0
  7. data/README.md +150 -0
  8. data/Rakefile +10 -0
  9. data/alt_bench.rb +46 -0
  10. data/changelog.md +131 -0
  11. data/jrjackson.gemspec +32 -0
  12. data/lib/com/fasterxml/jackson/core/jackson-annotations/2.7.1/jackson-annotations-2.7.1.jar +0 -0
  13. data/lib/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar +0 -0
  14. data/lib/com/fasterxml/jackson/core/jackson-databind/2.7.1/jackson-databind-2.7.1.jar +0 -0
  15. data/lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.6.3/jackson-module-afterburner-2.6.3.jar +0 -0
  16. data/lib/com/fasterxml/jackson/module/jackson-module-afterburner/2.7.1/jackson-module-afterburner-2.7.1.jar +0 -0
  17. data/lib/jrjackson.rb +2 -0
  18. data/lib/jrjackson/build_info.rb +15 -0
  19. data/lib/jrjackson/jars/jrjackson-1.2.18.jar +0 -0
  20. data/lib/jrjackson/jars/jrjackson-1.2.7.jar +0 -0
  21. data/lib/jrjackson/jrjackson.rb +94 -0
  22. data/lib/jrjackson_jars.rb +7 -0
  23. data/lib/require_relative_patch.rb +6 -0
  24. data/pom.xml +193 -0
  25. data/profiling/profiled.rb +15 -0
  26. data/run_all_individual_bench.sh +25 -0
  27. data/run_jruby_individual_bench.sh +20 -0
  28. data/run_mri_individual_bench.sh +7 -0
  29. data/src/main/java/com/jrjackson/IParseHandler.java +53 -0
  30. data/src/main/java/com/jrjackson/JavaBigDecimalValueConverter.java +17 -0
  31. data/src/main/java/com/jrjackson/JavaBigIntValueConverter.java +17 -0
  32. data/src/main/java/com/jrjackson/JavaConverter.java +10 -0
  33. data/src/main/java/com/jrjackson/JavaFloatValueConverter.java +16 -0
  34. data/src/main/java/com/jrjackson/JavaHandler.java +118 -0
  35. data/src/main/java/com/jrjackson/JavaLongValueConverter.java +16 -0
  36. data/src/main/java/com/jrjackson/JjParse.java +147 -0
  37. data/src/main/java/com/jrjackson/JrJacksonBase.java +152 -0
  38. data/src/main/java/com/jrjackson/JrJacksonJava.java +81 -0
  39. data/src/main/java/com/jrjackson/JrJacksonRaw.java +108 -0
  40. data/src/main/java/com/jrjackson/JrJacksonRuby.java +89 -0
  41. data/src/main/java/com/jrjackson/JrJacksonSaj.java +26 -0
  42. data/src/main/java/com/jrjackson/JrJacksonSch.java +25 -0
  43. data/src/main/java/com/jrjackson/JrJacksonService.java +38 -0
  44. data/src/main/java/com/jrjackson/JrParse.java +149 -0
  45. data/src/main/java/com/jrjackson/ParseError.java +16 -0
  46. data/src/main/java/com/jrjackson/RubyAnySerializer.java +254 -0
  47. data/src/main/java/com/jrjackson/RubyBigDecimalValueConverter.java +18 -0
  48. data/src/main/java/com/jrjackson/RubyBigIntValueConverter.java +21 -0
  49. data/src/main/java/com/jrjackson/RubyConverter.java +12 -0
  50. data/src/main/java/com/jrjackson/RubyDateFormat.java +34 -0
  51. data/src/main/java/com/jrjackson/RubyFloatValueConverter.java +18 -0
  52. data/src/main/java/com/jrjackson/RubyHandler.java +119 -0
  53. data/src/main/java/com/jrjackson/RubyIntValueConverter.java +18 -0
  54. data/src/main/java/com/jrjackson/RubyJacksonModule.java +72 -0
  55. data/src/main/java/com/jrjackson/RubyKeyConverter.java +12 -0
  56. data/src/main/java/com/jrjackson/RubyNameConverter.java +9 -0
  57. data/src/main/java/com/jrjackson/RubyObjectDeserializer.java +182 -0
  58. data/src/main/java/com/jrjackson/RubyStringConverter.java +18 -0
  59. data/src/main/java/com/jrjackson/RubyStringKeyConverter.java +15 -0
  60. data/src/main/java/com/jrjackson/RubyStringNameConverter.java +12 -0
  61. data/src/main/java/com/jrjackson/RubySymbolKeyConverter.java +15 -0
  62. data/src/main/java/com/jrjackson/RubySymbolNameConverter.java +12 -0
  63. data/src/main/java/com/jrjackson/RubyUtils.java +150 -0
  64. data/src/main/java/com/jrjackson/SajParse.java +169 -0
  65. data/src/main/java/com/jrjackson/SchParse.java +209 -0
  66. data/src/main/java/com/jrjackson/StreamParse.java +66 -0
  67. data/test/jrjackson_test.rb +533 -0
  68. metadata +162 -0
@@ -0,0 +1,81 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import org.jruby.Ruby;
5
+ import org.jruby.RubyClass;
6
+ import org.jruby.anno.JRubyModule;
7
+ import org.jruby.anno.JRubyMethod;
8
+ import org.jruby.runtime.ThreadContext;
9
+ import org.jruby.runtime.builtin.IRubyObject;
10
+
11
+ import java.io.IOException;
12
+
13
+ import com.fasterxml.jackson.core.JsonProcessingException;
14
+ import org.jruby.RubyHash;
15
+ import org.jruby.exceptions.RaiseException;
16
+
17
+
18
+ @JRubyModule(name = "JrJacksonJava")
19
+ public class JrJacksonJava extends JrJacksonBase {
20
+
21
+ public JrJacksonJava(Ruby ruby, RubyClass metaclass) {
22
+ super(ruby, metaclass);
23
+ }
24
+
25
+ // deserialize
26
+ @JRubyMethod(module = true, name = {"parse", "load"}, required = 2)
27
+ public static IRubyObject parse(ThreadContext context, IRubyObject self, IRubyObject arg, IRubyObject opts)
28
+ throws JsonProcessingException, IOException, RaiseException {
29
+
30
+ JavaConverter ikonv = new JavaBigIntValueConverter();
31
+ JavaConverter dkonv = new JavaBigDecimalValueConverter();
32
+ if (opts != context.nil) {
33
+ RubyHash options = opts.convertToHash();
34
+ if (options.size() > 0) {
35
+ if (!flagged(options,
36
+ RubyUtils.rubySymbol(context.runtime, "use_bigdecimal"), true)) {
37
+ dkonv = new JavaFloatValueConverter();
38
+ }
39
+ if (flagged(options,
40
+ RubyUtils.rubySymbol(context.runtime, "use_smallint"))) {
41
+ ikonv = new JavaLongValueConverter();
42
+ }
43
+ }
44
+ }
45
+
46
+ JavaHandler handler = new JavaHandler(ikonv, dkonv);
47
+ JjParse parse = new JjParse(handler);
48
+ JsonParser jp;
49
+ try {
50
+ jp = buildParser(context, RubyJacksonModule.factory, arg);
51
+ } catch (IOException e) {
52
+ throw context.runtime.newIOError(e.getLocalizedMessage());
53
+ }
54
+
55
+ parse.deserialize(jp);
56
+ jp.close();
57
+ return RubyUtils.rubyObject(context.runtime, handler.getResult());
58
+ }
59
+
60
+ // deserialize
61
+ @JRubyMethod(module = true, name = {"parse_raw", "load_raw"}, required = 2)
62
+ public static IRubyObject parse_raw(ThreadContext context, IRubyObject self, IRubyObject arg, IRubyObject opts)
63
+ throws JsonProcessingException, IOException, RaiseException {
64
+
65
+ JavaConverter ikonv = new JavaBigIntValueConverter();
66
+ JavaConverter dkonv = new JavaBigDecimalValueConverter();
67
+
68
+ JavaHandler handler = new JavaHandler(ikonv, dkonv);
69
+ JjParse parse = new JjParse(handler);
70
+ JsonParser jp;
71
+ try {
72
+ jp = buildParser(context, RubyJacksonModule.factory, arg);
73
+ } catch (IOException e) {
74
+ throw context.runtime.newIOError(e.getLocalizedMessage());
75
+ }
76
+
77
+ parse.deserialize(jp);
78
+ jp.close();
79
+ return RubyUtils.rubyObject(context.runtime, handler.getResult());
80
+ }
81
+ }
@@ -0,0 +1,108 @@
1
+ package com.jrjackson;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.RubyClass;
5
+ import org.jruby.RubyHash;
6
+ import org.jruby.anno.JRubyMethod;
7
+ import org.jruby.anno.JRubyModule;
8
+ import org.jruby.runtime.ThreadContext;
9
+ import org.jruby.runtime.builtin.IRubyObject;
10
+
11
+ import java.io.IOException;
12
+
13
+ import com.fasterxml.jackson.databind.ObjectMapper;
14
+ import com.fasterxml.jackson.databind.DeserializationFeature;
15
+ import org.jruby.exceptions.RaiseException;
16
+
17
+
18
+ @JRubyModule(name = "JrJacksonRaw")
19
+ public class JrJacksonRaw extends JrJacksonBase {
20
+
21
+ public JrJacksonRaw(Ruby ruby, RubyClass metaclass) {
22
+ super(ruby, metaclass);
23
+ }
24
+
25
+ // deserialize
26
+ @JRubyMethod(module = true, name = {"parse", "load"}, required = 2)
27
+ public static IRubyObject parse(ThreadContext context, IRubyObject self, IRubyObject arg, IRubyObject opts)
28
+ throws IOException {
29
+ Ruby _ruby = context.runtime;
30
+ RubyHash options = null;
31
+
32
+ if (opts != context.nil) {
33
+ options = opts.convertToHash();
34
+
35
+ return direct(context, self, arg,
36
+ flagged(options, RubyUtils.rubySymbol(_ruby, "use_bigdecimal")),
37
+ !flagged(options, RubyUtils.rubySymbol(_ruby, "use_smallint")),
38
+ flagged(options, RubyUtils.rubySymbol(_ruby, "symbolize_keys")),
39
+ flagged(options, RubyUtils.rubySymbol(_ruby, "raw")));
40
+
41
+ } else {
42
+ return direct(context, self, arg, false, true, false, false);
43
+ }
44
+ }
45
+
46
+ private static IRubyObject direct(ThreadContext context, IRubyObject self, IRubyObject arg,
47
+ boolean use_big_decimal, boolean use_big_int,
48
+ boolean use_symbols, boolean use_raw) throws IOException {
49
+ ObjectMapper local = RubyJacksonModule.rawBigNumberMapper();
50
+
51
+ RubyConverter vci = new RubyIntValueConverter();
52
+ RubyConverter vcf = new RubyFloatValueConverter();
53
+ RubyKeyConverter kcn;
54
+
55
+ if (use_big_decimal) {
56
+ vcf = new RubyBigDecimalValueConverter();
57
+ } else {
58
+ local.disable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
59
+ }
60
+
61
+ if (use_big_int) {
62
+ vci = new RubyBigIntValueConverter();
63
+ } else {
64
+ local.disable(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS);
65
+ }
66
+
67
+ if(use_raw) {
68
+ return _parse(context, arg, local);
69
+ }
70
+
71
+ if (use_symbols) {
72
+ kcn = new RubySymbolKeyConverter();
73
+ } else {
74
+ kcn = new RubyStringKeyConverter();
75
+ }
76
+
77
+ local = RubyJacksonModule.mapperWith(context.runtime, kcn, vci, vcf);
78
+ return _parse(context, arg, local);
79
+ }
80
+
81
+ @JRubyMethod(module = true, name = {"parse_raw", "load_raw"}, required = 1)
82
+ public static IRubyObject parse_raw(ThreadContext context, IRubyObject self, IRubyObject arg)
83
+ throws IOException, RaiseException {
84
+ return direct(context, self, arg, false, false, false, true);
85
+ }
86
+
87
+ @JRubyMethod(module = true, name = {"parse_raw_bd", "load_raw_bd"}, required = 1)
88
+ public static IRubyObject parse_raw_bd(ThreadContext context, IRubyObject self, IRubyObject arg)
89
+ throws IOException, RaiseException {
90
+
91
+ return direct(context, self, arg, true, true, false, true);
92
+ }
93
+
94
+ @JRubyMethod(module = true, name = {"parse_sym", "load_sym"}, required = 1)
95
+ public static IRubyObject parse_sym(ThreadContext context, IRubyObject self, IRubyObject arg)
96
+ throws IOException, RaiseException {
97
+
98
+ return direct(context, self, arg, false, false, true, false);
99
+ }
100
+
101
+ @JRubyMethod(module = true, name = {"parse_str", "load_str"}, required = 1)
102
+ public static IRubyObject parse_str(ThreadContext context, IRubyObject self, IRubyObject arg)
103
+ throws IOException, RaiseException {
104
+
105
+ return direct(context, self, arg, false, true, false, false);
106
+
107
+ }
108
+ }
@@ -0,0 +1,89 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonFactory;
4
+ import com.fasterxml.jackson.core.JsonParser;
5
+ import org.jruby.Ruby;
6
+ import org.jruby.RubyClass;
7
+ import org.jruby.anno.JRubyModule;
8
+ import org.jruby.anno.JRubyMethod;
9
+ import org.jruby.runtime.ThreadContext;
10
+ import org.jruby.runtime.builtin.IRubyObject;
11
+
12
+ import java.io.IOException;
13
+
14
+ import com.fasterxml.jackson.databind.ObjectMapper;
15
+ import com.fasterxml.jackson.core.JsonProcessingException;
16
+ import static com.jrjackson.JrJacksonBase.flagged;
17
+ import org.jruby.RubyHash;
18
+ import org.jruby.exceptions.RaiseException;
19
+
20
+ @JRubyModule(name = "JrJacksonRuby")
21
+ public class JrJacksonRuby extends JrJacksonBase {
22
+
23
+ public JrJacksonRuby(Ruby ruby, RubyClass metaclass) {
24
+ super(ruby, metaclass);
25
+ }
26
+
27
+ // deserialize
28
+ @JRubyMethod(module = true, name = {"parse_sym", "load_sym"}, required = 2)
29
+ public static Object parse_sym(ThreadContext context, IRubyObject self, IRubyObject arg, IRubyObject opts)
30
+ throws JsonProcessingException, IOException, RaiseException {
31
+
32
+ return __parse(context, arg,
33
+ new RubySymbolNameConverter(),
34
+ new RubyBigIntValueConverter(),
35
+ new RubyBigDecimalValueConverter()
36
+ );
37
+ }
38
+
39
+ @JRubyMethod(module = true, name = {"parse", "load"}, required = 2)
40
+ public static Object parse(ThreadContext context, IRubyObject self, IRubyObject arg, IRubyObject opts)
41
+ throws JsonProcessingException, IOException, RaiseException {
42
+
43
+ RubyNameConverter konv = new RubyStringNameConverter();
44
+ RubyConverter ikonv = new RubyBigIntValueConverter();
45
+ RubyConverter dkonv = new RubyBigDecimalValueConverter();
46
+ if (opts != context.nil) {
47
+ RubyHash options = opts.convertToHash();
48
+ if (options.size() > 0) {
49
+ if (flagged(options,
50
+ RubyUtils.rubySymbol(context.runtime, "symbolize_keys"))) {
51
+ konv = new RubySymbolNameConverter();
52
+ }
53
+ if (!flagged(options,
54
+ RubyUtils.rubySymbol(context.runtime, "use_bigdecimal"), true)) {
55
+ dkonv = new RubyFloatValueConverter();
56
+ }
57
+ if (flagged(options,
58
+ RubyUtils.rubySymbol(context.runtime, "use_smallint"))) {
59
+ ikonv = new RubyIntValueConverter();
60
+ }
61
+ }
62
+ }
63
+ return __parse(context, arg, konv, ikonv, dkonv);
64
+ }
65
+
66
+ private static Object __parse(ThreadContext context, IRubyObject arg,
67
+ RubyNameConverter keykonv, RubyConverter intconv, RubyConverter decimalconv)
68
+ throws JsonProcessingException, IOException, RaiseException {
69
+
70
+ RubyHandler handler = new RubyHandler(context,
71
+ keykonv,
72
+ intconv,
73
+ decimalconv);
74
+ JrParse parse = new JrParse(handler);
75
+ ObjectMapper mapper = RubyJacksonModule.rawBigNumberMapper();
76
+ JsonFactory jf = mapper.getFactory().disable(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW);
77
+ JsonParser jp;
78
+ try {
79
+
80
+ jp = buildParser(context, jf, arg);
81
+
82
+ } catch (IOException e) {
83
+ throw context.runtime.newIOError(e.getLocalizedMessage());
84
+ }
85
+ parse.deserialize(jp);
86
+ jp.close();
87
+ return handler.getResult();
88
+ }
89
+ }
@@ -0,0 +1,26 @@
1
+ package com.jrjackson;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.RubyClass;
5
+ import org.jruby.anno.JRubyMethod;
6
+ import org.jruby.anno.JRubyModule;
7
+ import org.jruby.runtime.ThreadContext;
8
+ import org.jruby.runtime.builtin.IRubyObject;
9
+
10
+ import org.jruby.exceptions.RaiseException;
11
+
12
+ @JRubyModule(name = "JrJacksonSaj")
13
+ public class JrJacksonSaj extends JrJacksonBase {
14
+
15
+ public JrJacksonSaj(Ruby ruby, RubyClass metaclass) {
16
+ super(ruby, metaclass);
17
+ }
18
+
19
+ // deserialize
20
+ @JRubyMethod(module = true, name = {"parse", "load"}, required = 3)
21
+ public static IRubyObject parse(ThreadContext context, IRubyObject self, IRubyObject handler, IRubyObject arg, IRubyObject opts)
22
+ throws RaiseException {
23
+ StreamParse sp = new SajParse(context, handler);
24
+ return _sjcparse(context, handler, arg, opts, sp);
25
+ }
26
+ }
@@ -0,0 +1,25 @@
1
+ package com.jrjackson;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.RubyClass;
5
+ import org.jruby.anno.JRubyMethod;
6
+ import org.jruby.anno.JRubyModule;
7
+ import org.jruby.runtime.ThreadContext;
8
+ import org.jruby.runtime.builtin.IRubyObject;
9
+ import org.jruby.exceptions.RaiseException;
10
+
11
+ @JRubyModule(name = "JrJacksonSch")
12
+ public class JrJacksonSch extends JrJacksonBase {
13
+
14
+ public JrJacksonSch(Ruby ruby, RubyClass metaclass) {
15
+ super(ruby, metaclass);
16
+ }
17
+
18
+ // deserialize
19
+ @JRubyMethod(module = true, name = {"parse", "load"}, required = 3)
20
+ public static IRubyObject parse(ThreadContext context, IRubyObject self, IRubyObject handler, IRubyObject arg, IRubyObject opts)
21
+ throws RaiseException {
22
+ StreamParse sp = new SchParse(context, handler);
23
+ return _sjcparse(context, handler, arg, opts, sp);
24
+ }
25
+ }
@@ -0,0 +1,38 @@
1
+ package com.jrjackson;
2
+
3
+ import org.jruby.Ruby;
4
+ import org.jruby.RubyModule;
5
+ import org.jruby.RubyClass;
6
+ import org.jruby.runtime.load.BasicLibraryService;
7
+
8
+ import java.io.IOException;
9
+
10
+ public class JrJacksonService implements BasicLibraryService {
11
+
12
+ @Override
13
+ public boolean basicLoad(final Ruby ruby) throws IOException {
14
+ RubyModule jr_jackson = ruby.defineModule("JrJackson");
15
+
16
+ RubyModule jr_jackson_base = ruby.defineModuleUnder("Base", jr_jackson);
17
+ jr_jackson_base.defineAnnotatedMethods(JrJacksonBase.class);
18
+
19
+ RubyModule jr_jackson_raw = ruby.defineModuleUnder("Raw", jr_jackson);
20
+ jr_jackson_raw.defineAnnotatedMethods(JrJacksonRaw.class);
21
+
22
+ RubyModule jr_jackson_ruby = ruby.defineModuleUnder("Ruby", jr_jackson);
23
+ jr_jackson_ruby.defineAnnotatedMethods(JrJacksonRuby.class);
24
+
25
+ RubyModule jr_jackson_java = ruby.defineModuleUnder("Java", jr_jackson);
26
+ jr_jackson_java.defineAnnotatedMethods(JrJacksonJava.class);
27
+
28
+ RubyModule jr_jackson_saj = ruby.defineModuleUnder("Saj", jr_jackson);
29
+ jr_jackson_saj.defineAnnotatedMethods(JrJacksonSaj.class);
30
+
31
+ RubyModule jr_jackson_sch = ruby.defineModuleUnder("Sch", jr_jackson);
32
+ jr_jackson_sch.defineAnnotatedMethods(JrJacksonSch.class);
33
+
34
+ RubyClass runtimeError = ruby.getRuntimeError();
35
+ RubyClass parseError = jr_jackson.defineClassUnder("ParseError", runtimeError, runtimeError.getAllocator());
36
+ return true;
37
+ }
38
+ }
@@ -0,0 +1,149 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import com.fasterxml.jackson.core.JsonProcessingException;
5
+ import com.fasterxml.jackson.core.JsonStreamContext;
6
+ import java.io.IOException;
7
+ import java.util.HashMap;
8
+ import org.jruby.RubyArray;
9
+ import org.jruby.RubyHash;
10
+ import org.jruby.runtime.builtin.IRubyObject;
11
+
12
+
13
+ /**
14
+ *
15
+ * @author Guy Boertje
16
+ */
17
+ public class JrParse {
18
+ private final RubyHandler _handler;
19
+ protected final HashMap<JsonStreamContext, IRubyObject> _objectMap = new HashMap<JsonStreamContext, IRubyObject>();
20
+ protected JsonStreamContext _deepestContext;
21
+
22
+ public JrParse(RubyHandler handler) {
23
+ _handler = handler;
24
+
25
+ }
26
+
27
+ public void deserialize(JsonParser jp) throws JsonProcessingException, IOException {
28
+ try {
29
+
30
+ while (jp.nextValue() != null) {
31
+ handleCurrentToken(jp);
32
+ }
33
+
34
+ } catch (JsonProcessingException e) {
35
+ _handler.raiseError(e.getLocalizedMessage());
36
+ } catch (IOException e) {
37
+ _handler.raiseError(e.getLocalizedMessage());
38
+ }
39
+ }
40
+
41
+ private void callAddValue(JsonStreamContext x) {
42
+ JsonStreamContext px = x.getParent();
43
+ IRubyObject dtarget = _objectMap.get(_deepestContext);
44
+
45
+ if (px == null) {
46
+ _handler.addValue(dtarget);
47
+ return;
48
+ }
49
+
50
+ IRubyObject value = _objectMap.get(x);
51
+
52
+ if (x.inArray()) {
53
+ _handler.arrayAppend(
54
+ (RubyArray)value, dtarget);
55
+ } else if (x.inObject()) {
56
+ _handler.hashSet(
57
+ (RubyHash)value, callHashKey(x), dtarget);
58
+
59
+ } else {
60
+ _handler.addValue(value);
61
+ }
62
+ }
63
+
64
+ private void callAddValue(JsonStreamContext x, IRubyObject val) {
65
+
66
+ if (x.inArray()) {
67
+ RubyArray a = (RubyArray)_objectMap.get(x);
68
+ _handler.arrayAppend(a, val);
69
+ } else if (x.inObject()) {
70
+ RubyHash h = (RubyHash)_objectMap.get(x);
71
+ _handler.hashSet(h, callHashKey(x), val);
72
+
73
+ } else {
74
+ _handler.addValue(val);
75
+ }
76
+ }
77
+
78
+ private IRubyObject callHashKey(JsonStreamContext x) {
79
+ String k = x.getCurrentName();
80
+ if (k == null) {
81
+ return _handler.treatNull();
82
+ }
83
+ return _handler.hashKey(k);
84
+ }
85
+
86
+ private void handleCurrentToken(JsonParser jp)
87
+ throws IOException, JsonProcessingException {
88
+
89
+ JsonStreamContext cx = jp.getParsingContext();
90
+
91
+ switch (jp.getCurrentToken()) {
92
+ case START_OBJECT:
93
+ _deepestContext = cx;
94
+ _objectMap.put(cx, _handler.hashStart());
95
+ break;
96
+
97
+ case START_ARRAY:
98
+ _deepestContext = cx;
99
+ _objectMap.put(cx, _handler.arrayStart());
100
+
101
+ case FIELD_NAME:
102
+ break;
103
+
104
+ case VALUE_EMBEDDED_OBJECT:
105
+ System.out.println("-------- VALUE_EMBEDDED_OBJECT ????????? --------");
106
+ System.out.println(jp.getEmbeddedObject());
107
+ break;
108
+
109
+ case VALUE_STRING:
110
+ callAddValue(cx,
111
+ _handler.treatString(jp));
112
+ break;
113
+
114
+ case VALUE_NUMBER_INT:
115
+ callAddValue(cx,
116
+ _handler.treatInt(jp));
117
+ break;
118
+
119
+ case VALUE_NUMBER_FLOAT:
120
+ callAddValue(cx,
121
+ _handler.treatFloat(jp));
122
+ break;
123
+
124
+ case VALUE_TRUE:
125
+ callAddValue(cx, _handler.trueValue());
126
+ break;
127
+
128
+ case VALUE_FALSE:
129
+ callAddValue(cx, _handler.falseValue());
130
+ break;
131
+
132
+ case VALUE_NULL: // should not get this but...
133
+ callAddValue(cx, _handler.treatNull());
134
+ break;
135
+
136
+ case END_ARRAY:
137
+ _handler.arrayEnd();
138
+ callAddValue(cx);
139
+ _deepestContext = cx;
140
+ break;
141
+
142
+ case END_OBJECT:
143
+ _handler.hashEnd();
144
+ callAddValue(cx);
145
+ _deepestContext = cx;
146
+ break;
147
+ }
148
+ }
149
+ }