/** * @since 1.3.1 * @deprecated As of 1.4 use {@link JsonWriter#JsonWriter(Writer, int, Format) instead} */ public JsonWriter(Writer writer, char[] lineIndenter, String newLine, int mode) { this(writer, mode, new Format( lineIndenter, newLine.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT)); }
/** * Create a JsonWriter. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @param format the JSON format definition * @param bufferSize the buffer size of the internally used QuickWriter * @see JsonWriter#JsonWriter(Writer, int, Format) * @since 1.4 */ public JsonWriter(Writer writer, int mode, Format format, int bufferSize) { super(mode, format.getNameCoder()); this.writer = new QuickWriter(writer, bufferSize); this.format = format; depth = (mode & DROP_ROOT_MODE) == 0 ? -1 : 0; }
/** * Create a JsonWriter. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @param format the JSON format definition * @param bufferSize the buffer size of the internally used QuickWriter * @see JsonWriter#JsonWriter(Writer, int, Format) * @since 1.4 */ public JsonWriter(Writer writer, int mode, Format format, int bufferSize) { super(mode, format.getNameCoder()); this.writer = new QuickWriter(writer, bufferSize); this.format = format; depth = (mode & DROP_ROOT_MODE) == 0 ? -1 : 0; }
/** * Create a JsonWriter. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @param format the JSON format definition * @param bufferSize the buffer size of the internally used QuickWriter * @see JsonWriter#JsonWriter(Writer, int, Format) * @since 1.4 */ public JsonWriter(Writer writer, int mode, Format format, int bufferSize) { super(mode, format.getNameCoder()); this.writer = new QuickWriter(writer, bufferSize); this.format = format; depth = (mode & DROP_ROOT_MODE) == 0 ? -1 : 0; }
/** * Create a JsonWriter. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @param format the JSON format definition * @param bufferSize the buffer size of the internally used QuickWriter * @see JsonWriter#JsonWriter(Writer, int, Format) * @since 1.4 */ public JsonWriter(Writer writer, int mode, Format format, int bufferSize) { super(mode, format.getNameCoder()); this.writer = new QuickWriter(writer, bufferSize); this.format = format; depth = (mode & DROP_ROOT_MODE) == 0 ? -1 : 0; }
/** * Create a JsonWriter. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @param format the JSON format definition * @param bufferSize the buffer size of the internally used QuickWriter * @see JsonWriter#JsonWriter(Writer, int, Format) * @since 1.4 */ public JsonWriter(Writer writer, int mode, Format format, int bufferSize) { super(mode, format.getNameCoder()); this.writer = new QuickWriter(writer, bufferSize); this.format = format; depth = (mode & DROP_ROOT_MODE) == 0 ? -1 : 0; }
/** * {@inheritDoc} */ protected void addLabel(String name) { if (newLineProposed) { writeNewLine(); } writer.write('"'); writeText(name); writer.write("\":"); if ((format.mode() & Format.SPACE_AFTER_LABEL) != 0) { writer.write(' '); } }
/** * Create a JsonWriter. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @param format the JSON format definition * @param bufferSize the buffer size of the internally used QuickWriter * @see JsonWriter#JsonWriter(Writer, int, Format) * @since 1.4 */ public JsonWriter(final Writer writer, final int mode, final Format format, final int bufferSize) { super(mode, format.getNameCoder()); this.writer = new QuickWriter(writer, bufferSize); this.format = format; depth = (mode & DROP_ROOT_MODE) == 0 ? -1 : 0; }
/** * {@inheritDoc} */ protected void addLabel(String name) { if (newLineProposed) { writeNewLine(); } writer.write('"'); writeText(name); writer.write("\":"); if ((format.mode() & Format.SPACE_AFTER_LABEL) != 0) { writer.write(' '); } }
/** * {@inheritDoc} */ protected void addLabel(String name) { if (newLineProposed) { writeNewLine(); } writer.write('"'); writeText(name); writer.write("\":"); if ((format.mode() & Format.SPACE_AFTER_LABEL) != 0) { writer.write(' '); } }
/** * {@inheritDoc} */ protected void addLabel(String name) { if (newLineProposed) { writeNewLine(); } writer.write('"'); writeText(name); writer.write("\":"); if ((format.mode() & Format.SPACE_AFTER_LABEL) != 0) { writer.write(' '); } }
/** * {@inheritDoc} */ protected void addLabel(String name) { if (newLineProposed) { writeNewLine(); } writer.write('"'); writeText(name); writer.write("\":"); if ((format.mode() & Format.SPACE_AFTER_LABEL) != 0) { writer.write(' '); } }
private void writeNewLine() { int depth = this.depth; writer.write(format.getNewLine()); while (depth-- > 0) { writer.write(format.getLineIndenter()); } newLineProposed = false; }
public JsonWriter(Writer writer) { this(writer, 0, new Format( new char[]{' ', ' '}, new char[]{'\n'}, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT)); }
/** * @deprecated As of 1.4 use {@link JsonWriter#JsonWriter(Writer, Format) instead} */ public JsonWriter(Writer writer, char[] lineIndenter, String newLine) { this(writer, 0, new Format( lineIndenter, newLine.toCharArray(), Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT)); }
private void endNewLine() { if (depth-- > 0) { if (((format.mode() & Format.COMPACT_EMPTY_ELEMENT) != 0) && newLineProposed) { newLineProposed = false; } else { writeNewLine(); } } }
private void endNewLine() { if (depth-- > 0) { if (((format.mode() & Format.COMPACT_EMPTY_ELEMENT) != 0) && newLineProposed) { newLineProposed = false; } else { writeNewLine(); } } }
/** * @deprecated As of 1.4 use {@link JsonWriter#JsonWriter(Writer, Format) instead} */ public JsonWriter(Writer writer, String lineIndenter) { this(writer, 0, new Format( lineIndenter.toCharArray(), new char[]{'\n'}, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT)); }
/** * Create a JsonWriter where the writer mode can be chosen. * * @param writer the {@link Writer} where the JSON is written to * @param mode the JsonWriter mode * @since 1.3.1 * @see #JsonWriter(Writer, int, Format) */ public JsonWriter(Writer writer, int mode) { this(writer, mode, new Format()); }
/** * @deprecated As of 1.4 use {@link JsonWriter#JsonWriter(Writer, Format) instead} */ public JsonWriter(Writer writer, char[] lineIndenter) { this(writer, 0, new Format(lineIndenter, new char[]{'\n'}, Format.SPACE_AFTER_LABEL | Format.COMPACT_EMPTY_ELEMENT)); }