@@ -1204,8 +1204,6 @@ public JsonNode readTree(File file) throws JacksonException
1204
1204
/**
1205
1205
* Same as {@link #readTree(InputStream)} except content read from
1206
1206
* passed-in {@link Path}.
1207
- *
1208
- * @since 3.0
1209
1207
*/
1210
1208
public JsonNode readTree (Path path ) throws JacksonException
1211
1209
{
@@ -1230,6 +1228,16 @@ public JsonNode readTree(URL src) throws JacksonException {
1230
1228
return _readTreeAndClose (ctxt , _streamFactory .createParser (ctxt , src ));
1231
1229
}
1232
1230
1231
+ /**
1232
+ * Same as {@link #readTree(InputStream)} except content read from
1233
+ * passed-in {@link TokenBuffer}.
1234
+ */
1235
+ public JsonNode readTree (TokenBuffer src ) throws JacksonException {
1236
+ _assertNotNull ("src" , src );
1237
+ DeserializationContextExt ctxt = _deserializationContext ();
1238
+ return _readTreeAndClose (ctxt , src .asParser (ctxt ));
1239
+ }
1240
+
1233
1241
/*
1234
1242
/**********************************************************************
1235
1243
/* Public API serialization
@@ -1774,6 +1782,33 @@ public <T> T readValue(DataInput src, TypeReference<T> valueTypeRef) throws Jack
1774
1782
_streamFactory .createParser (ctxt , src ), _typeFactory .constructType (valueTypeRef ));
1775
1783
}
1776
1784
1785
+ @ SuppressWarnings ("unchecked" )
1786
+ public <T > T readValue (TokenBuffer src , Class <T > valueType ) throws JacksonException
1787
+ {
1788
+ _assertNotNull ("src" , src );
1789
+ DeserializationContextExt ctxt = _deserializationContext ();
1790
+ return (T ) _readMapAndClose (ctxt ,
1791
+ src .asParser (ctxt ), _typeFactory .constructType (valueType ));
1792
+ }
1793
+
1794
+ @ SuppressWarnings ("unchecked" )
1795
+ public <T > T readValue (TokenBuffer src , JavaType valueType ) throws JacksonException
1796
+ {
1797
+ _assertNotNull ("src" , src );
1798
+ DeserializationContextExt ctxt = _deserializationContext ();
1799
+ return (T ) _readMapAndClose (ctxt ,
1800
+ src .asParser (ctxt ), valueType );
1801
+ }
1802
+
1803
+ @ SuppressWarnings ("unchecked" )
1804
+ public <T > T readValue (TokenBuffer src , TypeReference <T > valueTypeRef ) throws JacksonException
1805
+ {
1806
+ _assertNotNull ("src" , src );
1807
+ DeserializationContextExt ctxt = _deserializationContext ();
1808
+ return (T ) _readMapAndClose (ctxt ,
1809
+ src .asParser (ctxt ), _typeFactory .constructType (valueTypeRef ));
1810
+ }
1811
+
1777
1812
/*
1778
1813
/**********************************************************************
1779
1814
/* Public API: serialization (mapping from Java types to external format)
@@ -1891,6 +1926,20 @@ public byte[] writeValueAsBytes(Object value) throws JacksonException
1891
1926
}
1892
1927
}
1893
1928
1929
+ /**
1930
+ * Convenience method that can be used to serialize any Java value into newly created
1931
+ * {@link TokenBuffer}. Functionally equivalent to calling
1932
+ * {@link #writeValue(JsonGenerator, Object)} passing buffer as generator.
1933
+ */
1934
+ public TokenBuffer writeValueIntoBuffer (Object value ) throws JacksonException
1935
+ {
1936
+ final SerializationContextExt ctxt = _serializationContext ();
1937
+ try (TokenBuffer buf = ctxt .bufferForValueConversion ()) {
1938
+ _configAndWriteValue (ctxt , buf , value );
1939
+ return buf ;
1940
+ }
1941
+ }
1942
+
1894
1943
/**
1895
1944
* Method called to configure the generator as necessary and then
1896
1945
* call write functionality
0 commit comments