@Override public void writeEndArray() throws IOException { if (!_jpropContext.inArray()) { _reportError("Current context not an Array but "+_jpropContext.typeDesc()); } _jpropContext = _jpropContext.getParent(); }
@Override public void writeEndArray() throws IOException { if (!_jpropContext.inArray()) { _reportError("Current context not an Array but "+_jpropContext.typeDesc()); } _jpropContext = _jpropContext.getParent(); }
@Override public void writeEndObject() throws IOException { if (!_jpropContext.inObject()) { _reportError("Current context not an Ibject but "+_jpropContext.typeDesc()); } _jpropContext = _jpropContext.getParent(); }
@Override public void writeEndObject() throws IOException { if (!_jpropContext.inObject()) { _reportError("Current context not an Ibject but "+_jpropContext.typeDesc()); } _jpropContext = _jpropContext.getParent(); }
@Override public void writeFieldName(String name) throws IOException { if (!_jpropContext.writeFieldName(name)) { _reportError("Can not write a field name, expecting a value"); } // also, may need to output header if this would be first write if (!_headerChecked) { _headerChecked = true; String header = _schema.header(); if (header != null && !header.isEmpty()) { _writeRaw(header); } } // Ok; append to base path at this point. // First: ensure possibly preceding field name is removed: _jpropContext.truncatePath(_basePath); if (_basePath.length() > _indentLength) { String sep = _schema.pathSeparator(); if (!sep.isEmpty()) { _basePath.append(sep); } } // Note that escaping needs to be applied now... JPropEscapes.appendKey(_basePath, name); // NOTE: we do NOT yet write the key; wait until we have value; just append to path }
@Override public void writeFieldName(String name) throws IOException { if (!_jpropContext.writeFieldName(name)) { _reportError("Can not write a field name, expecting a value"); } // also, may need to output header if this would be first write if (!_headerChecked) { _headerChecked = true; String header = _schema.header(); if (header != null && !header.isEmpty()) { _writeRaw(header); } } // Ok; append to base path at this point. // First: ensure possibly preceding field name is removed: _jpropContext.truncatePath(_basePath); if (_basePath.length() > _indentLength) { String sep = _schema.pathSeparator(); if (!sep.isEmpty()) { _basePath.append(sep); } } // Note that escaping needs to be applied now... JPropEscapes.appendKey(_basePath, name); // NOTE: we do NOT yet write the key; wait until we have value; just append to path }
@Override protected void _verifyValueWrite(String typeMsg) throws IOException { // first, check that name/value cadence works if (!_jpropContext.writeValue()) { _reportError("Can not "+typeMsg+", expecting field name"); } // and if so, update path if we are in array if (_jpropContext.inArray()) { // remove possible path remnants from an earlier sibling _jpropContext.truncatePath(_basePath); int ix = _jpropContext.getCurrentIndex() + _schema.firstArrayOffset(); if (_schema.writeIndexUsingMarkers()) { Markers m = _schema.indexMarker(); // no leading path separator, if using enclosed indexes _basePath.append(m.getStart()); _basePath.append(ix); _basePath.append(m.getEnd()); } else { // leading path separator, if using "simple" index markers if (_basePath.length() > 0) { String sep = _schema.pathSeparator(); if (!sep.isEmpty()) { _basePath.append(sep); } } _basePath.append(ix); } } }
@Override protected void _verifyValueWrite(String typeMsg) throws IOException { // first, check that name/value cadence works if (!_jpropContext.writeValue()) { _reportError("Can not "+typeMsg+", expecting field name"); } // and if so, update path if we are in array if (_jpropContext.inArray()) { // remove possible path remnants from an earlier sibling _jpropContext.truncatePath(_basePath); int ix = _jpropContext.getCurrentIndex() + _schema.firstArrayOffset(); if (_schema.writeIndexUsingMarkers()) { Markers m = _schema.indexMarker(); // no leading path separator, if using enclosed indexes _basePath.append(m.getStart()); _basePath.append(ix); _basePath.append(m.getEnd()); } else { // leading path separator, if using "simple" index markers if (_basePath.length() > 0) { String sep = _schema.pathSeparator(); if (!sep.isEmpty()) { _basePath.append(sep); } } _basePath.append(ix); } } }