public static JsonStringEncoder getJsonStringEncoder() { SoftReference<JsonStringEncoder> ref = _encoderRef.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _encoderRef.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
public static JsonStringEncoder getJsonStringEncoder() { SoftReference<JsonStringEncoder> ref = _encoderRef.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _encoderRef.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
public static String quoteString( String s ) { JsonStringEncoder encoder = new JsonStringEncoder(); return new String( encoder.quoteAsUTF8( s ) ); }
/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. */ public static JsonStringEncoder getInstance() { SoftReference<JsonStringEncoder> ref = _threadEncoder.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _threadEncoder.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
public static JsonStringEncoder getJsonStringEncoder() { SoftReference<JsonStringEncoder> ref = _encoderRef.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _encoderRef.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. */ public static JsonStringEncoder getInstance() { SoftReference<JsonStringEncoder> ref = _threadEncoder.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _threadEncoder.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. */ public static JsonStringEncoder getInstance() { SoftReference<JsonStringEncoder> ref = _threadEncoder.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _threadEncoder.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. */ public static JsonStringEncoder getInstance() { SoftReference<JsonStringEncoder> ref = _threadEncoder.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _threadEncoder.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
/** * Factory method for getting an instance; this is either recycled per-thread instance, * or a newly constructed one. */ public static JsonStringEncoder getInstance() { SoftReference<JsonStringEncoder> ref = _threadEncoder.get(); JsonStringEncoder enc = (ref == null) ? null : ref.get(); if (enc == null) { enc = new JsonStringEncoder(); _threadEncoder.set(new SoftReference<JsonStringEncoder>(enc)); } return enc; }
private static ByteBuf generateContent(final List<String> messages) { final JsonStringEncoder jsonEndocder = new JsonStringEncoder(); final ByteBuf content = Unpooled.buffer(); content.writeByte('a').writeByte('['); final int size = messages.size(); for (int i = 0; i < size; i++) { content.writeByte('"'); final String element = messages.get(i); if (element == null) { messages.subList(i, size).clear(); break; } final String escaped = escapeCharacters(jsonEndocder.quoteAsString(element)); final ByteBuf escapedBuf = Unpooled.copiedBuffer(escaped, CharsetUtil.UTF_8); content.writeBytes(escapedBuf).writeByte('"'); escapedBuf.release(); if (i < size - 1) { content.writeByte(','); } } return content.writeByte(']'); }
private static ByteBuf generateContent(final List<String> messages) { final JsonStringEncoder jsonEndocder = new JsonStringEncoder(); final ByteBuf content = Unpooled.buffer(); content.writeByte('a').writeByte('['); final int size = messages.size(); for (int i = 0; i < size; i++) { content.writeByte('"'); final String element = messages.get(i); if (element == null) { messages.subList(i, size).clear(); break; } final String escaped = escapeCharacters(jsonEndocder.quoteAsString(element)); final ByteBuf escapedBuf = Unpooled.copiedBuffer(escaped, CharsetUtil.UTF_8); content.writeBytes(escapedBuf).writeByte('"'); escapedBuf.release(); if (i < size - 1) { content.writeByte(','); } } return content.writeByte(']'); }