jrjackson 0.4.18-java → 0.4.19-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/jrjackson.gemspec +1 -2
  3. data/lib/com/fasterxml/jackson/core/jackson-annotations/{2.15.2/jackson-annotations-2.15.2.jar → 2.15.4/jackson-annotations-2.15.4.jar} +0 -0
  4. data/lib/com/fasterxml/jackson/core/jackson-core/{2.15.2/jackson-core-2.15.2.jar → 2.15.4/jackson-core-2.15.4.jar} +0 -0
  5. data/lib/com/fasterxml/jackson/core/jackson-databind/{2.15.2/jackson-databind-2.15.2.jar → 2.15.4/jackson-databind-2.15.4.jar} +0 -0
  6. data/lib/com/fasterxml/jackson/module/jackson-module-afterburner/{2.15.2/jackson-module-afterburner-2.15.2.jar → 2.15.4/jackson-module-afterburner-2.15.4.jar} +0 -0
  7. data/lib/jrjackson/build_info.rb +8 -8
  8. data/lib/jrjackson/jars/{jrjackson-1.2.35.jar → jrjackson-1.2.36.jar} +0 -0
  9. data/lib/jrjackson_jars.rb +8 -8
  10. data/pom.xml +47 -10
  11. metadata +13 -78
  12. data/.gitignore +0 -16
  13. data/.jrubyr_c +0 -433
  14. data/Gemfile +0 -13
  15. data/Mavenfile +0 -25
  16. data/Rakefile +0 -39
  17. data/alt_bench.rb +0 -46
  18. data/changelog.md +0 -181
  19. data/profiling/profiled.rb +0 -15
  20. data/run_all_individual_bench.sh +0 -25
  21. data/run_jruby_individual_bench.sh +0 -20
  22. data/run_mri_individual_bench.sh +0 -7
  23. data/src/main/java/com/jrjackson/IParseHandler.java +0 -53
  24. data/src/main/java/com/jrjackson/JavaBigDecimalValueConverter.java +0 -17
  25. data/src/main/java/com/jrjackson/JavaBigIntValueConverter.java +0 -17
  26. data/src/main/java/com/jrjackson/JavaConverter.java +0 -10
  27. data/src/main/java/com/jrjackson/JavaFloatValueConverter.java +0 -16
  28. data/src/main/java/com/jrjackson/JavaHandler.java +0 -118
  29. data/src/main/java/com/jrjackson/JavaLongValueConverter.java +0 -16
  30. data/src/main/java/com/jrjackson/JjParse.java +0 -139
  31. data/src/main/java/com/jrjackson/JrJacksonBase.java +0 -152
  32. data/src/main/java/com/jrjackson/JrJacksonJava.java +0 -81
  33. data/src/main/java/com/jrjackson/JrJacksonRaw.java +0 -108
  34. data/src/main/java/com/jrjackson/JrJacksonRuby.java +0 -89
  35. data/src/main/java/com/jrjackson/JrJacksonSaj.java +0 -26
  36. data/src/main/java/com/jrjackson/JrJacksonSch.java +0 -25
  37. data/src/main/java/com/jrjackson/JrJacksonService.java +0 -38
  38. data/src/main/java/com/jrjackson/JrParse.java +0 -142
  39. data/src/main/java/com/jrjackson/ParseError.java +0 -16
  40. data/src/main/java/com/jrjackson/RubyAnySerializer.java +0 -291
  41. data/src/main/java/com/jrjackson/RubyBigDecimalValueConverter.java +0 -18
  42. data/src/main/java/com/jrjackson/RubyBigIntValueConverter.java +0 -21
  43. data/src/main/java/com/jrjackson/RubyConverter.java +0 -12
  44. data/src/main/java/com/jrjackson/RubyDateFormat.java +0 -34
  45. data/src/main/java/com/jrjackson/RubyFloatValueConverter.java +0 -18
  46. data/src/main/java/com/jrjackson/RubyHandler.java +0 -119
  47. data/src/main/java/com/jrjackson/RubyIntValueConverter.java +0 -18
  48. data/src/main/java/com/jrjackson/RubyJacksonModule.java +0 -80
  49. data/src/main/java/com/jrjackson/RubyKeyConverter.java +0 -12
  50. data/src/main/java/com/jrjackson/RubyNameConverter.java +0 -9
  51. data/src/main/java/com/jrjackson/RubyObjectDeserializer.java +0 -182
  52. data/src/main/java/com/jrjackson/RubyStringConverter.java +0 -18
  53. data/src/main/java/com/jrjackson/RubyStringKeyConverter.java +0 -15
  54. data/src/main/java/com/jrjackson/RubyStringNameConverter.java +0 -12
  55. data/src/main/java/com/jrjackson/RubySymbolKeyConverter.java +0 -15
  56. data/src/main/java/com/jrjackson/RubySymbolNameConverter.java +0 -12
  57. data/src/main/java/com/jrjackson/RubyUtils.java +0 -149
  58. data/src/main/java/com/jrjackson/SajParse.java +0 -169
  59. data/src/main/java/com/jrjackson/SchParse.java +0 -209
  60. data/src/main/java/com/jrjackson/StreamParse.java +0 -66
  61. data/src/test/java/com/jrjackson/RubyAnySerializerTest.java +0 -56
  62. data/test/jrjackson_test.rb +0 -578
