@@ -42,34 +42,15 @@ public class JsonFactory
42
42
java .io .Serializable // since 2.1 (for Android, mostly)
43
43
{
44
44
/**
45
- * Computed for Jackson 2.1 .0 release
45
+ * Computed for Jackson 2.2 .0 release
46
46
*/
47
47
private static final long serialVersionUID = 8726401676402117450L ;
48
48
49
- /**
50
- * Name used to identify JSON format
51
- * (and returned by {@link #getFormatName()}
52
- */
53
- public final static String FORMAT_NAME_JSON = "JSON" ;
54
-
55
- /**
56
- * Bitfield (set of flags) of all factory features that are enabled by default.
57
- */
58
- protected final static int DEFAULT_FACTORY_FEATURE_FLAGS = JsonFactory .Feature .collectDefaults ();
59
-
60
- /**
61
- * Bitfield (set of flags) of all parser features that are enabled
62
- * by default.
63
- */
64
- protected final static int DEFAULT_PARSER_FEATURE_FLAGS = JsonParser .Feature .collectDefaults ();
65
-
66
- /**
67
- * Bitfield (set of flags) of all generator features that are enabled
68
- * by default.
49
+ /*
50
+ /**********************************************************
51
+ /* Helper types
52
+ /**********************************************************
69
53
*/
70
- protected final static int DEFAULT_GENERATOR_FEATURE_FLAGS = JsonGenerator .Feature .collectDefaults ();
71
-
72
- private final static SerializableString DEFAULT_ROOT_VALUE_SEPARATOR = DefaultPrettyPrinter .DEFAULT_ROOT_VALUE_SEPARATOR ;
73
54
74
55
/**
75
56
* Enumeration that defines all on/off features that can only be
@@ -138,7 +119,39 @@ private Feature(boolean defaultState)
138
119
public boolean enabledIn (int flags ) { return (flags & getMask ()) != 0 ; }
139
120
140
121
public int getMask () { return (1 << ordinal ()); }
141
- }
122
+ }
123
+
124
+ /*
125
+ /**********************************************************
126
+ /* Constants
127
+ /**********************************************************
128
+ */
129
+
130
+ /**
131
+ * Name used to identify JSON format
132
+ * (and returned by {@link #getFormatName()}
133
+ */
134
+ public final static String FORMAT_NAME_JSON = "JSON" ;
135
+
136
+ /**
137
+ * Bitfield (set of flags) of all factory features that are enabled by default.
138
+ */
139
+ protected final static int DEFAULT_FACTORY_FEATURE_FLAGS = JsonFactory .Feature .collectDefaults ();
140
+
141
+ /**
142
+ * Bitfield (set of flags) of all parser features that are enabled
143
+ * by default.
144
+ */
145
+ protected final static int DEFAULT_PARSER_FEATURE_FLAGS = JsonParser .Feature .collectDefaults ();
146
+
147
+ /**
148
+ * Bitfield (set of flags) of all generator features that are enabled
149
+ * by default.
150
+ */
151
+ protected final static int DEFAULT_GENERATOR_FEATURE_FLAGS = JsonGenerator .Feature .collectDefaults ();
152
+
153
+ private final static SerializableString DEFAULT_ROOT_VALUE_SEPARATOR = DefaultPrettyPrinter .DEFAULT_ROOT_VALUE_SEPARATOR ;
154
+
142
155
/*
143
156
/**********************************************************
144
157
/* Buffer, symbol table management
@@ -243,27 +256,53 @@ private Feature(boolean defaultState)
243
256
* and this reuse only works within context of a single
244
257
* factory instance.
245
258
*/
246
- public JsonFactory () { this (null ); }
259
+ public JsonFactory () { this (( ObjectCodec ) null ); }
247
260
248
261
public JsonFactory (ObjectCodec oc ) { _objectCodec = oc ; }
249
262
263
+ /**
264
+ * Constructor used when copy()ing a factory instance.
265
+ *
266
+ * @since 2.2.1
267
+ */
268
+ protected JsonFactory (JsonFactory src , ObjectCodec codec )
269
+ {
270
+ _objectCodec = null ;
271
+ _factoryFeatures = src ._factoryFeatures ;
272
+ _parserFeatures = src ._parserFeatures ;
273
+ _generatorFeatures = src ._generatorFeatures ;
274
+ _characterEscapes = src ._characterEscapes ;
275
+ _inputDecorator = src ._inputDecorator ;
276
+ _outputDecorator = src ._outputDecorator ;
277
+ _rootValueSeparator = src ._rootValueSeparator ;
278
+
279
+ /* 27-Apr-2013, tatu: How about symbol table; should we try to
280
+ * reuse shared symbol tables? Could be more efficient that way;
281
+ * although can slightly add to concurrency overhead.
282
+ */
283
+ }
284
+
250
285
/**
251
286
* Method for constructing a new {@link JsonFactory} that has
252
287
* the same settings as this instance, but is otherwise
253
288
* independent (i.e. nothing is actually shared, symbol tables
254
289
* are separate).
255
290
* Note that {@link ObjectCodec} reference is not copied but is
256
291
* set to null; caller typically needs to set it after calling
257
- * this method.
292
+ * this method. Reason for this is that the codec is used for
293
+ * callbacks, and assumption is that there is strict 1-to-1
294
+ * mapping between codec, factory. Caller has to, then, explicitly
295
+ * set codec after making the copy.
258
296
*
259
297
* @since 2.1
260
298
*/
261
299
public JsonFactory copy ()
262
300
{
263
301
_checkInvalidCopy (JsonFactory .class );
264
- return new JsonFactory (null );
302
+ // as per above, do clear ObjectCodec
303
+ return new JsonFactory (this , null );
265
304
}
266
-
305
+
267
306
/**
268
307
* @since 2.1
269
308
* @param exp
0 commit comments