From 516b82b4712da79bcefbeeb06b8a59f17aa99976 Mon Sep 17 00:00:00 2001 From: Emmanuel Bourg Date: Tue, 6 Mar 2012 21:00:44 +0000 Subject: [PATCH] Made all public methods in CharBuffer and ExtendedBufferedReader package private git-svn-id: https://svn.apache.org/repos/asf/commons/sandbox/csv/trunk@1297719 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/csv/CharBuffer.java | 28 +++++++++---------- .../commons/csv/ExtendedBufferedReader.java | 18 +++++------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CharBuffer.java b/src/main/java/org/apache/commons/csv/CharBuffer.java index 5b88a9c8..26f014b3 100644 --- a/src/main/java/org/apache/commons/csv/CharBuffer.java +++ b/src/main/java/org/apache/commons/csv/CharBuffer.java @@ -38,7 +38,7 @@ class CharBuffer { /** * Creates a new CharBuffer with an initial capacity of 32 characters. */ - public CharBuffer() { + CharBuffer() { this(32); } @@ -46,7 +46,7 @@ class CharBuffer { * Creates a new CharBuffer with an initial capacity * of length characters. */ - public CharBuffer(final int length) { + CharBuffer(final int length) { if (length == 0) { throw new IllegalArgumentException("Can't create an empty CharBuffer"); } @@ -56,7 +56,7 @@ class CharBuffer { /** * Empties the buffer. The capacity still remains the same, so no memory is freed. */ - public void clear() { + void clear() { length = 0; } @@ -65,7 +65,7 @@ class CharBuffer { * * @return the number of characters */ - public int length() { + int length() { return length; } @@ -74,7 +74,7 @@ class CharBuffer { * * @return the maximum number of characters that can be stored in this buffer without resizing it. */ - public int capacity() { + int capacity() { return c.length; } @@ -84,7 +84,7 @@ class CharBuffer { * * @param cb the CharBuffer to append or null */ - public void append(final CharBuffer cb) { + void append(final CharBuffer cb) { if (cb == null) { return; } @@ -99,7 +99,7 @@ class CharBuffer { * * @param s the String to append or null */ - public void append(final String s) { + void append(final String s) { if (s == null) { return; } @@ -112,7 +112,7 @@ class CharBuffer { * * @param data the char[] to append or null */ - public void append(final char[] data) { + void append(final char[] data) { if (data == null) { return; } @@ -127,7 +127,7 @@ class CharBuffer { * * @param data the char to append */ - public void append(final char data) { + void append(final char data) { provideCapacity(length + 1); c[length] = data; length++; @@ -137,7 +137,7 @@ class CharBuffer { * Shrinks the capacity of the buffer to the current length if necessary. * This method involves copying the data once! */ - public void shrink() { + void shrink() { if (c.length == length) { return; } @@ -149,7 +149,7 @@ class CharBuffer { /** * Removes trailing whitespace. */ - public void trimTrailingWhitespace() { + void trimTrailingWhitespace() { while (length > 0 && Character.isWhitespace(c[length - 1])) { length--; } @@ -164,7 +164,7 @@ class CharBuffer { * * @return */ - public char[] getCharacters() { + char[] getCharacters() { if (c.length == length) { return c; } @@ -176,7 +176,7 @@ class CharBuffer { /** * Returns the character at the specified position. */ - public char charAt(int pos) { + char charAt(int pos) { return c[pos]; } @@ -195,7 +195,7 @@ class CharBuffer { * * @param capacity */ - public void provideCapacity(final int capacity) { + void provideCapacity(final int capacity) { if (c.length >= capacity) { return; } diff --git a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java index 68bb226f..7c5b163e 100644 --- a/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java +++ b/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java @@ -34,10 +34,10 @@ import java.io.Reader; class ExtendedBufferedReader extends BufferedReader { /** The end of stream symbol */ - public static final int END_OF_STREAM = -1; + static final int END_OF_STREAM = -1; /** Undefined state for the lookahead char */ - public static final int UNDEFINED = -2; + static final int UNDEFINED = -2; /** The lookahead chars */ private int lookaheadChar = UNDEFINED; @@ -53,7 +53,7 @@ class ExtendedBufferedReader extends BufferedReader { /** * Created extended buffered reader using default buffer-size */ - public ExtendedBufferedReader(Reader r) { + ExtendedBufferedReader(Reader r) { super(r); /* note uh: do not fetch the first char here, * because this might block the method! @@ -87,7 +87,7 @@ class ExtendedBufferedReader extends BufferedReader { * * @return the last read char or UNDEFINED */ - public int readAgain() { + int readAgain() { return lastChar; } @@ -198,7 +198,7 @@ class ExtendedBufferedReader extends BufferedReader { * * @return the next char (without consuming it) or END_OF_STREAM */ - public int lookAhead() throws IOException { + int lookAhead() throws IOException { if (lookaheadChar == UNDEFINED) { lookaheadChar = super.read(); } @@ -211,12 +211,8 @@ class ExtendedBufferedReader extends BufferedReader { * * @return the current-line-number (or -1) */ - public int getLineNumber() { - if (lineCounter > -1) { - return lineCounter; - } else { - return -1; - } + int getLineNumber() { + return lineCounter > -1 ? lineCounter : -1; } /**