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

/**
 * Creates a {@link UTF8JsonGenerator} for the outputstream with the supplied buf {@code outBuffer} to use.
 *//*  w ww  .j a va 2s. c om*/
public static UTF8JsonGenerator newJsonGenerator(OutputStream out, byte[] buf) {
    return newJsonGenerator(out, buf, 0, false,
            new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false));
}

From source file:io.protostuff.SmileIOUtil.java

/**
 * Merges the {@code message} from the {@link InputStream} using the given {@code schema}.
 *///www.  jav a  2  s .c  o m
public static <T> void mergeFrom(InputStream in, T message, 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 {
        JsonIOUtil.mergeFrom(parser, message, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Merges the {@code message} with the byte array using the given {@code schema}.
 *///  w w w. ja v a  2s  .c o m
public static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema,
        boolean numeric) throws IOException {
    final IOContext context = new IOContext(DEFAULT_JSON_FACTORY._getBufferRecycler(), data, false);
    final JsonParser parser = newJsonParser(null, data, offset, offset + length, false, context);
    /*
     * final JsonParser parser = DEFAULT_JSON_FACTORY.createJsonParser(data, offset, length);
     */
    try {
        mergeFrom(parser, message, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

/**
 * Merges the {@code message} from the {@link InputStream} using the given {@code schema}.
 * <p>//from w ww.j  a v  a2s .c om
 * The {@link LinkedBuffer}'s internal byte array will be used when reading the message.
 */
public static <T> void mergeFrom(InputStream in, T message, 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 {
        JsonIOUtil.mergeFrom(parser, message, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Merges the {@code message} from the {@link InputStream} using the given {@code schema}.
 */// w  w  w . ja v  a  2  s .c o  m
public static <T> void mergeFrom(InputStream in, T message, 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 {
        mergeFrom(parser, message, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.JsonIOUtil.java

/**
 * Merges the {@code message} from the {@link InputStream} using the given {@code schema}.
 * <p>/*from w  ww  . j av a2 s.  co m*/
 * The {@link LinkedBuffer}'s internal byte array will be used when reading the message.
 */
public static <T> void mergeFrom(InputStream in, T message, 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 {
        mergeFrom(parser, message, schema, numeric);
    } finally {
        parser.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

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

    final SmileGenerator generator = newSmileGenerator(out, context.allocWriteEncodingBuffer(), 0, true,
            context);

    // final SmileGenerator generator = DEFAULT_SMILE_FACTORY.createJsonGenerator(out);

    try {
        JsonIOUtil.writeTo(generator, message, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

/**
 * Serializes the {@code message} into an {@link OutputStream} using the given {@code schema}.
 * <p>//from ww w  . j  a  v a 2  s  .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 writeTo(OutputStream out, T message, Schema<T> schema, boolean numeric,
        LinkedBuffer buffer) throws IOException {
    final IOContext context = new IOContext(DEFAULT_SMILE_FACTORY._getBufferRecycler(), out, false);

    final SmileGenerator generator = newSmileGenerator(out, buffer.buffer, 0, false, context);

    // final SmileGenerator generator = DEFAULT_SMILE_FACTORY.createJsonGenerator(out);
    try {
        JsonIOUtil.writeTo(generator, message, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

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

    final SmileGenerator generator = newSmileGenerator(out, context.allocWriteEncodingBuffer(), 0, true,
            context);

    // final SmileGenerator generator = DEFAULT_SMILE_FACTORY.createJsonGenerator(out);
    try {
        JsonIOUtil.writeListTo(generator, messages, schema, numeric);
    } finally {
        generator.close();
    }
}

From source file:io.protostuff.SmileIOUtil.java

/**
 * Serializes the {@code messages} into the stream using the given schema.
 * <p>/*  w  w  w  .  j a v a2  s. 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_SMILE_FACTORY._getBufferRecycler(), out, false);

    final SmileGenerator generator = newSmileGenerator(out, buffer.buffer, 0, false, context);

    // final SmileGenerator generator = DEFAULT_SMILE_FACTORY.createJsonGenerator(out);
    try {
        JsonIOUtil.writeListTo(generator, messages, schema, numeric);
    } finally {
        generator.close();
    }
}