Class ColumnFileReader
java.lang.Object
net.fabricmc.mappingio.format.ColumnFileReader
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidDiscard the last mark.intbooleanbooleanisAtBof()booleanisAtEof()booleanisAtEol()Whether EOL has been encountered in the current line yet.intmark()Marks the present position in the stream.@Nullable StringnextCol()Read and consume a column without unescaping.@Nullable StringnextCol(boolean unescape) Read and consume a column, and unescape it if requested.booleanTry to read the current column with specific expected content.@Nullable StringnextCols(boolean unescape) Read and consume all columns until EOL, and unescape if requested.intRead and consume a column and convert it to integer.booleannextLine(int indent) Read and consume until the start of the next line is reached, and return whether the followingindentcharacters matchindentationChar.@Nullable StringpeekCol(boolean unescape) Read a column without consuming, and unescape if requested.@Nullable StringpeekCols(boolean unescape) Read all columns until EOL without consuming, and unescape if requested.intreset()Reset to last mark.voidreset(int indexToResetTo) Reset to the mark with the specified index.
-
Constructor Details
-
ColumnFileReader
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
nextCol
Try to read the current column with specific expected content.The reader will point to the next column or end of line if successful, otherwise remains unchanged.
- Parameters:
expected- Content to expect.- Returns:
trueif the column was read and had the expected content,falseotherwise.- Throws:
IOException
-
nextCol
Read and consume a column without unescaping.- Returns:
nullif nothing has been read (first char was EOL), otherwise the read string (may be empty).- Throws:
IOException
-
nextCol
Read and consume a column, and unescape it if requested.- Returns:
nullif nothing has been read (first char was EOL), otherwise the read string (may be empty).- Throws:
IOException
-
peekCol
Read a column without consuming, and unescape if requested. Since it doesn't consume, it won't (un)mark BOF, EOL or EOF.- Returns:
nullif nothing has been read (first char was EOL), otherwise the read string (may be empty).- Throws:
IOException
-
nextCols
Read and consume all columns until EOL, and unescape if requested.- Returns:
nullif nothing has been read (first char was EOL), otherwise the read string (may be empty).- Throws:
IOException
-
peekCols
Read all columns until EOL without consuming, and unescape if requested. Since it doesn't consume, it won't (un)mark BOF, EOL or EOF.- Returns:
nullif nothing has been read (first char was EOL), otherwise the read string (may be empty).- Throws:
IOException
-
nextIntCol
Read and consume a column and convert it to integer.- Returns:
- -1 if nothing has been read (first char was EOL), otherwise the number present.
- Throws:
IOException
-
nextLine
Read and consume until the start of the next line is reached, and return whether the followingindentcharacters matchindentationChar.Empty lines are skipped if
indentis 0.- Parameters:
indent- The number of characters to check for indentation.- Returns:
trueif the next line has the specified indentation or higher,falseotherwise.- Throws:
IOException
-
hasExtraIndents
- Throws:
IOException
-
getLineNumber
public int getLineNumber() -
isAtEol
public boolean isAtEol()Whether EOL has been encountered in the current line yet. -
isAtBof
public boolean isAtBof() -
isAtEof
public boolean isAtEof() -
mark
public int mark()Marks the present position in the stream. Subsequent calls toreset()will reposition the stream to this point. In comparison toReader.mark(int)this method stacks, so don't forget to calldiscardMark()if you don't need the mark anymore.- Returns:
- the mark index (starting at 1)
-
discardMark
public void discardMark()Discard the last mark. -
reset
public int reset()Reset to last mark. The marked data isn't discarded, so can be called multiple times. If you want to reset to an older mark, usereset(int).- Returns:
- The index of the mark that was reset to.
-
reset
public void reset(int indexToResetTo) Reset to the mark with the specified index. Unless reset to 0, the marked data isn't discarded afterwards, so can be called multiple times. Use negative indices to reset to a mark relative to the current one.
-