Package org.commonmark.internal.util
Class LineReader
- java.lang.Object
-
- org.commonmark.internal.util.LineReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class LineReader extends java.lang.Object implements java.io.CloseableReads lines from a reader likeBufferedReaderbut also returns the line terminators.Line terminators can be either a line feed
"\n", carriage return"\r", or a carriage return followed by a line feed"\r\n". CallgetLineTerminator()afterreadLine()to obtain the corresponding line terminator. If a stream has a line at the end without a terminator,getLineTerminator()returnsnull.
-
-
Field Summary
Fields Modifier and Type Field Description private char[]cbuf(package private) static intCHAR_BUFFER_SIZE(package private) static intEXPECTED_LINE_LENGTHprivate intlimitprivate java.lang.StringlineTerminatorprivate intpositionprivate java.io.Readerreader
-
Constructor Summary
Constructors Constructor Description LineReader(java.io.Reader reader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()private voidfill()private java.lang.Stringfinish(java.lang.StringBuilder sb, int start, int end)java.lang.StringgetLineTerminator()Return the line terminator of the last read line fromreadLine().private java.lang.Stringline(java.lang.String line, java.lang.String lineTerminator)java.lang.StringreadLine()Read a line of text.
-
-
-
Field Detail
-
CHAR_BUFFER_SIZE
static final int CHAR_BUFFER_SIZE
- See Also:
- Constant Field Values
-
EXPECTED_LINE_LENGTH
static final int EXPECTED_LINE_LENGTH
- See Also:
- Constant Field Values
-
reader
private java.io.Reader reader
-
cbuf
private char[] cbuf
-
position
private int position
-
limit
private int limit
-
lineTerminator
private java.lang.String lineTerminator
-
-
Method Detail
-
readLine
public java.lang.String readLine() throws java.io.IOExceptionRead a line of text.- Returns:
- the line, or
nullwhen the end of the stream has been reached and no more lines can be read - Throws:
java.io.IOException
-
getLineTerminator
public java.lang.String getLineTerminator()
Return the line terminator of the last read line fromreadLine().- Returns:
"\n","\r","\r\n", ornull
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
fill
private void fill() throws java.io.IOException- Throws:
java.io.IOException
-
line
private java.lang.String line(java.lang.String line, java.lang.String lineTerminator)
-
finish
private java.lang.String finish(java.lang.StringBuilder sb, int start, int end)
-
-