/** * Clean up method to call to release all buffers this object may be * using. After calling the method, no other accessors can be used (and * attempt to do so may result in an exception) */ public void release() { reset(); if (_bufferRecycler != null && _currBlock != null) { _bufferRecycler.releaseByteBuffer(BufferRecycler.ByteBufferType.WRITE_CONCAT_BUFFER, _currBlock); _currBlock = null; } }
/** * Helper method that should return default pretty-printer to * use for generators constructed by this mapper, when instructed * to use default pretty printer. * * @since 1.7 */ protected PrettyPrinter _defaultPrettyPrinter() { return new DefaultPrettyPrinter(); }
public ByteArrayBuilder _getByteArrayBuilder() { if (_byteArrayBuilder == null) { _byteArrayBuilder = new ByteArrayBuilder(); } else { _byteArrayBuilder.reset(); } return _byteArrayBuilder; }
public final char[] allocCharBuffer(CharBufferType type, int minSize) { if (type.size > minSize) { minSize = type.size; } int ix = type.ordinal(); char[] buffer = _charBuffers[ix]; if (buffer == null || buffer.length < minSize) { buffer = calloc(minSize); } else { _charBuffers[ix] = null; } return buffer; }
public SegmentedStringWriter(BufferRecycler br) { super(); _buffer = new TextBuffer(br); }
@Override public final Number getNumberValue() throws IOException, JsonParseException { _checkIsNumber(); return (Number) _currentObject(); }
/** * Note: calling this method may not be as efficient as calling * {@link #contentsAsString}, since it's not guaranteed that resulting * String is cached. */ @Override public String toString() { return contentsAsString(); }
/** * Method called when starting "manual" output: will clear out * current state and return the first segment buffer to fill * * @since 1.6 */ public byte[] resetAndGetFirstSegment() { reset(); return _currBlock; }
@Override public void writeObject(Object value) throws IOException, JsonProcessingException { // embedded means that no conversions should be done... _append(JsonToken.VALUE_EMBEDDED_OBJECT, value); }
@Override public void serialize(TokenBuffer value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { value.serialize(jgen); }
protected final void _append(JsonToken type) { Segment next = _last.append(_appendOffset, type); if (next == null) { ++_appendOffset; } else { _last = next; _appendOffset = 1; // since we added first at 0 } }
/** * Method called when the current segment buffer is full; will * append to current contents, allocate a new segment buffer * and return it * * @since 1.6 */ public byte[] finishCurrentSegment() { _allocMore(); return _currBlock; }
protected final JsonToken resetAsNaN(String valueStr, double value) { _textBuffer.resetWithString(valueStr); _numberDouble = value; _numTypesValid = NR_DOUBLE; return JsonToken.VALUE_NUMBER_FLOAT; }
@Override public Object getEmbeddedObject() { if (_currToken == JsonToken.VALUE_EMBEDDED_OBJECT) { return _currentObject(); } return null; }
@Override protected void _handleEOF() throws JsonParseException { _throwInternal(); } }
@Override public void writeNumber(String encodedValue) throws IOException, JsonGenerationException { /* 03-Dec-2010, tatu: related to [JACKSON-423], should try to keep as numeric * identity as long as possible */ _append(JsonToken.VALUE_NUMBER_FLOAT, encodedValue); }