Class TextBuffer
java.lang.Object
com.fasterxml.jackson.dataformat.csv.impl.TextBuffer
Helper class for efficiently aggregating parsed and decoded
textual content
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.fasterxml.jackson.core.util.BufferRecycler
private char[]
private int
Number of characters in currently active (last) segmentprivate boolean
Flag that indicates whether _seqments is non-emptyprivate char[]
Shared input buffer; stored here in case some input can be returned as is, without being copied to collector's own buffers.private int
private int
Character offset of first char in input buffer; -1 to indicate that input buffer currently does not contain any useful char dataprivate char[]
private String
String that will be constructed when the whole contents are needed; will be temporarily stored in case asked for again.private LinkedList<char[]>
List of segments prior to currently active segment.private int
Amount of characters in segments in_segments
(package private) static final int
(package private) static final int
(package private) static final char[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate final char[]
_charArray
(int len) private String
_doTrim
(int ptr) private char[]
private final void
char[]
Convenience method for converting contents of the buffer into aBigDecimal
.double
Convenience method for converting contents of the buffer into a Double value.final char[]
void
Method called to make sure that buffer is not using shared input buffer; if it is, it will copy such contents to private buffer.private void
expand
(int minNewSegmentSize) private final char[]
findBuffer
(int needed) Helper method used to find a buffer to use, ideally one recycled earlier.finishAndReturn
(int lastSegmentEnd, boolean trimTrailingSpaces) char[]
char[]
int
char[]
int
boolean
boolean
void
void
reset()
void
resetWithString
(String value) int
size()
private void
unshare
(int needExtra) Method called if/when we need to append content when we have been initialized to use shared buffer.
-
Field Details
-
NO_CHARS
static final char[] NO_CHARS -
MIN_SEGMENT_LEN
static final int MIN_SEGMENT_LEN- See Also:
-
MAX_SEGMENT_LEN
static final int MAX_SEGMENT_LEN- See Also:
-
_allocator
private final com.fasterxml.jackson.core.util.BufferRecycler _allocator -
_inputBuffer
private char[] _inputBufferShared input buffer; stored here in case some input can be returned as is, without being copied to collector's own buffers. -
_inputStart
private int _inputStartCharacter offset of first char in input buffer; -1 to indicate that input buffer currently does not contain any useful char data -
_inputLen
private int _inputLen -
_segments
List of segments prior to currently active segment. -
_hasSegments
private boolean _hasSegmentsFlag that indicates whether _seqments is non-empty -
_segmentSize
private int _segmentSizeAmount of characters in segments in_segments
-
_currentSegment
private char[] _currentSegment -
_currentSize
private int _currentSizeNumber of characters in currently active (last) segment -
_resultString
String that will be constructed when the whole contents are needed; will be temporarily stored in case asked for again. -
_resultArray
private char[] _resultArray
-
-
Constructor Details
-
TextBuffer
public TextBuffer(com.fasterxml.jackson.core.util.BufferRecycler allocator)
-
-
Method Details
-
releaseBuffers
public void releaseBuffers() -
reset
public void reset() -
resetWithString
-
findBuffer
private final char[] findBuffer(int needed) Helper method used to find a buffer to use, ideally one recycled earlier. -
clearSegments
private final void clearSegments() -
size
public int size()- Returns:
- Number of characters currently stored by this collector
-
getTextOffset
public int getTextOffset() -
hasTextAsCharacters
public boolean hasTextAsCharacters() -
getTextBuffer
public char[] getTextBuffer() -
contentsAsString
-
contentsAsArray
public char[] contentsAsArray() -
contentsAsDecimal
Convenience method for converting contents of the buffer into aBigDecimal
.- Throws:
NumberFormatException
-
contentsAsDouble
Convenience method for converting contents of the buffer into a Double value.- Throws:
NumberFormatException
-
looksLikeInt
public boolean looksLikeInt() -
getCurrentSegment
public char[] getCurrentSegment() -
emptyAndGetCurrentSegment
public final char[] emptyAndGetCurrentSegment() -
getCurrentSegmentSize
public int getCurrentSegmentSize() -
finishAndReturn
- Parameters:
lastSegmentEnd
- End offset in the currently active segment, could be 0 in the case of first character is delimiter or end-of-linetrimTrailingSpaces
- Whether trailing spaces should be trimmed or not
-
_doTrim
-
finishCurrentSegment
public char[] finishCurrentSegment() -
expand
private void expand(int minNewSegmentSize) -
buildResultArray
private char[] buildResultArray() -
_charArray
private final char[] _charArray(int len)
-