1 package de.juplo.simplemapper;
4 import com.fasterxml.jackson.core.JsonFactory;
6 import java.io.IOException;
7 import java.io.InputStream;
10 import java.util.Iterator;
11 import java.util.List;
13 import java.util.Spliterator;
14 import java.util.stream.Stream;
15 import org.springframework.beans.factory.InitializingBean;
16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.util.Assert;
25 public class SimpleMapperService
31 @Autowired(required = false)
32 private JsonFactory factory;
35 public SimpleMapperService() {}
37 public SimpleMapperService(JsonFactory factory)
39 this.factory = factory;
44 public void afterPropertiesSet() throws Exception
46 Assert.notNull(factory, "The attribute factory must be set!");
49 public JsonFactory getFactory()
55 public Spliterator<Object> getArraySpliterator(File file)
59 return getArraySpliterator(factory.createParser(file));
62 public Spliterator<Object> getArraySpliterator(InputStream is)
66 return getArraySpliterator(factory.createParser(is));
69 public Spliterator<Object> getArraySpliterator(Reader r)
73 return getArraySpliterator(factory.createParser(r));
76 public Spliterator<Object> getArraySpliterator(String content)
80 return getArraySpliterator(factory.createParser(content));
83 public Spliterator<Object> getArraySpliterator(URL url)
87 return getArraySpliterator(factory.createParser(url));
90 public Spliterator<Object> getArraySpliterator(byte[] data)
94 return getArraySpliterator(factory.createParser(data));
97 public Spliterator<Object> getArraySpliterator(char[] content)
101 return getArraySpliterator(factory.createParser(content));
104 public Spliterator<Object> getArraySpliterator(byte[] data, int offset, int len)
108 return getArraySpliterator(factory.createParser(data, offset, len));
111 public Spliterator<Object> getArraySpliterator(char[] data, int offset, int len)
115 return getArraySpliterator(factory.createParser(data, offset, len));
118 public Stream<Object> getArrayStream(File file)
122 return getArrayStream(factory.createParser(file));
125 public Stream<Object> getArrayStream(InputStream is)
129 return getArrayStream(factory.createParser(is));
132 public Stream<Object> getArrayStream(Reader r)
136 return getArrayStream(factory.createParser(r));
139 public Stream<Object> getArrayStream(String content)
143 return getArrayStream(factory.createParser(content));
146 public Stream<Object> getArrayStream(URL url)
150 return getArrayStream(factory.createParser(url));
153 public Stream<Object> getArrayStream(byte[] data)
157 return getArrayStream(factory.createParser(data));
160 public Stream<Object> getArrayStream(char[] content)
164 return getArrayStream(factory.createParser(content));
167 public Stream<Object> getArrayStream(byte[] data, int offset, int len)
171 return getArrayStream(factory.createParser(data, offset, len));
174 public Stream<Object> getArrayStream(char[] data, int offset, int len)
178 return getArrayStream(factory.createParser(data, offset, len));
181 public Iterator<Object> getArrayIterator(File file)
185 return getArrayIterator(factory.createParser(file));
188 public Iterator<Object> getArrayIterator(InputStream is)
192 return getArrayIterator(factory.createParser(is));
195 public Iterator<Object> getArrayIterator(Reader r)
199 return getArrayIterator(factory.createParser(r));
202 public Iterator<Object> getArrayIterator(String content)
206 return getArrayIterator(factory.createParser(content));
209 public Iterator<Object> getArrayIterator(URL url)
213 return getArrayIterator(factory.createParser(url));
216 public Iterator<Object> getArrayIterator(byte[] data)
220 return getArrayIterator(factory.createParser(data));
223 public Iterator<Object> getArrayIterator(char[] content)
227 return getArrayIterator(factory.createParser(content));
230 public Iterator<Object> getArrayIterator(byte[] data, int offset, int len)
234 return getArrayIterator(factory.createParser(data, offset, len));
237 public Iterator<Object> getArrayIterator(char[] data, int offset, int len)
241 return getArrayIterator(factory.createParser(data, offset, len));
245 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(File file)
249 return getObjectSpliterator(factory.createParser(file));
252 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(InputStream is)
256 return getObjectSpliterator(factory.createParser(is));
259 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(Reader r)
263 return getObjectSpliterator(factory.createParser(r));
266 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(String content)
270 return getObjectSpliterator(factory.createParser(content));
273 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(URL url)
277 return getObjectSpliterator(factory.createParser(url));
280 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(byte[] data)
284 return getObjectSpliterator(factory.createParser(data));
287 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(char[] content)
291 return getObjectSpliterator(factory.createParser(content));
294 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(byte[] data, int offset, int len)
298 return getObjectSpliterator(factory.createParser(data, offset, len));
301 public Spliterator<Map.Entry<String, Object>> getObjectSpliterator(char[] data, int offset, int len)
305 return getObjectSpliterator(factory.createParser(data, offset, len));
308 public Stream<Map.Entry<String, Object>> getObjectStream(File file)
312 return getObjectStream(factory.createParser(file));
315 public Stream<Map.Entry<String, Object>> getObjectStream(InputStream is)
319 return getObjectStream(factory.createParser(is));
322 public Stream<Map.Entry<String, Object>> getObjectStream(Reader r)
326 return getObjectStream(factory.createParser(r));
329 public Stream<Map.Entry<String, Object>> getObjectStream(String content)
333 return getObjectStream(factory.createParser(content));
336 public Stream<Map.Entry<String, Object>> getObjectStream(URL url)
340 return getObjectStream(factory.createParser(url));
343 public Stream<Map.Entry<String, Object>> getObjectStream(byte[] data)
347 return getObjectStream(factory.createParser(data));
350 public Stream<Map.Entry<String, Object>> getObjectStream(char[] content)
354 return getObjectStream(factory.createParser(content));
357 public Stream<Map.Entry<String, Object>> getObjectStream(byte[] data, int offset, int len)
361 return getObjectStream(factory.createParser(data, offset, len));
364 public Stream<Map.Entry<String, Object>> getObjectStream(char[] data, int offset, int len)
368 return getObjectStream(factory.createParser(data, offset, len));
371 public Iterator<Map.Entry<String, Object>> getObjectIterator(File file)
375 return getObjectIterator(factory.createParser(file));
378 public Iterator<Map.Entry<String, Object>> getObjectIterator(InputStream is)
382 return getObjectIterator(factory.createParser(is));
385 public Iterator<Map.Entry<String, Object>> getObjectIterator(Reader r)
389 return getObjectIterator(factory.createParser(r));
392 public Iterator<Map.Entry<String, Object>> getObjectIterator(String content)
396 return getObjectIterator(factory.createParser(content));
399 public Iterator<Map.Entry<String, Object>> getObjectIterator(URL url)
403 return getObjectIterator(factory.createParser(url));
406 public Iterator<Map.Entry<String, Object>> getObjectIterator(byte[] data)
410 return getObjectIterator(factory.createParser(data));
413 public Iterator<Map.Entry<String, Object>> getObjectIterator(char[] content)
417 return getObjectIterator(factory.createParser(content));
420 public Iterator<Map.Entry<String, Object>> getObjectIterator(byte[] data, int offset, int len)
424 return getObjectIterator(factory.createParser(data, offset, len));
427 public Iterator<Map.Entry<String, Object>> getObjectIterator(char[] data, int offset, int len)
431 return getObjectIterator(factory.createParser(data, offset, len));
435 public List<Object> convertArray(File file) throws Exception
437 return convertArray(factory.createParser(file));
440 public List<Object> convertArray(InputStream is) throws Exception
442 return convertArray(factory.createParser(is));
445 public List<Object> convertArray(Reader r) throws Exception
447 return convertArray(factory.createParser(r));
450 public List<Object> convertArray(String content) throws Exception
452 return convertArray(factory.createParser(content));
455 public List<Object> convertArray(URL url) throws Exception
457 return convertArray(factory.createParser(url));
460 public List<Object> convertArray(byte[] data) throws Exception
462 return convertArray(factory.createParser(data));
465 public List<Object> convertArray(char[] content) throws Exception
467 return convertArray(factory.createParser(content));
470 public List<Object> convertArray(byte[] data, int offset, int len)
474 return convertArray(factory.createParser(data, offset, len));
477 public List<Object> convertArray(char[] content, int offset, int len)
481 return convertArray(factory.createParser(content, offset, len));
484 public Map<String, Object> convertObject(File file) throws Exception
486 return convertObject(factory.createParser(file));
489 public Map<String, Object> convertObject(InputStream is) throws Exception
491 return convertObject(factory.createParser(is));
494 public Map<String, Object> convertObject(Reader r) throws Exception
496 return convertObject(factory.createParser(r));
499 public Map<String, Object> convertObject(String content) throws Exception
501 return convertObject(factory.createParser(content));
504 public Map<String, Object> convertObject(URL url) throws Exception
506 return convertObject(factory.createParser(url));
509 public Map<String, Object> convertObject(byte[] data) throws Exception
511 return convertObject(factory.createParser(data));
514 public Map<String, Object> convertObject(char[] content) throws Exception
516 return convertObject(factory.createParser(content));
519 public Map<String, Object> convertObject(byte[] data, int offset, int len)
523 return convertObject(factory.createParser(data, offset, len));
526 public Map<String, Object> convertObject(char[] content, int offset, int len)
530 return convertObject(factory.createParser(content, offset, len));
533 public Object convert(File file) throws Exception
535 return convert(factory.createParser(file));
538 public Object convert(InputStream is) throws Exception
540 return convert(factory.createParser(is));
543 public Object convert(Reader r) throws Exception
545 return convert(factory.createParser(r));
548 public Object convert(String content) throws Exception
550 return convert(factory.createParser(content));
553 public Object convert(URL url) throws Exception
555 return convert(factory.createParser(url));
558 public Object convert(byte[] data) throws Exception
560 return convert(factory.createParser(data));
563 public Object convert(char[] content) throws Exception
565 return convert(factory.createParser(content));
568 public Object convert(byte[] data, int offset, int len)
572 return convert(factory.createParser(data, offset, len));
575 public Object convert(char[] content, int offset, int len)
579 return convert(factory.createParser(content, offset, len));