From 4f4b9cf2516762cd766368759c2c122f19f0caa5 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 19 Sep 2024 16:04:47 -0400 Subject: [PATCH] Sort members --- .../commons/csv/ExtendedBufferedReader.java | 56 +++++++++---------- .../java/org/apache/commons/csv/Lexer.java | 48 ++++++++-------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java index 82e16562c..18c922a50 100644 --- a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java +++ b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java @@ -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 @@ public void close() throws IOException { 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 @@ long getLineNumber() { 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 @@ long getPosition() { 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 @@ public String readLine() throws IOException { return buffer.toString(); } + @Override + public void reset() throws IOException { + lineNumber = lineNumberMark; + lastChar = lastCharMark; + position = positionMark; + super.reset(); + } + } diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java index b25ade052..6d9c8a485 100644 --- a/src/main/java/org/apache/commons/csv/Lexer.java +++ b/src/main/java/org/apache/commons/csv/Lexer.java @@ -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 @@ boolean isStartOfLine(final int ch) { 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. *

@@ -279,6 +295,10 @@ Token nextToken(final Token token) throws IOException { return token; } + private int nullToDisabled(final Character c) { + return c == null ? Constants.UNDEFINED : c.charValue(); // Explicit unboxing + } + /** * Parses an encapsulated token. *

@@ -408,26 +428,6 @@ private Token parseSimpleToken(final Token token, int ch) throws IOException { 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... *