commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [csv] CSVRecord implements Map<String, String>
Date Thu, 16 Jan 2014 06:42:59 GMT
2014/1/16 Gary Gregory <garydgregory@gmail.com>

> Maybe we _should_ revisit splitting the record class. Now, we have the
> following slots:
>
> CSVRecord:
> comment : String
> mapping : Map<String, Integer>
> recordNumber : long
> values : String[]
>
> If we take out mapping and put in it a subclass, that reduces the "size" of
> the plain record by 25%:
>
> CSVRecord:
> comment : String
> recordNumber : long
> values : String[]
>
> CSVRecordMap extends CSVRecord
> mapping : Map<String, Integer>
>
> or:
>
> CSVRecordMap extends CSVRecord implements Map<String, String>
> mapping : Map<String, Integer>
>
>
> Thoughts?
>

Sounds like a nice idea. We would have to change how the parsing works,
because currently CSVParser implements Iterable<CSVRecord>. We would need a
method that returns an Iterable<CSVRecord> and one that returns an
Iteable<CSVRecordMap> (or MappedCSVRecord?).

We had this discussion [1] a while back, where Paul Benedict mentioned that
the whole design of a Parser that is an Iterable may not be completely
sound.

Benedikt

[1] http://markmail.org/message/occadenoj2nycneh


>
> Gary
>
>
> On Wed, Jan 15, 2014 at 11:22 AM, Emmanuel Bourg <ebourg@apache.org>
> wrote:
>
> > Le 15/01/2014 07:17, Benedikt Ritter a écrit :
> > > A wrapper of some kind like Adrian suggested sounds like the way to go
> > > here. Maybe we could have something like:
> > >
> > > Map<String, String> map = CSVRecordUtils.toMap(record);
> >
> > I had something like that in mind too, but I would rather use
> > record.toMap() and avoid exposing a new class.
> >
> > Emmanuel Bourg
> >
> >
> > ---------------------------------------------------------------------
> > 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message