Java 类com.fasterxml.jackson.core.json.UTF8StreamJsonParser 实例源码

项目:GitHub    文件:JsonParserSequenceTest.java   
@Test
public void testSkipChildren() throws IOException {
    JsonParser[] jsonParserArray = new JsonParser[3];
    IOContext ioContext = new IOContext(new BufferRecycler(), jsonParserArray, true);
    byte[] byteArray = new byte[8];
    InputStream byteArrayInputStream = new ByteArrayInputStream(byteArray, 0, (byte) 58);
    UTF8StreamJsonParser uTF8StreamJsonParser = new UTF8StreamJsonParser(ObjectReadContext.empty(),
            ioContext,
            0, byteArrayInputStream, ByteQuadsCanonicalizer.createRoot(),
            byteArray, -1, (byte) 9, true);
    JsonParserDelegate jsonParserDelegate = new JsonParserDelegate(jsonParserArray[0]);
    JsonParserSequence jsonParserSequence = JsonParserSequence.createFlattened(true, uTF8StreamJsonParser, jsonParserDelegate);
    JsonParserSequence jsonParserSequenceTwo = (JsonParserSequence) jsonParserSequence.skipChildren();

    assertEquals(2, jsonParserSequenceTwo.containedParsersCount());
}
项目:metadatamanagement    文件:ExceptionTranslator.java   
private ErrorListDto createJsonParsingError(InvalidFormatException invalidFormatException) {
  UTF8StreamJsonParser processor =
      (UTF8StreamJsonParser) invalidFormatException.getProcessor();

  //Create Json Parsing Error. Just the first will be returned
  try {            
    String domainObject = ((Class<?>) invalidFormatException.getPath().get(0).getFrom())
        .getSimpleName();

    String property = processor.getCurrentName();
    if (property == null) {
      property = invalidFormatException.getPath().get(0).getFieldName();
    }
    String invalidValue = (String)invalidFormatException.getValue();
    String messageKey = "global.error.import.json-parsing-error";
    return new ErrorListDto(new ErrorDto(domainObject, messageKey,invalidValue, property));
  } catch (IOException e) {
    return new ErrorListDto(
        new ErrorDto(null, "global.error.import.no-json-mapping", null, null));
  }
}
项目:GitHub    文件:SymbolTableMergingTest.java   
private JsonParser _getParser(MyJsonFactory f, String doc, boolean useBytes) throws IOException
{
    JsonParser p;
    if (useBytes) {
        p = f.createParser(ObjectReadContext.empty(), doc.getBytes("UTF-8"));
        assertEquals(UTF8StreamJsonParser.class, p.getClass());
        assertEquals(0, f.byteSymbolCount());
    } else {
        p = f.createParser(ObjectReadContext.empty(), doc);
        assertEquals(ReaderBasedJsonParser.class, p.getClass());
        assertEquals(0, f.charSymbolCount());
    }
    return p;
}
项目:Beam    文件:JsonIOUtil.java   
/**
 * Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use.
 */
public static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf,
        int offset, int limit) throws IOException
{
    return newJsonParser(in, buf, offset, limit, false,
            new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), in,
                    false));
}
项目:Beam    文件:JsonIOUtil.java   
/**
 * Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use.
 */
static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf,
        int offset, int limit, boolean bufferRecyclable, IOContext context)
        throws IOException
{
    return new UTF8StreamJsonParser(context,
            DEFAULT_JSON_FACTORY.getParserFeatures(), in,
            DEFAULT_JSON_FACTORY.getCodec(),
            DEFAULT_JSON_FACTORY.getRootByteSymbols().makeChild(true, true),
            buf, offset, limit, bufferRecyclable);
}
项目:protostuff    文件:JsonIOUtil.java   
/**
 * Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use.
 */
public static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf,
        int offset, int limit) throws IOException
{
    return newJsonParser(in, buf, offset, limit, false,
            new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), in,
                    false));
}
项目:protostuff    文件:JsonIOUtil.java   
/**
 * Creates a {@link UTF8StreamJsonParser} from the inputstream with the supplied buf {@code inBuffer} to use.
 */
static UTF8StreamJsonParser newJsonParser(InputStream in, byte[] buf,
        int offset, int limit, boolean bufferRecyclable, IOContext context)
        throws IOException
{
    return new UTF8StreamJsonParser(context,
            DEFAULT_JSON_FACTORY.getParserFeatures(), in,
            DEFAULT_JSON_FACTORY.getCodec(),
            DEFAULT_JSON_FACTORY.getRootByteSymbols().makeChild(1),
            buf, offset, limit, bufferRecyclable);
}