Top Description Fields Constructors Methods
org.snakeyaml.engine.v2.scanner

public final Class StreamReader

extends Object
Class Inheritance
Imports
java.io.IOException, .Reader, .StringReader, java.util.Arrays, .Optional, org.snakeyaml.engine.v2.api.LoadSettings, org.snakeyaml.engine.v2.common.CharConstants, org.snakeyaml.engine.v2.exceptions.Mark, .ReaderException, .YamlEngineException

Read the provided stream of code points into String and implement look-ahead operations. Checks if code points are in the allowed range.

Field Summary

Modifier and TypeField and Description
private final char[]
private final int
private int[]
codePointsWindow

Read data (as a moving window for input stream)

private int
private int
dataLength

Real length of the data in dataWindow

private int
private boolean
private int
index

index is only required to implement 1024 key length restriction and the total length restriction

private int
private final String
private int
pointer

The variable points to the current position in the data array

private final Reader
private final boolean

Constructor Summary

AccessConstructor and Description
public
StreamReader(Reader
- the input
reader
,
LoadSettings
- configuration options
loadSettings
)
Deprecated use the other constructor with LoadSettings first

public
StreamReader(LoadSettings
- configuration options
loadSettings
,
Reader
- the input
reader
)

Create

public
StreamReader(String
- the input
stream
,
LoadSettings
- configuration options
loadSettings
)
Deprecated use the other constructor with LoadSettings first

public
StreamReader(LoadSettings
- configuration options
loadSettings
,
String
- the input
stream
)

Create

Method Summary

Modifier and TypeMethod and Description
private boolean
private boolean
ensureEnoughData(int size)

public void
forward()

read the next character and move the pointer.

public void
forward(int
amount of characters to move forward
length
)

read the next length characters and move the pointer.

public int

Returns:

current position as number (in characters) from the beginning of the current line
getColumn
()

public int

Returns:

index of the current position from the beginning of the current document
getDocumentIndex
()

Get the position of the currect char in the current YAML document

public int

Returns:

current position as number (in characters) from the beginning of the stream
getIndex
()

public int

Returns:

current line from the beginning of the stream
getLine
()

public Optional<Mark>

Returns:

Mark of the current position or empty Optional otherwise
getMark
()

Generate Mark if it is configured

public static boolean

Returns:

true only when everything is human-readable
isPrintable
(final String
- content to be checked for human-readability
data
)

Check if the all the data is human-readable (used in Representer)

public static boolean

Returns:

true only when the code point is human-readable
isPrintable
(final int
- code point to be checked for human-readability
c
)

Check if the code point is human-readable

private void
moveIndices(int length)

public int

Returns:

the next code point or 0 if empty
peek
()

Peek the next code point (look without moving the pointer)

public int

Returns:

the next index-th code point or 0 if empty
peek
(int
to peek
index
)

Peek the next index-th code point

public String

Returns:

the String representation
prefix
(int
amount of the characters to convert
length
)

Create String from code points

public String

Returns:

the next length code points
prefixForward
(int
amount of characters to get
length
)

prefix(length) immediately followed by forward(length)

public void
resetDocumentIndex()

Reset the position to start (at the start of a new document in the stream)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final char[] buffer
bufferSizeback to summary
private final int bufferSize
codePointsWindowback to summary
private int[] codePointsWindow

Read data (as a moving window for input stream)

columnback to summary
private int column
dataLengthback to summary
private int dataLength

Real length of the data in dataWindow

documentIndexback to summary
private int documentIndex
eofback to summary
private boolean eof
indexback to summary
private int index

index is only required to implement 1024 key length restriction and the total length restriction

lineback to summary
private int line
nameback to summary
private final String name
pointerback to summary
private int pointer

The variable points to the current position in the data array

streamback to summary
private final Reader stream
useMarksback to summary
private final boolean useMarks

Constructor Detail

StreamReaderback to summary
public StreamReader(Reader reader, LoadSettings loadSettings)

Deprecated

use the other constructor with LoadSettings first

Parameters
reader:Reader

- the input

loadSettings:LoadSettings

- configuration options

Annotations
@Deprecated
StreamReaderback to summary
public StreamReader(LoadSettings loadSettings, Reader reader)

Create

Parameters
loadSettings:LoadSettings

- configuration options

reader:Reader

- the input

StreamReaderback to summary
public StreamReader(String stream, LoadSettings loadSettings)

Deprecated

use the other constructor with LoadSettings first

Parameters
stream:String

- the input

loadSettings:LoadSettings

- configuration options

Annotations
@Deprecated
StreamReaderback to summary
public StreamReader(LoadSettings loadSettings, String stream)

Create

Parameters
loadSettings:LoadSettings

- configuration options

stream:String

- the input

Method Detail

ensureEnoughDataback to summary
private boolean ensureEnoughData()
ensureEnoughDataback to summary
private boolean ensureEnoughData(int size)
forwardback to summary
public void forward()

read the next character and move the pointer. if the last character is high surrogate one more character will be read

forwardback to summary
public void forward(int length)

read the next length characters and move the pointer. if the last character is high surrogate one more character will be read

Parameters
length:int

amount of characters to move forward

getColumnback to summary
public int getColumn()
Returns:int

current position as number (in characters) from the beginning of the current line

getDocumentIndexback to summary
public int getDocumentIndex()

Get the position of the currect char in the current YAML document

Returns:int

index of the current position from the beginning of the current document

getIndexback to summary
public int getIndex()
Returns:int

current position as number (in characters) from the beginning of the stream

getLineback to summary
public int getLine()
Returns:int

current line from the beginning of the stream

getMarkback to summary
public Optional<Mark> getMark()

Generate Mark if it is configured

Returns:Optional<Mark>

Mark of the current position or empty Optional otherwise

isPrintableback to summary
public static boolean isPrintable(final String data)

Check if the all the data is human-readable (used in Representer)

Parameters
data:String

- content to be checked for human-readability

Returns:boolean

true only when everything is human-readable

isPrintableback to summary
public static boolean isPrintable(final int c)

Check if the code point is human-readable

Parameters
c:int

- code point to be checked for human-readability

Returns:boolean

true only when the code point is human-readable

moveIndicesback to summary
private void moveIndices(int length)
peekback to summary
public int peek()

Peek the next code point (look without moving the pointer)

Returns:int

the next code point or 0 if empty

peekback to summary
public int peek(int index)

Peek the next index-th code point

Parameters
index:int

to peek

Returns:int

the next index-th code point or 0 if empty

prefixback to summary
public String prefix(int length)

Create String from code points

Parameters
length:int

amount of the characters to convert

Returns:String

the String representation

prefixForwardback to summary
public String prefixForward(int length)

prefix(length) immediately followed by forward(length)

Parameters
length:int

amount of characters to get

Returns:String

the next length code points

resetDocumentIndexback to summary
public void resetDocumentIndex()

Reset the position to start (at the start of a new document in the stream)

updateback to summary
private void update()