Sort members
This commit is contained in:
parent
6a11b896aa
commit
4f4b9cf251
|
@ -56,22 +56,6 @@ final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
|
|||
super(reader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(final int readAheadLimit) throws IOException {
|
||||
lineNumberMark = lineNumber;
|
||||
lastCharMark = lastChar;
|
||||
positionMark = position;
|
||||
super.mark(readAheadLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
lineNumber = lineNumberMark;
|
||||
lastChar = lastCharMark;
|
||||
position = positionMark;
|
||||
super.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the stream.
|
||||
*
|
||||
|
@ -85,6 +69,18 @@ final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
|
|||
super.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last character that was read as an integer (0 to 65535). This will be the last character returned by
|
||||
* any of the read methods. This will not include a character read using the {@link #peek()} method. If no
|
||||
* character has been read then this will return {@link Constants#UNDEFINED}. If the end of the stream was reached
|
||||
* on the last read then this will return {@link IOUtils#EOF}.
|
||||
*
|
||||
* @return the last character that was read
|
||||
*/
|
||||
int getLastChar() {
|
||||
return lastChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current line number
|
||||
*
|
||||
|
@ -98,18 +94,6 @@ final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
|
|||
return lineNumber + 1; // Allow for counter being incremented only at EOL
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last character that was read as an integer (0 to 65535). This will be the last character returned by
|
||||
* any of the read methods. This will not include a character read using the {@link #peek()} method. If no
|
||||
* character has been read then this will return {@link Constants#UNDEFINED}. If the end of the stream was reached
|
||||
* on the last read then this will return {@link IOUtils#EOF}.
|
||||
*
|
||||
* @return the last character that was read
|
||||
*/
|
||||
int getLastChar() {
|
||||
return lastChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the character position in the reader.
|
||||
*
|
||||
|
@ -119,6 +103,14 @@ final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
|
|||
return this.position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mark(final int readAheadLimit) throws IOException {
|
||||
lineNumberMark = lineNumber;
|
||||
lastCharMark = lastChar;
|
||||
positionMark = position;
|
||||
super.mark(readAheadLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
final int current = super.read();
|
||||
|
@ -190,4 +182,12 @@ final class ExtendedBufferedReader extends UnsynchronizedBufferedReader {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
lineNumber = lineNumberMark;
|
||||
lastChar = lastCharMark;
|
||||
position = positionMark;
|
||||
super.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,6 +63,26 @@ final class Lexer implements Closeable {
|
|||
this.escapeDelimiterBuf = new char[2 * delimiter.length - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the next escaped character to the token's content.
|
||||
*
|
||||
* @param token the current token
|
||||
* @throws IOException on stream access error
|
||||
* @throws CSVException Thrown on invalid input.
|
||||
*/
|
||||
private void appendNextEscapedCharacterToToken(final Token token) throws IOException {
|
||||
if (isEscapeDelimiter()) {
|
||||
token.content.append(delimiter);
|
||||
} else {
|
||||
final int unescaped = readEscape();
|
||||
if (unescaped == EOF) { // unexpected char after escape
|
||||
token.content.append((char) escape).append((char) reader.getLastChar());
|
||||
} else {
|
||||
token.content.append((char) unescaped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes resources.
|
||||
*
|
||||
|
@ -190,10 +210,6 @@ final class Lexer implements Closeable {
|
|||
return ch == Constants.LF || ch == Constants.CR || ch == Constants.UNDEFINED;
|
||||
}
|
||||
|
||||
private int nullToDisabled(final Character c) {
|
||||
return c == null ? Constants.UNDEFINED : c.charValue(); // Explicit unboxing
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next token.
|
||||
* <p>
|
||||
|
@ -279,6 +295,10 @@ final class Lexer implements Closeable {
|
|||
return token;
|
||||
}
|
||||
|
||||
private int nullToDisabled(final Character c) {
|
||||
return c == null ? Constants.UNDEFINED : c.charValue(); // Explicit unboxing
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an encapsulated token.
|
||||
* <p>
|
||||
|
@ -408,26 +428,6 @@ final class Lexer implements Closeable {
|
|||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the next escaped character to the token's content.
|
||||
*
|
||||
* @param token the current token
|
||||
* @throws IOException on stream access error
|
||||
* @throws CSVException Thrown on invalid input.
|
||||
*/
|
||||
private void appendNextEscapedCharacterToToken(final Token token) throws IOException {
|
||||
if (isEscapeDelimiter()) {
|
||||
token.content.append(delimiter);
|
||||
} else {
|
||||
final int unescaped = readEscape();
|
||||
if (unescaped == EOF) { // unexpected char after escape
|
||||
token.content.append((char) escape).append((char) reader.getLastChar());
|
||||
} else {
|
||||
token.content.append((char) unescaped);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Greedily accepts \n, \r and \r\n This checker consumes silently the second control-character...
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue