commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Carman <ja...@carmanconsulting.com>
Subject Re: svn commit: r1298215 - in /commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv: CharBuffer.java ExtendedBufferedReader.java UnicodeUnescapeReader.java
Date Thu, 08 Mar 2012 02:35:48 GMT
It's not just about renames.  If you put the @Override annotation,
you're telling the compiler that you think you're overriding
something.  If that method isn't there (you fat-fingered the name or
something), you'll get an error.

On Wed, Mar 7, 2012 at 6:47 PM, Emmanuel Bourg <ebourg@apache.org> wrote:
> I think I never understood the purpose of @Override on the JDK methods. I
> thought @Override was mainly useful to prevent a method renamed in a super
> class to leave non renamed methods in the subclasses. But for methods like
> toString() or read() this is never going to happen. So in this case I think
> @Override adds unnecessary noise.
>
> Emmanuel Bourg
>
>
>
> Le 08/03/2012 00:34, sebb@apache.org a écrit :
>>
>> Author: sebb
>> Date: Wed Mar  7 23:34:39 2012
>> New Revision: 1298215
>>
>> URL: http://svn.apache.org/viewvc?rev=1298215&view=rev
>> Log:
>> @Override + Javadoc
>>
>> Modified:
>>
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CharBuffer.java
>>
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
>>
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/UnicodeUnescapeReader.java
>>
>> Modified:
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CharBuffer.java
>> URL:
>> http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CharBuffer.java?rev=1298215&r1=1298214&r2=1298215&view=diff
>>
>> ==============================================================================
>> ---
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CharBuffer.java
>> (original)
>> +++
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/CharBuffer.java
>> Wed Mar  7 23:34:39 2012
>> @@ -184,8 +184,9 @@ class CharBuffer {
>>       * Converts the contents of the buffer into a StringBuffer.
>>       * This method involves copying the new data once!
>>       *
>> -     * @return
>> +     * @return the contents of the character buffer as a String
>>       */
>> +    @Override
>>      public String toString() {
>>          return new String(c, 0, length);
>>      }
>>
>> Modified:
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
>> URL:
>> http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java?rev=1298215&r1=1298214&r2=1298215&view=diff
>>
>> ==============================================================================
>> ---
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
>> (original)
>> +++
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/ExtendedBufferedReader.java
>> Wed Mar  7 23:34:39 2012
>> @@ -65,6 +65,7 @@ class ExtendedBufferedReader extends Buf
>>       *
>>       * @return the next char or END_OF_STREAM if end of stream has been
>> reached.
>>       */
>> +    @Override
>>      public int read() throws IOException {
>>          // initialize the lookahead
>>          if (lookaheadChar == UNDEFINED) {
>> @@ -103,6 +104,7 @@ class ExtendedBufferedReader extends Buf
>>       *
>>       * @return nof chars actually read or END_OF_STREAM
>>       */
>> +    @Override
>>      public int read(char[] buf, int off, int len) throws IOException {
>>          // do not claim if len == 0
>>          if (len == 0) {
>> @@ -145,6 +147,7 @@ class ExtendedBufferedReader extends Buf
>>       *         including any line-termination characters, or null
>>       *         if the end of the stream has been reached
>>       */
>> +    @Override
>>      public String readLine() throws IOException {
>>
>>          if (lookaheadChar == UNDEFINED) {
>> @@ -186,6 +189,7 @@ class ExtendedBufferedReader extends Buf
>>      /**
>>       * Unsupported
>>       */
>> +    @Override
>>      public long skip(long n) throws IllegalArgumentException, IOException
>> {
>>          throw new UnsupportedOperationException("CSV has no reason to
>> implement this");
>>      }
>> @@ -216,8 +220,10 @@ class ExtendedBufferedReader extends Buf
>>      }
>>
>>      /**
>> -     * Unsupported
>> +     * Unsupported.
>> +     * @throws UnsupportedOperationException if invoked
>>       */
>> +    @Override
>>      public boolean markSupported() {
>>          throw new UnsupportedOperationException("CSV has no reason to
>> implement this");
>>      }
>>
>> Modified:
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/UnicodeUnescapeReader.java
>> URL:
>> http://svn.apache.org/viewvc/commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/UnicodeUnescapeReader.java?rev=1298215&r1=1298214&r2=1298215&view=diff
>>
>> ==============================================================================
>> ---
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/UnicodeUnescapeReader.java
>> (original)
>> +++
>> commons/sandbox/csv/trunk/src/main/java/org/apache/commons/csv/UnicodeUnescapeReader.java
>> Wed Mar  7 23:34:39 2012
>> @@ -38,6 +38,7 @@ class UnicodeUnescapeReader extends Read
>>          this.reader = new PushbackReader(reader, sequence.length);
>>      }
>>
>> +    @Override
>>      public int read(char[] cbuf, int off, int len) throws IOException {
>>          int count = 0;
>>          for (int i = 0; i<  len; i++) {
>> @@ -75,6 +76,7 @@ class UnicodeUnescapeReader extends Read
>>          return ('0'<= c&&  c<= '9') || ('a'<= c&&
 c<= 'f') || ('A'<= c&&
>>  c<= 'F');
>>      }
>>
>> +    @Override
>>      public void close() throws IOException {
>>          if (reader != null) {
>>              reader.close();
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message