/** * Method for constructing parser for parsing * the contents of given byte array. */ public JsonParser createJsonParser(byte[] data) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { InputStream in = _inputDecorator.decorate(ctxt, data, 0, data.length); if (in != null) { return _createJsonParser(in, ctxt); } } return _createJsonParser(data, 0, data.length, ctxt); }
/** * Method for constructing parser for parsing * the contents of given byte array. * * @param data Buffer that contains data to parse * @param offset Offset of the first data byte within buffer * @param len Length of contents to parse within buffer */ public JsonParser createJsonParser(byte[] data, int offset, int len) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { InputStream in = _inputDecorator.decorate(ctxt, data, offset, len); if (in != null) { return _createJsonParser(in, ctxt); } } return _createJsonParser(data, offset, len, ctxt); }
/** * Method for constructing parser for parsing * contens of given String. */ public JsonParser createJsonParser(String content) throws IOException, JsonParseException { Reader r = new StringReader(content); // true -> we own the Reader (and must close); not a big deal IOContext ctxt = _createContext(r, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { r = _inputDecorator.decorate(ctxt, r); } return _createJsonParser(r, ctxt); }
/** * Method for constructing JSON parser instance to parse * contents of specified file. Encoding is auto-detected * from contents according to JSON specification recommended * mechanism. *<p> * Underlying input stream (needed for reading contents) * will be <b>owned</b> (and managed, i.e. closed as need be) by * the parser, since caller has no access to it. * * @param f File that contains JSON content to parse */ public JsonParser createJsonParser(File f) throws IOException, JsonParseException { // true, since we create InputStream from File IOContext ctxt = _createContext(f, true); InputStream in = new FileInputStream(f); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { in = _inputDecorator.decorate(ctxt, in); } return _createJsonParser(in, ctxt); }
/** * Method for constructing parser for parsing * the contents accessed via specified Reader. <p> * The read stream will <b>not be owned</b> by * the parser, it will still be managed (i.e. closed if * end-of-stream is reacher, or parser close method called) * if (and only if) {@link org.codehaus.jackson.JsonParser.Feature#AUTO_CLOSE_SOURCE} * is enabled. *<p> * * @param r Reader to use for reading JSON content to parse */ public JsonParser createJsonParser(Reader r) throws IOException, JsonParseException { // false -> we do NOT own Reader (did not create it) IOContext ctxt = _createContext(r, false); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { r = _inputDecorator.decorate(ctxt, r); } return _createJsonParser(r, ctxt); }
/** * Method for constructing JSON parser instance to parse * the contents accessed via specified input stream. *<p> * The input stream will <b>not be owned</b> by * the parser, it will still be managed (i.e. closed if * end-of-stream is reacher, or parser close method called) * if (and only if) {@link org.codehaus.jackson.JsonParser.Feature#AUTO_CLOSE_SOURCE} * is enabled. *<p> * Note: no encoding argument is taken since it can always be * auto-detected as suggested by Json RFC. * * @param in InputStream to use for reading JSON content to parse */ public JsonParser createJsonParser(InputStream in) throws IOException, JsonParseException { IOContext ctxt = _createContext(in, false); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { in = _inputDecorator.decorate(ctxt, in); } return _createJsonParser(in, ctxt); }
/** * Method for constructing JSON parser instance to parse * contents of resource reference by given URL. * Encoding is auto-detected * from contents according to JSON specification recommended * mechanism. *<p> * Underlying input stream (needed for reading contents) * will be <b>owned</b> (and managed, i.e. closed as need be) by * the parser, since caller has no access to it. * * @param url URL pointing to resource that contains JSON content to parse */ public JsonParser createJsonParser(URL url) throws IOException, JsonParseException { // true, since we create InputStream from URL IOContext ctxt = _createContext(url, true); InputStream in = _optimizedStreamFromURL(url); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { in = _inputDecorator.decorate(ctxt, in); } return _createJsonParser(in, ctxt); }
/** * Method for constructing parser for parsing * the contents of given byte array. */ public JsonParser createJsonParser(byte[] data) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { InputStream in = _inputDecorator.decorate(ctxt, data, 0, data.length); if (in != null) { return _createJsonParser(in, ctxt); } } return _createJsonParser(data, 0, data.length, ctxt); }
/** * Method for constructing parser for parsing * the contents of given byte array. * * @param data Buffer that contains data to parse * @param offset Offset of the first data byte within buffer * @param len Length of contents to parse within buffer */ public JsonParser createJsonParser(byte[] data, int offset, int len) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { InputStream in = _inputDecorator.decorate(ctxt, data, offset, len); if (in != null) { return _createJsonParser(in, ctxt); } } return _createJsonParser(data, offset, len, ctxt); }
/** * Method for constructing parser for parsing * contens of given String. */ public JsonParser createJsonParser(String content) throws IOException, JsonParseException { Reader r = new StringReader(content); // true -> we own the Reader (and must close); not a big deal IOContext ctxt = _createContext(r, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { r = _inputDecorator.decorate(ctxt, r); } return _createJsonParser(r, ctxt); }
/** * Method for constructing JSON parser instance to parse * contents of specified file. Encoding is auto-detected * from contents according to JSON specification recommended * mechanism. *<p> * Underlying input stream (needed for reading contents) * will be <b>owned</b> (and managed, i.e. closed as need be) by * the parser, since caller has no access to it. * * @param f File that contains JSON content to parse */ public JsonParser createJsonParser(File f) throws IOException, JsonParseException { // true, since we create InputStream from File IOContext ctxt = _createContext(f, true); InputStream in = new FileInputStream(f); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { in = _inputDecorator.decorate(ctxt, in); } return _createJsonParser(in, ctxt); }
/** * Method for constructing JSON parser instance to parse * the contents accessed via specified input stream. *<p> * The input stream will <b>not be owned</b> by * the parser, it will still be managed (i.e. closed if * end-of-stream is reacher, or parser close method called) * if (and only if) {@link org.codehaus.jackson.JsonParser.Feature#AUTO_CLOSE_SOURCE} * is enabled. *<p> * Note: no encoding argument is taken since it can always be * auto-detected as suggested by Json RFC. * * @param in InputStream to use for reading JSON content to parse */ public JsonParser createJsonParser(InputStream in) throws IOException, JsonParseException { IOContext ctxt = _createContext(in, false); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { in = _inputDecorator.decorate(ctxt, in); } return _createJsonParser(in, ctxt); }
/** * Method for constructing parser for parsing * the contents accessed via specified Reader. <p> * The read stream will <b>not be owned</b> by * the parser, it will still be managed (i.e. closed if * end-of-stream is reacher, or parser close method called) * if (and only if) {@link org.codehaus.jackson.JsonParser.Feature#AUTO_CLOSE_SOURCE} * is enabled. *<p> * * @param r Reader to use for reading JSON content to parse */ public JsonParser createJsonParser(Reader r) throws IOException, JsonParseException { // false -> we do NOT own Reader (did not create it) IOContext ctxt = _createContext(r, false); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { r = _inputDecorator.decorate(ctxt, r); } return _createJsonParser(r, ctxt); }
/** * Method for constructing JSON parser instance to parse * contents of resource reference by given URL. * Encoding is auto-detected * from contents according to JSON specification recommended * mechanism. *<p> * Underlying input stream (needed for reading contents) * will be <b>owned</b> (and managed, i.e. closed as need be) by * the parser, since caller has no access to it. * * @param url URL pointing to resource that contains JSON content to parse */ public JsonParser createJsonParser(URL url) throws IOException, JsonParseException { // true, since we create InputStream from URL IOContext ctxt = _createContext(url, true); InputStream in = _optimizedStreamFromURL(url); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { in = _inputDecorator.decorate(ctxt, in); } return _createJsonParser(in, ctxt); }
/** * Overridable factory method that actually instantiates desired * parser. */ @Override protected JsonParser _createJsonParser(Reader r, IOContext ctxt) throws IOException, JsonParseException { if (_cfgDelegateToTextual) { return super._createJsonParser(r, ctxt); } throw new UnsupportedOperationException("Can not create generator for non-byte-based target"); }
/** * Method for constructing parser for parsing * the contents of given byte array. */ public JsonParser createJsonParser(byte[] data) throws IOException, JsonParseException { IOContext ctxt = _createContext(data, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { InputStream in = _inputDecorator.decorate(ctxt, data, 0, data.length); if (in != null) { return _createJsonParser(in, ctxt); } } return _createJsonParser(data, 0, data.length, ctxt); }
/** * Method for constructing json parser instance to parse * contents of specified file. Encoding is auto-detected * from contents according to json specification recommended * mechanism. *<p> * Underlying input stream (needed for reading contents) * will be <b>owned</b> (and managed, i.e. closed as need be) by * the parser, since caller has no access to it. * * @param f File that contains JSON content to parse */ public JsonParser createJsonParser(File f) throws IOException, JsonParseException { return _createJsonParser(new FileInputStream(f), _createContext(f, true)); }
/** * Method for constructing parser for parsing * contens of given String. */ public JsonParser createJsonParser(String content) throws IOException, JsonParseException { Reader r = new StringReader(content); // true -> we own the Reader (and must close); not a big deal IOContext ctxt = _createContext(r, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { r = _inputDecorator.decorate(ctxt, r); } return _createJsonParser(r, ctxt); }
/** * Method for constructing parser for parsing * contens of given String. */ public JsonParser createJsonParser(String content) throws IOException, JsonParseException { Reader r = new StringReader(content); // true -> we own the Reader (and must close); not a big deal IOContext ctxt = _createContext(r, true); // [JACKSON-512]: allow wrapping with InputDecorator if (_inputDecorator != null) { r = _inputDecorator.decorate(ctxt, r); } return _createJsonParser(r, ctxt); }
public JsonParser createJsonParser(byte[] data, int offset, int len) throws IOException, JsonParseException { // !!! TODO: make efficient (see [JACKSON-24]) InputStream in = new ByteArrayInputStream(data, offset, len); // true -> must be managed as caller didn't hand stream return _createJsonParser(in, _createContext(in, true)); }