@Override public void writeEndObject(JsonGenerator jg, int nrOfEntries) throws IOException { if (!_objectIndenter.isInline()) { --_nesting; } if (nrOfEntries > 0) { _objectIndenter.writeIndentation(jg, _nesting); } else { jg.writeRaw(' '); } jg.writeRaw('}'); }
@Override public void writeEndArray(JsonGenerator gen, int nrOfValues) throws IOException { if (!_arrayIndenter.isInline()) { --_nesting; } if (nrOfValues > 0) { _arrayIndenter.writeIndentation(gen, _nesting); } else { gen.writeRaw(' '); } gen.writeRaw(']'); }
@Override public void writeStartArray(JsonGenerator jg) throws IOException { if (!_arrayIndenter.isInline()) { ++_nesting; } jg.writeRaw('['); }
@Override public void writeStartObject(JsonGenerator jg) throws IOException { jg.writeRaw('{'); if (!_objectIndenter.isInline()) { ++_nesting; } }
/** * This is used to write any comments that have been set. The comment will typically be written at * the start of an element to describe the purpose of the element or include debug data that can * be used to determine any issues in serialization. * * @param comment this is the comment that is to be written */ public void writeComment(String comment) throws Exception { String text = indenter.top(); if (last == Tag.START) { append('>'); } if (text != null) { append(text); append(OPEN); append(comment); append(CLOSE); } last = Tag.COMMENT; }
/** * This method is used to write a start tag for an element. If a start tag was written before this * then it is closed. Before the start tag is written an indent is generated and placed in front * of the tag, this is done for all but the first start tag. * * @param name this is the name of the start tag to be written * @throws Exception thrown if there is an I/O exception */ public void writeStart(String name, String prefix) throws Exception { String text = indenter.push(); if (last == Tag.START) { append('>'); } flush(); append(text); append('<'); if (!isEmpty(prefix)) { append(prefix); append(':'); } append(name); last = Tag.START; }
/** * This is used to write an end element tag to the writer. This will close the element with a * short <code>/></code> if the last tag written was a start tag. However if an end tag or some * text was written then a full end tag is written. * * @param name this is the name of the element to be closed * @throws Exception thrown if there is an I/O exception */ public void writeEnd(String name, String prefix) throws Exception { String text = indenter.pop(); if (last == Tag.START) { write('/'); write('>'); } else { if (last != Tag.TEXT) { write(text); } if (last != Tag.START) { write('<'); write('/'); write(name, prefix); write('>'); } } last = Tag.END; }
/** * Method called after an array value has been completely output, and before another value is to * be output. * * <p>Default handling (without pretty-printing) will output a single comma to separate the two. * Pretty-printer is to output a comma as well, but can surround that with other (white-space) * decoration. */ @Override public void writeArrayValueSeparator(JsonGenerator gen) throws IOException { gen.writeRaw(','); _arrayIndenter.writeIndentation(gen, _nesting); }
@Override public void beforeArrayValues(JsonGenerator jg) throws IOException { _arrayIndenter.writeIndentation(jg, _nesting); }
/** * Method called after an object entry (field:value) has been completely output, and before * another value is to be output. * * <p>Default handling (without pretty-printing) will output a single comma to separate the two. * Pretty-printer is to output a comma as well, but can surround that with other (white-space) * decoration. */ @Override public void writeObjectEntrySeparator(JsonGenerator jg) throws IOException { jg.writeRaw(','); _objectIndenter.writeIndentation(jg, _nesting); }
@Override public void beforeObjectEntries(JsonGenerator jg) throws IOException { _objectIndenter.writeIndentation(jg, _nesting); }