-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathObjectReader.java
1928 lines (1743 loc) · 70.7 KB
/
ObjectReader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package tools.jackson.databind;
import java.io.*;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import tools.jackson.core.*;
import tools.jackson.core.exc.JacksonIOException;
import tools.jackson.core.filter.FilteringParserDelegate;
import tools.jackson.core.filter.JsonPointerBasedFilter;
import tools.jackson.core.filter.TokenFilter;
import tools.jackson.core.filter.TokenFilter.Inclusion;
import tools.jackson.core.type.ResolvedType;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.cfg.ContextAttributes;
import tools.jackson.databind.cfg.DatatypeFeature;
import tools.jackson.databind.cfg.DeserializationContexts;
import tools.jackson.databind.deser.DeserializationContextExt;
import tools.jackson.databind.deser.DeserializationProblemHandler;
import tools.jackson.databind.node.ArrayNode;
import tools.jackson.databind.node.JsonNodeFactory;
import tools.jackson.databind.node.ObjectNode;
import tools.jackson.databind.node.TreeTraversingParser;
import tools.jackson.databind.type.SimpleType;
import tools.jackson.databind.type.TypeFactory;
import tools.jackson.databind.util.ClassUtil;
/**
* Builder object that can be used for per-serialization configuration of
* deserialization parameters, such as root type to use or object
* to update (instead of constructing new instance).
*<p>
* Uses "mutant factory" pattern so that instances are immutable
* (and thus fully thread-safe with no external synchronization);
* new instances are constructed for different configurations.
* Instances are initially constructed by {@link ObjectMapper} and can be
* reused, shared, cached; both because of thread-safety and because
* instances are relatively light-weight.
*<p>
* NOTE: this class is NOT meant as sub-classable by users. It is left as
* non-final mostly to allow frameworks that require byte code generation for proxying
* and similar use cases, but there is no expectation that functionality
* should be extended by sub-classing.
*/
public class ObjectReader
implements Versioned, TreeCodec
// NOTE: since 3.x, NO LONGER JDK Serializable
{
protected final static JavaType JSON_NODE_TYPE = SimpleType.constructUnsafe(JsonNode.class);
/*
/**********************************************************************
/* Immutable configuration from ObjectMapper
/**********************************************************************
*/
/**
* General serialization configuration settings; while immutable,
* can use copy-constructor to create modified instances as necessary.
*/
protected final DeserializationConfig _config;
/**
* Blueprint instance of deserialization context; used for creating
* actual instance when needed.
*/
protected final DeserializationContexts _contexts;
/**
* Factory used for constructing {@link JsonParser}s
*/
protected final TokenStreamFactory _parserFactory;
/**
* Flag that indicates whether root values are expected to be unwrapped or not
*/
protected final boolean _unwrapRoot;
/**
* Filter to be consider for JsonParser.
* Default value to be null as filter not considered.
*/
private final TokenFilter _filter;
/*
/**********************************************************************
/* Configuration that can be changed during building
/**********************************************************************
*/
/**
* Declared type of value to instantiate during deserialization.
* Defines which deserializer to use; as well as base type of instance
* to construct if an updatable value is not configured to be used
* (subject to changes by embedded type information, for polymorphic
* types). If {@link #_valueToUpdate} is non-null, only used for
* locating deserializer.
*/
protected final JavaType _valueType;
/**
* We may pre-fetch deserializer as soon as {@link #_valueType}
* is known, and if so, reuse it afterwards.
* This allows avoiding further deserializer lookups and increases
* performance a bit on cases where readers are reused.
*/
protected final ValueDeserializer<Object> _rootDeserializer;
/**
* Instance to update with data binding; if any. If null,
* a new instance is created, if non-null, properties of
* this value object will be updated instead.
* Note that value can be of almost any type, except not
* {@link tools.jackson.databind.type.ArrayType}; array
* types cannot be modified because array size is immutable.
*/
protected final Object _valueToUpdate;
/**
* When using data format that uses a schema, schema is passed
* to parser.
*/
protected final FormatSchema _schema;
/**
* Values that can be injected during deserialization, if any.
*/
protected final InjectableValues _injectableValues;
/*
/**********************************************************************
/* Caching
/**********************************************************************
*/
/**
* Root-level cached deserializers.
* Passed by {@link ObjectMapper}, shared with it.
*/
final protected ConcurrentHashMap<JavaType, ValueDeserializer<Object>> _rootDeserializers;
/*
/**********************************************************************
/* Life-cycle, construction
/**********************************************************************
*/
/**
* Constructor used by {@link ObjectMapper} for initial instantiation
*/
protected ObjectReader(ObjectMapper mapper, DeserializationConfig config) {
this(mapper, config, null, null, null, null);
}
/**
* Constructor called when a root deserializer should be fetched based
* on other configuration.
*/
protected ObjectReader(ObjectMapper mapper, DeserializationConfig config,
JavaType valueType, Object valueToUpdate,
FormatSchema schema, InjectableValues injectableValues)
{
_config = config;
_contexts = mapper._deserializationContexts;
_rootDeserializers = mapper._rootDeserializers;
_parserFactory = mapper._streamFactory;
_valueType = valueType;
_valueToUpdate = valueToUpdate;
_schema = schema;
_injectableValues = injectableValues;
_unwrapRoot = config.useRootWrapping();
_rootDeserializer = _prefetchRootDeserializer(valueType);
_filter = null;
}
/**
* Copy constructor used for building variations.
*/
protected ObjectReader(ObjectReader base, DeserializationConfig config,
JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate,
FormatSchema schema, InjectableValues injectableValues)
{
_config = config;
_contexts = base._contexts;
_rootDeserializers = base._rootDeserializers;
_parserFactory = base._parserFactory;
_valueType = valueType;
_rootDeserializer = rootDeser;
_valueToUpdate = valueToUpdate;
_schema = schema;
_injectableValues = injectableValues;
_unwrapRoot = config.useRootWrapping();
_filter = base._filter;
}
/**
* Copy constructor used when modifying simple feature flags
*/
protected ObjectReader(ObjectReader base, DeserializationConfig config)
{
_config = config;
_contexts = base._contexts;
_rootDeserializers = base._rootDeserializers;
_parserFactory = base._parserFactory;
_valueType = base._valueType;
_rootDeserializer = base._rootDeserializer;
_valueToUpdate = base._valueToUpdate;
_schema = base._schema;
_injectableValues = base._injectableValues;
_unwrapRoot = config.useRootWrapping();
_filter = base._filter;
}
protected ObjectReader(ObjectReader base, TokenFilter filter) {
_config = base._config;
_contexts = base._contexts;
_rootDeserializers = base._rootDeserializers;
_parserFactory = base._parserFactory;
_valueType = base._valueType;
_rootDeserializer = base._rootDeserializer;
_valueToUpdate = base._valueToUpdate;
_schema = base._schema;
_injectableValues = base._injectableValues;
_unwrapRoot = base._unwrapRoot;
_filter = filter;
}
/**
* Method that will return version information stored in and read from jar
* that contains this class.
*/
@Override
public Version version() {
return tools.jackson.databind.cfg.PackageVersion.VERSION;
}
/*
/**********************************************************************
/* Helper methods used internally for invoking constructors
/* Need to be overridden if sub-classing (not recommended)
/* is used.
/**********************************************************************
*/
/**
* Factory method called by various "withXxx()" methods
*/
protected ObjectReader _new(ObjectReader base, DeserializationConfig config) {
return new ObjectReader(base, config);
}
/**
* Factory method called by various "withXxx()" methods
*/
protected ObjectReader _new(ObjectReader base, DeserializationConfig config,
JavaType valueType, ValueDeserializer<Object> rootDeser, Object valueToUpdate,
FormatSchema schema, InjectableValues injectableValues) {
return new ObjectReader(base, config, valueType, rootDeser, valueToUpdate,
schema, injectableValues);
}
/**
* Factory method used to create {@link MappingIterator} instances;
* either default, or custom subtype.
*/
protected <T> MappingIterator<T> _newIterator(JsonParser p, DeserializationContext ctxt,
ValueDeserializer<?> deser, boolean parserManaged)
{
return new MappingIterator<T>(_valueType, p, ctxt,
deser, parserManaged, _valueToUpdate);
}
/*
/**********************************************************************
/* Methods for initializing parser instance to use
/**********************************************************************
*/
protected JsonToken _initForReading(DeserializationContextExt ctxt, JsonParser p)
{
ctxt.assignParser(p);
// First: must point to a token; if not pointing to one, advance.
// This occurs before first read from JsonParser, as well as
// after clearing of current token.
JsonToken t = p.currentToken();
if (t == null) { // and then we must get something...
t = p.nextToken();
if (t == null) {
// Throw mapping exception, since it's failure to map, not an actual parsing problem
ctxt.reportInputMismatch(_valueType,
"No content to map due to end-of-input");
}
}
return t;
}
/**
* Alternative to {@link #_initForReading} used in cases where reading
* of multiple values means that we may or may not want to advance the stream,
* but need to do other initialization.
*<p>
* Base implementation only sets configured {@link FormatSchema}, if any, on parser.
*/
protected void _initForMultiRead(DeserializationContextExt ctxt, JsonParser p)
{
ctxt.assignParser(p);
}
/*
/**********************************************************************
/* Life-cycle, fluent factory methods for DeserializationFeatures
/**********************************************************************
*/
/**
* Method for constructing a new reader instance that is configured
* with specified feature enabled.
*/
public ObjectReader with(DeserializationFeature feature) {
return _with(_config.with(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features enabled.
*/
public ObjectReader with(DeserializationFeature first,
DeserializationFeature... other)
{
return _with(_config.with(first, other));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features enabled.
*/
public ObjectReader withFeatures(DeserializationFeature... features) {
return _with(_config.withFeatures(features));
}
/**
* Method for constructing a new reader instance that is configured
* with specified feature disabled.
*/
public ObjectReader without(DeserializationFeature feature) {
return _with(_config.without(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features disabled.
*/
public ObjectReader without(DeserializationFeature first,
DeserializationFeature... other) {
return _with(_config.without(first, other));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features disabled.
*/
public ObjectReader withoutFeatures(DeserializationFeature... features) {
return _with(_config.withoutFeatures(features));
}
/*
/**********************************************************************
/* Life-cycle, fluent factory methods for DatatypeFeatures
/**********************************************************************
*/
/**
* Method for constructing a new reader instance that is configured
* with specified feature enabled.
*/
public ObjectReader with(DatatypeFeature feature) {
return _with(_config.with(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features enabled.
*/
public ObjectReader withFeatures(DatatypeFeature... features) {
return _with(_config.withFeatures(features));
}
/**
* Method for constructing a new reader instance that is configured
* with specified feature disabled.
*/
public ObjectReader without(DatatypeFeature feature) {
return _with(_config.without(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features disabled.
*/
public ObjectReader withoutFeatures(DatatypeFeature... features) {
return _with(_config.withoutFeatures(features));
}
/*
/**********************************************************
/* Life-cycle, fluent factory methods for StreamReadFeatures
/**********************************************************
*/
/**
* Method for constructing a new reader instance that is configured
* with specified feature enabled.
*/
public ObjectReader with(StreamReadFeature feature) {
return _with(_config.with(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features enabled.
*/
public ObjectReader withFeatures(StreamReadFeature... features) {
return _with(_config.withFeatures(features));
}
/**
* Method for constructing a new reader instance that is configured
* with specified feature disabled.
*/
public ObjectReader without(StreamReadFeature feature) {
return _with(_config.without(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features disabled.
*/
public ObjectReader withoutFeatures(StreamReadFeature... features) {
return _with(_config.withoutFeatures(features));
}
/*
/**********************************************************************
/* Life-cycle, fluent factory methods for FormatFeature
/**********************************************************************
*/
/**
* Method for constructing a new reader instance that is configured
* with specified feature enabled.
*/
public ObjectReader with(FormatFeature feature) {
return _with(_config.with(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features enabled.
*/
public ObjectReader withFeatures(FormatFeature... features) {
return _with(_config.withFeatures(features));
}
/**
* Method for constructing a new reader instance that is configured
* with specified feature disabled.
*/
public ObjectReader without(FormatFeature feature) {
return _with(_config.without(feature));
}
/**
* Method for constructing a new reader instance that is configured
* with specified features disabled.
*/
public ObjectReader withoutFeatures(FormatFeature... features) {
return _with(_config.withoutFeatures(features));
}
/*
/**********************************************************************
/* Life-cycle, fluent factory methods, other
/**********************************************************************
*/
/**
* Convenience method to bind from {@link JsonPointer}.
* {@link JsonPointerBasedFilter} is registered and will be used for parsing later.
*/
public ObjectReader at(String pointerExpr) {
_assertNotNull("pointerExpr", pointerExpr);
return new ObjectReader(this, new JsonPointerBasedFilter(pointerExpr));
}
/**
* Convenience method to bind from {@link JsonPointer}
* {@link JsonPointerBasedFilter} is registered and will be used for parsing later.
*/
public ObjectReader at(JsonPointer pointer) {
_assertNotNull("pointer", pointer);
return new ObjectReader(this, new JsonPointerBasedFilter(pointer));
}
/**
* Mutant factory method that will construct a new instance that has
* specified underlying {@link DeserializationConfig}.
*<p>
* NOTE: use of this method is not recommended, as there are many other
* re-configuration methods available.
*/
public ObjectReader with(DeserializationConfig config) {
return _with(config);
}
/**
* Method for constructing a new instance with configuration that uses
* passed {@link InjectableValues} to provide injectable values.
*<p>
* Note that the method does NOT change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader with(InjectableValues injectableValues)
{
if (_injectableValues == injectableValues) {
return this;
}
return _new(this, _config,
_valueType, _rootDeserializer, _valueToUpdate,
_schema, injectableValues);
}
/**
* Method for constructing a new reader instance with configuration that uses
* passed {@link JsonNodeFactory} for constructing {@link JsonNode}
* instances.
*<p>
* Note that the method does NOT change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader with(JsonNodeFactory f) {
return _with(_config.with(f));
}
/**
* Method for constructing a new instance with configuration that
* specifies what root name to expect for "root name unwrapping".
* See {@link DeserializationConfig#withRootName(String)} for
* details.
*<p>
* Note that the method does NOT change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader withRootName(String rootName) {
return _with(_config.withRootName(rootName));
}
public ObjectReader withRootName(PropertyName rootName) {
return _with(_config.withRootName(rootName));
}
/**
* Convenience method that is same as calling:
*<code>
* withRootName("")
*</code>
* which will forcibly prevent use of root name wrapping when writing
* values with this {@link ObjectReader}.
*/
public ObjectReader withoutRootName() {
return _with(_config.withRootName(PropertyName.NO_NAME));
}
/**
* Method for constructing a new instance with configuration that
* passes specified {@link FormatSchema} to {@link JsonParser} that
* is constructed for parsing content.
*<p>
* Note that the method does NOT change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader with(FormatSchema schema)
{
if (_schema == schema) {
return this;
}
_verifySchemaType(schema);
return _new(this, _config, _valueType, _rootDeserializer, _valueToUpdate,
schema, _injectableValues);
}
/**
* Method for constructing a new reader instance that is configured
* to data bind into specified type.
*<p>
* Note that the method does not change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader forType(JavaType valueType)
{
if (valueType != null && valueType.equals(_valueType)) {
return this;
}
ValueDeserializer<Object> rootDeser = _prefetchRootDeserializer(valueType);
return _new(this, _config, valueType, rootDeser,
_valueToUpdate, _schema, _injectableValues);
}
/**
* Method for constructing a new reader instance that is configured
* to data bind into specified type.
*<p>
* Note that the method does not change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader forType(Class<?> valueType) {
return forType(_config.constructType(valueType));
}
/**
* Method for constructing a new reader instance that is configured
* to data bind into specified type.
*<p>
* Note that the method does not change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader forType(TypeReference<?> valueTypeRef) {
return forType(_config.getTypeFactory().constructType(valueTypeRef.getType()));
}
/**
* Method for constructing a new instance with configuration that
* updates passed Object (as root value), instead of constructing
* a new value.
*<p>
* Note that the method does NOT change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader withValueToUpdate(Object value)
{
if (value == _valueToUpdate) return this;
if (value == null) {
// 18-Oct-2016, tatu: Actually, should be allowed, to remove value
// to update, if any
return _new(this, _config, _valueType, _rootDeserializer, null,
_schema, _injectableValues);
}
JavaType t;
/* no real benefit from pre-fetching, as updating readers are much
* less likely to be reused, and value type may also be forced
* with a later chained call...
*/
if (_valueType == null) {
t = _config.constructType(value.getClass());
} else {
t = _valueType;
}
return _new(this, _config, t, _rootDeserializer, value,
_schema, _injectableValues);
}
/**
* Method for constructing a new instance with configuration that
* uses specified View for filtering.
*<p>
* Note that the method does NOT change state of this reader, but
* rather construct and returns a newly configured instance.
*/
public ObjectReader withView(Class<?> activeView) {
return _with(_config.withView(activeView));
}
public ObjectReader with(Locale l) {
return _with(_config.with(l));
}
public ObjectReader with(TimeZone tz) {
return _with(_config.with(tz));
}
public ObjectReader withHandler(DeserializationProblemHandler h) {
return _with(_config.withHandler(h));
}
public ObjectReader with(Base64Variant defaultBase64) {
return _with(_config.with(defaultBase64));
}
/**
* Mutant factory for overriding set of (default) attributes for
* {@link ObjectReader} to use.
*<p>
* Note that this will replace defaults passed by {@link ObjectMapper}.
*
* @param attrs Default {@link ContextAttributes} to use with a reader
*
* @return {@link ObjectReader} instance with specified default attributes (which
* is usually a newly constructed reader instance with otherwise identical settings)
*/
public ObjectReader with(ContextAttributes attrs) {
return _with(_config.with(attrs));
}
public ObjectReader withAttributes(Map<?,?> attrs) {
return _with(_config.withAttributes(attrs));
}
public ObjectReader withAttribute(Object key, Object value) {
return _with( _config.withAttribute(key, value));
}
public ObjectReader withoutAttribute(Object key) {
return _with(_config.withoutAttribute(key));
}
/*
/**********************************************************************
/* Internal factory methods
/**********************************************************************
*/
protected final ObjectReader _with(DeserializationConfig newConfig) {
if (newConfig == _config) {
return this;
}
return _new(this, newConfig);
}
/*
/**********************************************************************
/* Simple accessors
/**********************************************************************
*/
public boolean isEnabled(DeserializationFeature f) {
return _config.isEnabled(f);
}
public boolean isEnabled(MapperFeature f) {
return _config.isEnabled(f);
}
public boolean isEnabled(DatatypeFeature f) {
return _config.isEnabled(f);
}
public boolean isEnabled(StreamReadFeature f) {
return _config.isEnabled(f);
}
public DeserializationConfig getConfig() {
return _config;
}
/**
* @since 3.0
*/
public TokenStreamFactory parserFactory() {
return _parserFactory;
}
/**
* @since 3.0
*/
public TypeFactory typeFactory() {
return _config.getTypeFactory();
}
public ContextAttributes getAttributes() {
return _config.getAttributes();
}
public InjectableValues getInjectableValues() {
return _injectableValues;
}
public JavaType getValueType() {
return _valueType;
}
/**
* @deprecated Since 3.0 use {@link #typeFactory}
*/
@Deprecated
public TypeFactory getTypeFactory() {
return typeFactory();
}
/*
/**********************************************************************
/* Public API: constructing Parsers that are properly linked
/* to `ObjectReadContext`
/**********************************************************************
*/
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,java.io.File)}.
*
* @since 3.0
*/
public JsonParser createParser(File src) throws JacksonException {
_assertNotNull("src", src);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, src));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,Path)}.
*
* @since 3.0
*/
public JsonParser createParser(Path src) throws JacksonException {
_assertNotNull("src", src);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, src));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,java.net.URL)}.
*
* @since 3.0
*/
public JsonParser createParser(URL src) throws JacksonException {
_assertNotNull("src", src);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, src));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,InputStream)}.
*
* @since 3.0
*/
public JsonParser createParser(InputStream src) throws JacksonException {
_assertNotNull("src", src);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, src));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,Reader)}.
*
* @since 3.0
*/
public JsonParser createParser(Reader src) throws JacksonException {
_assertNotNull("src", src);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, src));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,byte[])}.
*
* @since 3.0
*/
public JsonParser createParser(byte[] content) throws JacksonException {
_assertNotNull("content", content);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, content));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,byte[],int,int)}.
*
* @since 3.0
*/
public JsonParser createParser(byte[] content, int offset, int len) throws JacksonException {
_assertNotNull("content", content);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, content, offset, len));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,String)}.
*
* @since 3.0
*/
public JsonParser createParser(String content) throws JacksonException {
_assertNotNull("content", content);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, content));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,char[])}.
*
* @since 3.0
*/
public JsonParser createParser(char[] content) throws JacksonException {
_assertNotNull("content", content);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, content));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,char[],int,int)}.
*
* @since 3.0
*/
public JsonParser createParser(char[] content, int offset, int len) throws JacksonException {
_assertNotNull("content", content);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, content, offset, len));
}
/**
* Factory method for constructing {@link JsonParser} that is properly
* wired to allow callbacks for deserialization: basically
* constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createParser(ObjectReadContext,DataInput)}.
*
* @since 3.0
*/
public JsonParser createParser(DataInput content) throws JacksonException {
_assertNotNull("content", content);
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createParser(ctxt, content));
}
/**
* Factory method for constructing non-blocking {@link JsonParser} that is properly
* wired to allow configuration access (and, if relevant for parser, callbacks):
* essentially constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createNonBlockingByteArrayParser(ObjectReadContext)}.
*
* @since 3.0
*/
public JsonParser createNonBlockingByteArrayParser() throws JacksonException {
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createNonBlockingByteArrayParser(ctxt));
}
/**
* Factory method for constructing non-blocking {@link JsonParser} that is properly
* wired to allow configuration access (and, if relevant for parser, callbacks):
* essentially constructs a {@link ObjectReadContext} and then calls
* {@link TokenStreamFactory#createNonBlockingByteBufferParser(ObjectReadContext)}.
*
* @since 3.0
*/
public JsonParser createNonBlockingByteBufferParser() throws JacksonException {
DeserializationContextExt ctxt = _deserializationContext();
return ctxt.assignAndReturnParser(_parserFactory.createNonBlockingByteBufferParser(ctxt));
}
/*
/**********************************************************************
/* TreeCodec implementation
/**********************************************************************
*/
@Override
public ObjectNode createObjectNode() {
return _config.getNodeFactory().objectNode();
}
@Override
public ArrayNode createArrayNode() {
return _config.getNodeFactory().arrayNode();
}