2
2
3
3
import java .io .*;
4
4
import java .net .URL ;
5
+ import java .nio .file .Path ;
5
6
6
7
import com .fasterxml .jackson .core .*;
7
8
import com .fasterxml .jackson .core .io .IOContext ;
@@ -63,19 +64,35 @@ public boolean canHandleBinaryNatively() {
63
64
*/
64
65
65
66
@ Override
66
- public JsonParser createParser (ObjectReadContext readCtxt , File f ) throws JacksonException {
67
+ public JsonParser createParser (ObjectReadContext readCtxt ,
68
+ File f ) throws JacksonException
69
+ {
67
70
final InputStream in = _fileInputStream (f );
68
71
// true, since we create InputStream from File
69
72
final IOContext ioCtxt = _createContext (f , true );
70
- return _createParser (readCtxt , ioCtxt , _decorate (ioCtxt , in ));
73
+ return _createParser (readCtxt , ioCtxt ,
74
+ _decorate (ioCtxt , in ));
75
+ }
76
+
77
+ @ Override
78
+ public JsonParser createParser (ObjectReadContext readCtxt ,
79
+ Path p ) throws JacksonException
80
+ {
81
+ // true, since we create InputStream from Path
82
+ IOContext ioCtxt = _createContext (p , true );
83
+ return _createParser (readCtxt , ioCtxt ,
84
+ _decorate (ioCtxt , _pathInputStream (p )));
71
85
}
72
86
73
87
@ Override
74
- public JsonParser createParser (ObjectReadContext readCtxt , URL url ) throws JacksonException {
88
+ public JsonParser createParser (ObjectReadContext readCtxt ,
89
+ URL url ) throws JacksonException
90
+ {
75
91
// true, since we create InputStream from URL
76
92
IOContext ioCtxt = _createContext (url , true );
77
93
InputStream in = _optimizedStreamFromURL (url );
78
- return _createParser (readCtxt , ioCtxt , _decorate (ioCtxt , in ));
94
+ return _createParser (readCtxt , ioCtxt ,
95
+ _decorate (ioCtxt , in ));
79
96
}
80
97
81
98
@ Override
@@ -121,7 +138,7 @@ public JsonParser createParser(ObjectReadContext readCtxt,
121
138
IOContext ioCtxt = _createContext (in , false );
122
139
return _createParser (readCtxt , ioCtxt , _decorate (ioCtxt , in ));
123
140
}
124
-
141
+
125
142
protected abstract JsonParser _createParser (ObjectReadContext readCtxt ,
126
143
IOContext ioCtxt , InputStream in ) throws JacksonException ;
127
144
@@ -137,26 +154,6 @@ protected abstract JsonParser _createParser(ObjectReadContext readCtxt,
137
154
/**********************************************************************
138
155
*/
139
156
140
- /*
141
- @Override
142
- public JsonGenerator createGenerator(OutputStream out, JsonEncoding enc)
143
- throws JacksonException
144
- {
145
- // false -> we won't manage the stream unless explicitly directed to
146
- IOContext ioCtxt = _createContext(out, false, enc);
147
- return _createGenerator(EMPTY_WRITE_CONTEXT, ioCtxt, _decorate(ioCtxt, out));
148
- }
149
-
150
- @Override
151
- public JsonGenerator createGenerator(File f, JsonEncoding enc) throws JacksonException
152
- {
153
- OutputStream out = new FileOutputStream(f);
154
- // true -> yes, we have to manage the stream since we created it
155
- IOContext ioCtxt = _createContext(out, true, enc);
156
- return _createGenerator(EMPTY_WRITE_CONTEXT, ioCtxt, _decorate(ioCtxt, out));
157
- }
158
- */
159
-
160
157
@ Override
161
158
public JsonGenerator createGenerator (ObjectWriteContext writeCtxt ,
162
159
OutputStream out , JsonEncoding enc )
@@ -169,7 +166,8 @@ public JsonGenerator createGenerator(ObjectWriteContext writeCtxt,
169
166
170
167
@ Override
171
168
public JsonGenerator createGenerator (ObjectWriteContext writeCtxt ,
172
- Writer w ) throws JacksonException {
169
+ Writer w ) throws JacksonException
170
+ {
173
171
return _nonByteTarget ();
174
172
}
175
173
@@ -183,6 +181,16 @@ public JsonGenerator createGenerator(ObjectWriteContext writeCtxt,
183
181
return _createGenerator (writeCtxt , ioCtxt , _decorate (ioCtxt , out ));
184
182
}
185
183
184
+ @ Override
185
+ public JsonGenerator createGenerator (ObjectWriteContext writeCtxt ,
186
+ Path p , JsonEncoding enc )
187
+ throws JacksonException
188
+ {
189
+ final OutputStream out = _pathOutputStream (p );
190
+ final IOContext ioCtxt = _createContext (p , true , enc );
191
+ return _createGenerator (writeCtxt , ioCtxt , _decorate (ioCtxt , out ));
192
+ }
193
+
186
194
/*
187
195
/**********************************************************************
188
196
/* Factory methods: abstract, for sub-classes to implement
0 commit comments