Example usage for com.fasterxml.jackson.core.io IOContext IOContext

List of usage examples for com.fasterxml.jackson.core.io IOContext IOContext

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core.io IOContext IOContext.

Prototype

public IOContext(BufferRecycler br, Object sourceRef, boolean managedResource) 

Source Link

Usage

From source file:io.protostuff.JsonIOUtil.java

/**
 * Serializes the {@code message} into an {@link OutputStream} using the given {@code schema}.
 *//*from   w  w  w.  j av  a 2s .  co m*/
public static <T> void writeTo(OutputStream out, T message, Schema<T> schema, boolean numeric)
        throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false);

    final JsonGenerator generator = newJsonGenerator(out, context.allocWriteEncodingBuffer(), 0, true, context);

    /*
     * final JsonGenerator generator = DEFAULT_JSON_FACTORY.createJsonGenerator(out, JsonEncoding.UTF8);
     */
    try {
        writeTo(generator, message, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

/**
 * Parses the {@code messages} from the stream using the given {@code schema}.
 *//*from  ww  w  . j  a v  a 2  s.co m*/
public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema, boolean numeric) throws IOException {
    final IOContext context = new IOContext(DEFAULT_SMILE_FACTORY._getBufferRecycler(), in, false);
    final SmileParser parser = newSmileParser(in, context.allocReadIOBuffer(), 0, 0, true, context);

    // final SmileParser parser = DEFAULT_SMILE_FACTORY.createJsonParser(in);
    try {
        return JsonIOUtil.parseListFrom(parser, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Serializes the {@code message} into an {@link OutputStream} using the given {@code schema}.
 * <p>// w  w  w  . ja  va 2 s  .co m
 * The {@link LinkedBuffer}'s internal byte array will be used as the primary buffer when writing the message.
 */
public static <T> void writeTo(OutputStream out, T message, Schema<T> schema, boolean numeric,
        LinkedBuffer buffer) throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false);

    final JsonGenerator generator = newJsonGenerator(out, buffer.buffer, 0, false, context);
    try {
        writeTo(generator, message, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

/**
 * Parses the {@code messages} from the stream using the given {@code schema}.
 * <p>/*from  w  w w.  j av a2  s .c om*/
 * The {@link LinkedBuffer}'s internal byte array will be used when reading the message.
 */
public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema, boolean numeric, LinkedBuffer buffer)
        throws IOException {
    final IOContext context = new IOContext(DEFAULT_SMILE_FACTORY._getBufferRecycler(), in, false);
    final SmileParser parser = newSmileParser(in, buffer.buffer, 0, 0, false, context);

    // final SmileParser parser = DEFAULT_SMILE_FACTORY.createJsonParser(in);
    try {
        return JsonIOUtil.parseListFrom(parser, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Serializes the {@code messages} into the stream using the given schema.
 *///from   w  ww .j a v a  2 s  .  c  om
public static <T> void writeListTo(OutputStream out, List<T> messages, Schema<T> schema, boolean numeric)
        throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false);

    final JsonGenerator generator = newJsonGenerator(out, context.allocWriteEncodingBuffer(), 0, true, context);
    /*
     * final JsonGenerator generator = DEFAULT_JSON_FACTORY.createJsonGenerator(out, JsonEncoding.UTF8);
     */
    try {
        writeListTo(generator, messages, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Serializes the {@code messages} into the stream using the given schema.
 * <p>/*from w w w . j  a v  a2s  .c  o m*/
 * The {@link LinkedBuffer}'s internal byte array will be used as the primary buffer when writing the message.
 */
public static <T> void writeListTo(OutputStream out, List<T> messages, Schema<T> schema, boolean numeric,
        LinkedBuffer buffer) throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false);

    final JsonGenerator generator = newJsonGenerator(out, buffer.buffer, 0, false, context);
    try {
        writeListTo(generator, messages, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Parses the {@code messages} from the stream using the given {@code schema}.
 *///from  w ww . ja  v  a 2s.c  o  m
public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema, boolean numeric) throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), in, false);
    final JsonParser parser = newJsonParser(in, context.allocReadIOBuffer(), 0, 0, true, context);
    // final JsonParser parser = DEFAULT_JSON_FACTORY.createJsonParser(in);
    try {
        return parseListFrom(parser, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Parses the {@code messages} from the stream using the given {@code schema}.
 * <p>//w  ww.  j  a  va2s .c o  m
 * The {@link LinkedBuffer}'s internal byte array will be used when reading the message.
 */
public static <T> List<T> parseListFrom(InputStream in, Schema<T> schema, boolean numeric, LinkedBuffer buffer)
        throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), in, false);
    final JsonParser parser = newJsonParser(in, buffer.buffer, 0, 0, false, context);
    try {
        return parseListFrom(parser, schema, numeric);
    } finally {
        parser.close();
    }
}