You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Benedikt Ritter <br...@apache.org> on 2013/08/01 16:17:02 UTC

[CSV] Throw NoSuchElementException from Iterator if CSVParser is closed? (was: Fwd: svn commit: r1509068 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ test/resources/ferc.gov/)

Hi,

since Emmanuel has hijacked the original thread for discussing legal
issues, I'm bringing this up under a new topic ;-)

Please see my comments below.

Benedikt

---------- Forwarded message ----------
From: Benedikt Ritter <br...@apache.org>
Date: 2013/8/1
Subject: Re: svn commit: r1509068 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/
test/resources/ferc.gov/
To: Commons Developers List <de...@commons.apache.org>


Hi Gary,


2013/8/1 <gg...@apache.org>

Author: ggregory
> Date: Thu Aug  1 02:03:33 2013
> New Revision: 1509068
>
> URL: http://svn.apache.org/r1509068
> Log:
> - Add some real world CSV files.
> - Add a record API to get column values using an Enum.
> - Throw a better exception when a resource is not found in a class loader
> for the parser.
> - Replace some tabs with spaces.
>

<snip>


>
> @@ -371,9 +400,9 @@ public class CSVParser implements Iterab
>              }
>
>              public boolean hasNext() {
> -               if (CSVParser.this.isClosed()) {
> -                       return false;
> -               }
> +                if (CSVParser.this.isClosed()) {
> +                    return false;
> +                }
>                  if (this.current == null) {
>                      this.current = this.getNextRecord();
>                  }
> @@ -382,9 +411,9 @@ public class CSVParser implements Iterab
>              }
>
>              public CSVRecord next() {
> -               if (CSVParser.this.isClosed()) {
> -                       return null;
> -               }
> +                if (CSVParser.this.isClosed()) {
> +                    return null;
> +                }
>                  CSVRecord next = this.current;
>                  this.current = null;
>
>
JavaDoc of the Iterator interface says that next() throws a
NoSuchElementExecption if there are no more elements [1]. I'm not sure if
this applies if the parser is closed. WDYT?

Benedikt

[1] http://docs.oracle.com/javase/6/docs/api/java/util/Iterator.html#next()


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: [CSV] Throw NoSuchElementException from Iterator if CSVParser is closed? (was: Fwd: svn commit: r1509068 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ test/resources/ferc.gov/)

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Aug 1, 2013 at 10:53 AM, Benedikt Ritter <br...@apache.org> wrote:

> 2013/8/1 Gary Gregory <ga...@gmail.com>
>
> > On Thu, Aug 1, 2013 at 10:35 AM, sebb <se...@gmail.com> wrote:
> >
> > > On 1 August 2013 15:23, Emmanuel Bourg <eb...@apache.org> wrote:
> > > > Le 01/08/2013 16:17, Benedikt Ritter a écrit :
> > > >
> > > >> since Emmanuel has hijacked the original thread for discussing legal
> > > >> issues, I'm bringing this up under a new topic ;-)
> > > >
> > > > Hey I simply started a parallel discussion ;)
> > > >
> > > > +1 for NoSuchElementException
> > >
> > > Perhaps indicate in the message that the parser has been closed, as
> > > this is a slightly unusual situation.
> > >
> >
> > Hm, I like that.
> >
> > Benedikt, would you like to do the honors?
> >
>
> Jep, no problem, but I'll not get to it before tonight.
>

That's fine with me.

Gary


>
>
> >
> > Gary
> >
> >
> > > > Emmanuel Bourg
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > > For additional commands, e-mail: dev-help@commons.apache.org
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> > >
> >
> >
> > --
> > E-Mail: garydgregory@gmail.com | ggregory@apache.org
> > Java Persistence with Hibernate, Second Edition<
> > http://www.manning.com/bauer3/>
> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> > Spring Batch in Action <http://www.manning.com/templier/>
> > Blog: http://garygregory.wordpress.com
> > Home: http://garygregory.com/
> > Tweet! http://twitter.com/GaryGregory
> >
>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [CSV] Throw NoSuchElementException from Iterator if CSVParser is closed? (was: Fwd: svn commit: r1509068 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ test/resources/ferc.gov/)

Posted by Benedikt Ritter <br...@apache.org>.
2013/8/1 Gary Gregory <ga...@gmail.com>

> On Thu, Aug 1, 2013 at 10:35 AM, sebb <se...@gmail.com> wrote:
>
> > On 1 August 2013 15:23, Emmanuel Bourg <eb...@apache.org> wrote:
> > > Le 01/08/2013 16:17, Benedikt Ritter a écrit :
> > >
> > >> since Emmanuel has hijacked the original thread for discussing legal
> > >> issues, I'm bringing this up under a new topic ;-)
> > >
> > > Hey I simply started a parallel discussion ;)
> > >
> > > +1 for NoSuchElementException
> >
> > Perhaps indicate in the message that the parser has been closed, as
> > this is a slightly unusual situation.
> >
>
> Hm, I like that.
>
> Benedikt, would you like to do the honors?
>

Jep, no problem, but I'll not get to it before tonight.


>
> Gary
>
>
> > > Emmanuel Bourg
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > > For additional commands, e-mail: dev-help@commons.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> > For additional commands, e-mail: dev-help@commons.apache.org
> >
> >
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<
> http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Re: [CSV] Throw NoSuchElementException from Iterator if CSVParser is closed? (was: Fwd: svn commit: r1509068 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ test/resources/ferc.gov/)

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Aug 1, 2013 at 10:35 AM, sebb <se...@gmail.com> wrote:

> On 1 August 2013 15:23, Emmanuel Bourg <eb...@apache.org> wrote:
> > Le 01/08/2013 16:17, Benedikt Ritter a écrit :
> >
> >> since Emmanuel has hijacked the original thread for discussing legal
> >> issues, I'm bringing this up under a new topic ;-)
> >
> > Hey I simply started a parallel discussion ;)
> >
> > +1 for NoSuchElementException
>
> Perhaps indicate in the message that the parser has been closed, as
> this is a slightly unusual situation.
>

Hm, I like that.

Benedikt, would you like to do the honors?

Gary


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


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: [CSV] Throw NoSuchElementException from Iterator if CSVParser is closed? (was: Fwd: svn commit: r1509068 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ test/resources/ferc.gov/)

Posted by sebb <se...@gmail.com>.
On 1 August 2013 15:23, Emmanuel Bourg <eb...@apache.org> wrote:
> Le 01/08/2013 16:17, Benedikt Ritter a écrit :
>
>> since Emmanuel has hijacked the original thread for discussing legal
>> issues, I'm bringing this up under a new topic ;-)
>
> Hey I simply started a parallel discussion ;)
>
> +1 for NoSuchElementException

Perhaps indicate in the message that the parser has been closed, as
this is a slightly unusual situation.

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

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


Re: [CSV] Throw NoSuchElementException from Iterator if CSVParser is closed? (was: Fwd: svn commit: r1509068 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/ test/resources/ferc.gov/)

Posted by Emmanuel Bourg <eb...@apache.org>.
Le 01/08/2013 16:17, Benedikt Ritter a écrit :

> since Emmanuel has hijacked the original thread for discussing legal
> issues, I'm bringing this up under a new topic ;-)

Hey I simply started a parallel discussion ;)

+1 for NoSuchElementException

Emmanuel Bourg


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