com.fasterxml.jackson.core.json.UTF8JsonGenerator Java Examples
The following examples show how to use
com.fasterxml.jackson.core.json.UTF8JsonGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProtostuffMessageBodyWriter.java From datawave with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void writeTo(Object message, Class<?> clazz, Type type, Annotation[] annotations, MediaType media, MultivaluedMap<String,Object> httpHeaders, OutputStream out) throws IOException, WebApplicationException { // TODO: Figure out a method to add the proto file location in the response headers. // This map must be mofified before any data is written to out, // since at that time the response headers will be flushed. Schema<Object> schema = null; if (message instanceof Message) { Message<Object> msg = (Message<Object>) message; schema = msg.cachedSchema(); } else { schema = (Schema<Object>) RuntimeSchema.getSchema(clazz); } try { if (MediaType.APPLICATION_XML_TYPE.equals(media) || MediaType.TEXT_XML_TYPE.equals(media)) { XmlIOUtil.writeTo(out, message, schema); } else if ("text/yaml".equals(media.toString()) || "text/x-yaml".equals(media.toString()) || "application/x-yaml".equals(media.toString())) { YamlIOUtil.writeTo(out, message, schema, buffer); } else if ("application/x-protobuf".equals(media.toString())) { ProtobufIOUtil.writeTo(out, message, schema, buffer); } else if ("application/x-protostuff".equals(media.toString())) { ProtostuffIOUtil.writeTo(out, message, schema, buffer); } else if (MediaType.APPLICATION_JSON_TYPE.equals(media)) { IOContext ctx = new IOContext(JsonIOUtil.DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false); UTF8JsonGenerator generator = new UTF8JsonGenerator(ctx, JsonIOUtil.DEFAULT_JSON_FACTORY.getGeneratorFeatures(), JsonIOUtil.DEFAULT_JSON_FACTORY.getCodec(), out); try { JsonIOUtil.writeTo(generator, message, schema, false); } finally { generator.close(); } } } finally { buffer.clear(); } }
Example #2
Source File: JsonIOUtils.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * Creates a {@link UTF8JsonGenerator} for the outputstream with the supplied buf {@code outBuffer} to use. */ static UTF8JsonGenerator newJsonGenerator(OutputStream out, byte[] buf, int offset, boolean bufferRecyclable, IOContext context) { context.setEncoding(JsonEncoding.UTF8); return new UTF8JsonGenerator(context, DEFAULT_JSON_FACTORY.getGeneratorFeatures(), DEFAULT_JSON_FACTORY.getCodec(), out, buf, offset, bufferRecyclable); }
Example #3
Source File: JsonIOUtil.java From protostuff with Apache License 2.0 | 5 votes |
/** * Creates a {@link UTF8JsonGenerator} for the outputstream with the supplied buf {@code outBuffer} to use. */ static UTF8JsonGenerator newJsonGenerator(OutputStream out, byte[] buf, int offset, boolean bufferRecyclable, IOContext context) { context.setEncoding(JsonEncoding.UTF8); return new UTF8JsonGenerator(context, DEFAULT_JSON_FACTORY.getGeneratorFeaturesImpl(), DEFAULT_JSON_FACTORY.getCodec(), out, buf, offset, bufferRecyclable); }
Example #4
Source File: JsonIOUtils.java From dremio-oss with Apache License 2.0 | 4 votes |
/** * Creates a {@link UTF8JsonGenerator} for the outputstream with the supplied buf {@code outBuffer} to use. */ public static UTF8JsonGenerator newJsonGenerator(OutputStream out, byte[] buf) { return newJsonGenerator(out, buf, 0, false, new IOContext( DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false)); }
Example #5
Source File: JsonIOUtil.java From protostuff with Apache License 2.0 | 4 votes |
/** * Creates a {@link UTF8JsonGenerator} for the outputstream with the supplied buf {@code outBuffer} to use. */ public static UTF8JsonGenerator newJsonGenerator(OutputStream out, byte[] buf) { return newJsonGenerator(out, buf, 0, false, new IOContext( DEFAULT_JSON_FACTORY._getBufferRecycler(), out, false)); }