/** * Accessor for getting brief textual name of matched format if any (null * if none). Equivalent to: *<pre> * return hasMatch() ? getMatch().getFormatName() : null; *</pre> */ public String getMatchedFormatName() { return _match.getFactory().getFormatName(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('['); final int len = _readers.length; if (len > 0) { sb.append(_readers[0].getFactory().getFormatName()); for (int i = 1; i < len; ++i) { sb.append(", "); sb.append(_readers[i].getFactory().getFormatName()); } } sb.append(']'); return sb.toString(); }
/** * Convenience method for trying to construct a {@link JsonParser} for * parsing content which is assumed to be in detected data format. * If no match was found, returns null. */ public JsonParser createParserWithMatch() throws IOException { if (_match == null) { return null; } JsonFactory jf = _match.getFactory(); if (_originalStream == null) { return jf.createParser(_bufferedData, _bufferedStart, _bufferedLength); } return jf.createParser(getDataStream()); }
private Match _findFormat(AccessorForReader acc) throws IOException { ObjectReader bestMatch = null; MatchStrength bestMatchStrength = null; for (ObjectReader f : _readers) { acc.reset(); MatchStrength strength = f.getFactory().hasFormat(acc); // if not better than what we have so far (including minimal level limit), skip if (strength == null || strength.ordinal() < _minimalMatch.ordinal()) { continue; } // also, needs to better match than before if (bestMatch != null) { if (bestMatchStrength.ordinal() >= strength.ordinal()) { continue; } } // finally: if it's good enough match, we are done bestMatch = f; bestMatchStrength = strength; if (strength.ordinal() >= _optimalMatch.ordinal()) { break; } } return acc.createMatcher(bestMatch, bestMatchStrength); }
/** * Overridable helper method called to create a {@link JsonParser} for reading * contents of given raw {@link InputStream}. * May return null to indicate that Stream is empty; that is, contains no * content. * * @since 2.2 */ protected JsonParser _createParser(ObjectReader reader, InputStream rawStream) throws IOException { JsonParser p = reader.getFactory().createParser(rawStream); // Important: we are NOT to close the underlying stream after // mapping, so we need to instruct parser: p.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE); return p; }
@Override protected JsonParser _createParser(ObjectReader reader, InputStream rawStream) throws IOException { // Fix for [Issue#4]: note, can not try to advance parser, XML parser complains PushbackInputStream wrappedStream = new PushbackInputStream(rawStream); int firstByte = wrappedStream.read(); if (firstByte == -1) { return null; } wrappedStream.unread(firstByte); return reader.getFactory().createParser(wrappedStream); } }
@Nonnull private JsonParser parse(@Nullable String str) throws IOException { return objectReader.getFactory().createParser(str); }
/** * Accessor for getting brief textual name of matched format if any (null * if none). Equivalent to: *<pre> * return hasMatch() ? getMatch().getFormatName() : null; *</pre> */ public String getMatchedFormatName() { return _match.getFactory().getFormatName(); }
/** * Accessor for getting brief textual name of matched format if any (null * if none). Equivalent to: *<pre> * return hasMatch() ? getMatch().getFormatName() : null; *</pre> */ public String getMatchedFormatName() { return _match.getFactory().getFormatName(); }
/** * Accessor for getting brief textual name of matched format if any (null * if none). Equivalent to: *<pre> * return hasMatch() ? getMatch().getFormatName() : null; *</pre> */ public String getMatchedFormatName() { return _match.getFactory().getFormatName(); }
/** * Accessor for getting brief textual name of matched format if any (null * if none). Equivalent to: *<pre> * return hasMatch() ? getMatch().getFormatName() : null; *</pre> */ public String getMatchedFormatName() { return _match.getFactory().getFormatName(); }
/** * Accessor for getting brief textual name of matched format if any (null * if none). Equivalent to: *<pre> * return hasMatch() ? getMatch().getFormatName() : null; *</pre> */ public String getMatchedFormatName() { return _match.getFactory().getFormatName(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('['); final int len = _readers.length; if (len > 0) { sb.append(_readers[0].getFactory().getFormatName()); for (int i = 1; i < len; ++i) { sb.append(", "); sb.append(_readers[i].getFactory().getFormatName()); } } sb.append(']'); return sb.toString(); }
/** * Convenience method for trying to construct a {@link JsonParser} for * parsing content which is assumed to be in detected data format. * If no match was found, returns null. */ public JsonParser createParserWithMatch() throws IOException { if (_match == null) { return null; } JsonFactory jf = _match.getFactory(); if (_originalStream == null) { return jf.createParser(_bufferedData, _bufferedStart, _bufferedLength); } return jf.createParser(getDataStream()); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('['); final int len = _readers.length; if (len > 0) { sb.append(_readers[0].getFactory().getFormatName()); for (int i = 1; i < len; ++i) { sb.append(", "); sb.append(_readers[i].getFactory().getFormatName()); } } sb.append(']'); return sb.toString(); }
/** * Convenience method for trying to construct a {@link JsonParser} for * parsing content which is assumed to be in detected data format. * If no match was found, returns null. */ public JsonParser createParserWithMatch() throws IOException { if (_match == null) { return null; } JsonFactory jf = _match.getFactory(); if (_originalStream == null) { return jf.createParser(_bufferedData, _bufferedStart, _bufferedLength); } return jf.createParser(getDataStream()); }
/** * Overridable helper method called to create a {@link JsonParser} for reading * contents of given raw {@link InputStream}. * May return null to indicate that Stream is empty; that is, contains no * content. * * @since 2.2 */ protected JsonParser _createParser(ObjectReader reader, InputStream rawStream) throws IOException { JsonParser p = reader.getFactory().createParser(rawStream); // Important: we are NOT to close the underlying stream after // mapping, so we need to instruct parser: p.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE); return p; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append('['); final int len = _readers.length; if (len > 0) { sb.append(_readers[0].getFactory().getFormatName()); for (int i = 1; i < len; ++i) { sb.append(", "); sb.append(_readers[i].getFactory().getFormatName()); } } sb.append(']'); return sb.toString(); }
/** * Convenience method for trying to construct a {@link JsonParser} for * parsing content which is assumed to be in detected data format. * If no match was found, returns null. */ public JsonParser createParserWithMatch() throws IOException { if (_match == null) { return null; } JsonFactory jf = _match.getFactory(); if (_originalStream == null) { return jf.createParser(_bufferedData, _bufferedStart, _bufferedLength); } return jf.createParser(getDataStream()); }
/** * Create a new ListResponseOutputStream that will write to the provided * output stream. * * @param outputStream The output stream to write to. * @throws IOException If an exception occurs while writing to the output * stream. */ public ListResponseWriter(final OutputStream outputStream) throws IOException { jsonGenerator = JsonUtils.getObjectReader().getFactory().createGenerator(outputStream); deferredFields = JsonUtils.getJsonNodeFactory().objectNode(); }