On 7 March 2012 23:47, Emmanuel Bourg <ebo...@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.

If not added then compilers complain.

The point of @Override is to document that you intended to override
the super-class method.
So if the name is misspelt, that will be detected.

All other Commons components (and all other Java projects I contribute
to) use @Override.

> Emmanuel Bourg
>
>
>
> Le 08/03/2012 00:34, s...@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-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to