@@ -1,209 +0,0 @@
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
-
9
- import org.jruby.internal.runtime.methods.DynamicMethod;
10
- import org.jruby.runtime.ThreadContext;
11
- import org.jruby.runtime.builtin.IRubyObject;
12
- import org.jruby.RubyString;
13
- import org.jruby.exceptions.RaiseException;
14
-
15
- /**
16
- *
17
- * @author Guy Boertje
18
- */
19
- public class SchParse extends StreamParse {
20
-
21
- protected final DynamicMethod _hash_key;
22
- protected final boolean _no_hash_key;
23
-
24
- protected final DynamicMethod _hash_set;
25
- protected final boolean _no_hash_set;
26
-
27
- protected final DynamicMethod _array_append;
28
- protected final boolean _no_array_append;
29
-
30
- protected final HashMap<JsonStreamContext, IRubyObject> _objectMap = new HashMap<JsonStreamContext, IRubyObject>();
31
- protected JsonStreamContext _deepestContext;
32
-
33
- public SchParse(ThreadContext ctx, IRubyObject handler)
34
- throws RaiseException {
35
- super(ctx, handler);
36
-
37
- _hash_key = _meta.searchMethod("hash_key");
38
- _no_hash_key = _hash_key.isUndefined();
39
-
40
- _hash_set = _meta.searchMethod("hash_set");
41
- _no_hash_set = _hash_set.isUndefined();
42
-
43
- _array_append = _meta.searchMethod("array_append");
44
- _no_array_append = _array_append.isUndefined();
45
-
46
- //_hash_key is optional
47
- if (
48
- _no_hash_start || _no_hash_end ||
49
- _no_array_start || _no_array_end ||
50
- _no_add_value || _no_hash_set || _no_array_append
51
- ) {
52
- throw ParseError.newParseError(_ruby, "Handler does not implement public API");
53
- }
54
- }
55
-
56
- @Override
57
- public IRubyObject deserialize(JsonParser jp) throws RaiseException {
58
- try {
59
-
60
- while (jp.nextValue() != null) {
61
- handleCurrentToken(jp);
62
- }
63
- return _ctx.nil;
64
-
65
- } catch (JsonProcessingException e) {
66
- throw ParseError.newParseError(_ruby, e.getLocalizedMessage());
67
- } catch (IOException e) {
68
- throw _ruby.newIOError(e.getLocalizedMessage());
69
- }
70
- }
71
-
72
- private void callAddValue(JsonStreamContext x) {
73
- JsonStreamContext px = x.getParent();
74
- IRubyObject target = _objectMap.get(x);
75
- IRubyObject dtarget = _objectMap.get(_deepestContext);
76
-
77
- if (px == null) {
78
- _add_value.call(_ctx, _handler, _meta, "add_value", dtarget);
79
- return;
80
- }
81
-
82
- if (x.inArray()) {
83
- _array_append.call(_ctx, _handler, _meta, "array_append", target, dtarget);
84
- } else if (x.inObject()) {
85
- IRubyObject treatedKey = callHashKey(x);
86
- _hash_set.call(_ctx, _handler, _meta, "hash_set", target, treatedKey, dtarget);
87
- } else {
88
- _add_value.call(_ctx, _handler, _meta, "add_value", target);
89
- }
90
- }
91
-
92
- private void callAddValue(JsonStreamContext x, IRubyObject val) {
93
- IRubyObject target = _objectMap.get(x);
94
-
95
- if (x.inArray()) {
96
- _array_append.call(_ctx, _handler, _meta, "array_append", target, val);
97
- } else if (x.inObject()) {
98
- IRubyObject treatedKey = callHashKey(x);
99
- _hash_set.call(_ctx, _handler, _meta, "hash_set", target, treatedKey, val);
100
- } else {
101
- _add_value.call(_ctx, _handler, _meta, "add_value", val);
102
- }
103
- }
104
-
105
- private IRubyObject callHashKey(JsonStreamContext x) {
106
- String k = x.getCurrentName();
107
- if (k == null) {
108
- return _ctx.nil;
109
- }
110
- RubyString key = RubyUtils.rubyString(_ruby, k);
111
- if (_no_hash_key) {
112
- return key;
113
- }
114
- return _hash_key.call(_ctx, _handler, _meta, "hash_key", key);
115
- }
116
-
117
- private void handleCurrentToken(JsonParser jp)
118
- throws IOException, JsonProcessingException {
119
-
120
- JsonStreamContext cx = jp.getParsingContext();
121
- IRubyObject value;
122
- IRubyObject rubyObject;
123
-
124
- switch (jp.getCurrentToken()) {
125
- case START_OBJECT:
126
- _deepestContext = cx;
127
- rubyObject = _hash_start.call(_ctx, _handler, _meta, "hash_start");
128
- _objectMap.put(cx, rubyObject);
129
- break;
130
-
131
- case START_ARRAY:
132
- _deepestContext = cx;
133
- rubyObject = _array_start.call(_ctx, _handler, _meta, "array_start");
134
- _objectMap.put(cx, rubyObject);
135
- break;
136
-
137
- case FIELD_NAME:
138
- break;
139
-
140
- case VALUE_EMBEDDED_OBJECT:
141
- value = RubyUtils.rubyObject(_ruby, jp.getEmbeddedObject());
142
- callAddValue(cx, value);
143
- break;
144
-
145
- case VALUE_STRING:
146
- value = keyConverter.convert(_ruby, jp);
147
- callAddValue(cx, value);
148
- break;
149
-
150
- case VALUE_NUMBER_INT:
151
- /* [JACKSON-100]: caller may want to get all integral values
152
- * returned as BigInteger, for consistency
153
- */
154
- JsonParser.NumberType numberType = jp.getNumberType();
155
- value = RubyUtils.rubyBignum(_ruby, jp.getBigIntegerValue());
156
- callAddValue(cx, value);
157
- break;
158
-
159
- case VALUE_NUMBER_FLOAT:
160
- value = RubyUtils.rubyBigDecimal(_ruby, jp.getDecimalValue());
161
- callAddValue(cx, value);
162
- break;
163
-
164
- case VALUE_TRUE:
165
- value = _ruby.newBoolean(Boolean.TRUE);
166
- callAddValue(cx, value);
167
- break;
168
-
169
- case VALUE_FALSE:
170
- value = _ruby.newBoolean(Boolean.FALSE);
171
- callAddValue(cx, value);
172
- break;
173
-
174
- case VALUE_NULL: // should not get this but...
175
- value = _ctx.nil;
176
- callAddValue(cx, value);
177
- break;
178
-
179
- case END_ARRAY:
180
- _array_end.call(_ctx, _handler, _meta, "array_end");
181
- callAddValue(cx);
182
- _deepestContext = cx;
183
- break;
184
-
185
- case END_OBJECT:
186
- _hash_end.call(_ctx, _handler, _meta, "hash_end");
187
- callAddValue(cx);
188
- _deepestContext = cx;
189
- break;
190
- }
191
-
192
- }
193
-
194
- }
195
- // System.out.println("--- addRubyValue final ---");
196
- // if (px != null) {
197
- // System.out.println("-------- parent --------");
198
- // System.out.println(px.getTypeDesc());
199
- // System.out.println(px.getCurrentName());
200
- // }
201
- // System.out.println("-------- current --------");
202
- // System.out.println(x.getTypeDesc());
203
- // System.out.println(x.getCurrentName());
204
- // System.out.println(target);
205
- //
206
- // System.out.println("-------- deepest --------");
207
- // System.out.println(_deepestContext.getTypeDesc());
208
- // System.out.println(_deepestContext.getCurrentName());
209
- // System.out.println(dtarget);
@@ -1,66 +0,0 @@
1
- package com.jrjackson;
2
-
3
- import com.fasterxml.jackson.core.JsonParser;
4
-
5
- import org.jruby.Ruby;
6
- import org.jruby.RubyClass;
7
- import org.jruby.internal.runtime.methods.DynamicMethod;
8
- import org.jruby.runtime.ThreadContext;
9
- import org.jruby.runtime.builtin.IRubyObject;
10
- import org.jruby.exceptions.RaiseException;
11
-
12
- /**
13
- *
14
- * @author Guy Boertje
15
- */
16
- public abstract class StreamParse {
17
-
18
- protected final ThreadContext _ctx;
19
- protected final Ruby _ruby;
20
- protected final IRubyObject _handler;
21
- protected final RubyClass _meta;
22
- protected final RubyStringConverter keyConverter = new RubyStringConverter();
23
-
24
- protected final DynamicMethod _hash_start;
25
- protected final boolean _no_hash_start;
26
-
27
- protected final DynamicMethod _hash_end;
28
- protected final boolean _no_hash_end;
29
-
30
- protected final DynamicMethod _array_start;
31
- protected final boolean _no_array_start;
32
-
33
- protected final DynamicMethod _array_end;
34
- protected final boolean _no_array_end;
35
-
36
- protected final DynamicMethod _add_value;
37
- protected final boolean _no_add_value;
38
-
39
- public StreamParse(ThreadContext ctx, IRubyObject handler)
40
- throws RaiseException {
41
-
42
- _ctx = ctx;
43
- _ruby = ctx.runtime;
44
- _handler = handler;
45
- _meta = _handler.getMetaClass();
46
-
47
- _add_value = _meta.searchMethod("add_value");
48
- _no_add_value = _add_value.isUndefined();
49
-
50
- _hash_start = _meta.searchMethod("hash_start");
51
- _no_hash_start = _hash_start.isUndefined();
52
-
53
- _hash_end = _meta.searchMethod("hash_end");
54
- _no_hash_end = _hash_end.isUndefined();
55
-
56
- _array_start = _meta.searchMethod("array_start");
57
- _no_array_start = _array_start.isUndefined();
58
-
59
- _array_end = _meta.searchMethod("array_end");
60
- _no_array_end = _array_end.isUndefined();
61
-
62
- }
63
-
64
- public abstract IRubyObject deserialize(JsonParser jp)
65
- throws RaiseException;
66
- }
@@ -1,56 +0,0 @@
1
- package com.jrjackson;
2
-
3
- import com.fasterxml.jackson.core.JsonEncoding;
4
- import com.fasterxml.jackson.core.JsonGenerator;
5
- import com.fasterxml.jackson.databind.SerializerProvider;
6
- import org.jcodings.specific.UTF8Encoding;
7
- import org.jruby.CompatVersion;
8
- import org.jruby.Ruby;
9
- import org.jruby.RubyHash;
10
- import org.jruby.RubyInstanceConfig;
11
- import org.jruby.ext.bigdecimal.RubyBigDecimal;
12
- import org.jruby.util.ByteList;
13
- import org.junit.Before;
14
- import org.junit.Test;
15
-
16
- import java.io.ByteArrayOutputStream;
17
-
18
- import static org.hamcrest.CoreMatchers.equalTo;
19
- import static org.hamcrest.CoreMatchers.is;
20
- import static org.hamcrest.MatcherAssert.assertThat;
21
-
22
- public class RubyAnySerializerTest {
23
- private static boolean setupDone = false;
24
- public static Ruby ruby;
25
-
26
- @Before
27
- public void setUp() throws Exception {
28
- if (setupDone) return;
29
-
30
- RubyInstanceConfig config_19 = new RubyInstanceConfig();
31
- config_19.setCompatVersion(CompatVersion.RUBY1_9);
32
- ruby = Ruby.newInstance(config_19);
33
- RubyBigDecimal.createBigDecimal(ruby); // we need to do 'require "bigdecimal"'
34
- // JrubyTimestampExtLibrary.createTimestamp(ruby);
35
- setupDone = true;
36
- }
37
-
38
-
39
- @Test
40
- public void testSerialize() throws Exception {
41
- RubyHash rh = RubyHash.newHash(ruby);
42
- rh.put("somekey", 123);
43
-
44
- SerializerProvider provider = RubyJacksonModule.createProvider();
45
-
46
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
47
- JsonGenerator jgen = RubyJacksonModule.factory.createGenerator(
48
- baos, JsonEncoding.UTF8);
49
-
50
- RubyAnySerializer.instance.serialize(rh, jgen, provider);
51
- jgen.close();
52
- ByteList bl = new ByteList(baos.toByteArray(),
53
- UTF8Encoding.INSTANCE);
54
- assertThat(bl.toString(), is(equalTo("{\"somekey\":123}")));
55
- }
56
- }