Re: [csv] CSVRecord implements Map

2014-01-17 Thread sebb
On 17 January 2014 08:38, Benedikt Ritter wrote: > 2014/1/17 sebb > >> On 17 January 2014 00:57, Gary Gregory wrote: >> > On Thu, Jan 16, 2014 at 7:24 PM, sebb wrote: >> > >> >> On 16 January 2014 20:58, Gary Gregory wrote: >> >> > On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg >> >> wrote:

Re: [csv] CSVRecord implements Map

2014-01-17 Thread Benedikt Ritter
2014/1/17 sebb > On 17 January 2014 00:57, Gary Gregory wrote: > > On Thu, Jan 16, 2014 at 7:24 PM, sebb wrote: > > > >> On 16 January 2014 20:58, Gary Gregory wrote: > >> > On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg > >> wrote: > >> > > >> >> Le 15/01/2014 14:04, Gary Gregory a écrit :

Re: [csv] CSVRecord implements Map

2014-01-16 Thread sebb
On 17 January 2014 00:57, Gary Gregory wrote: > On Thu, Jan 16, 2014 at 7:24 PM, sebb wrote: > >> On 16 January 2014 20:58, Gary Gregory wrote: >> > On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg >> wrote: >> > >> >> Le 15/01/2014 14:04, Gary Gregory a écrit : >> >> >> >> > Uh, I want to go th

Re: [csv] CSVRecord implements Map

2014-01-16 Thread Gary Gregory
On Thu, Jan 16, 2014 at 7:24 PM, sebb wrote: > On 16 January 2014 20:58, Gary Gregory wrote: > > On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg > wrote: > > > >> Le 15/01/2014 14:04, Gary Gregory a écrit : > >> > >> > Uh, I want to go the other way around. See my use case. > >> > >> Why isn't

Re: [csv] CSVRecord implements Map

2014-01-16 Thread sebb
On 16 January 2014 20:58, Gary Gregory wrote: > On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg wrote: > >> Le 15/01/2014 14:04, Gary Gregory a écrit : >> >> > Uh, I want to go the other way around. See my use case. >> >> Why isn't this suitable to your use case? You could write: >> >>factory

Re: [csv] CSVRecord implements Map

2014-01-16 Thread Emmanuel Bourg
Le 16/01/2014 21:58, Gary Gregory a écrit : > That would work. What is still not clean or OO is that toMap() means > nothing when no headers are defined. Well, so be it. > I've split the record into a mapped record subclass here: > > https://issues.apache.org/jira/browse/CSV-104 > > Thoughts?

Re: [csv] CSVRecord implements Map

2014-01-16 Thread Gary Gregory
On Thu, Jan 16, 2014 at 7:49 AM, Emmanuel Bourg wrote: > Le 15/01/2014 14:04, Gary Gregory a écrit : > > > Uh, I want to go the other way around. See my use case. > > Why isn't this suitable to your use case? You could write: > >factory.create(record.toMap()); > > and then remove the create(C

Re: [csv] CSVRecord implements Map

2014-01-16 Thread Emmanuel Bourg
Le 15/01/2014 14:04, Gary Gregory a écrit : > Uh, I want to go the other way around. See my use case. Why isn't this suitable to your use case? You could write: factory.create(record.toMap()); and then remove the create(CSVRecord) method with the duplicated implementation. What am I missing

Re: [csv] CSVRecord implements Map

2014-01-16 Thread Emmanuel Bourg
Le 16/01/2014 07:04, Gary Gregory a écrit : > Thoughts? I don't mind improving how the internal state of CSVRecord is stored, but that shouldn't cause a regression in the usability and make it harder to access the record by key or by index. I don't think the size of a CSVRecord is really an issu

Re: [csv] CSVRecord implements Map

2014-01-16 Thread Adrian Crum
CSVRecordMap implements Map { CSVRecordMap(CSVRecord record) { } } Use the Map implementation to access the record in a Map-like way, use the CSVRecord instance to access the record in a List-like way. Adrian Crum Sandglass Software www.sandglass-software.com On 1/16/2014 1:04 AM, Gar

Re: [csv] CSVRecord implements Map

2014-01-15 Thread Benedikt Ritter
2014/1/16 Gary Gregory > Maybe we _should_ revisit splitting the record class. Now, we have the > following slots: > > CSVRecord: > comment : String > mapping : Map > recordNumber : long > values : String[] > > If we take out mapping and put in it a subclass, that reduces the "size" of > the plai

Re: [csv] CSVRecord implements Map

2014-01-15 Thread Gary Gregory
Maybe we _should_ revisit splitting the record class. Now, we have the following slots: CSVRecord: comment : String mapping : Map 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

Re: [csv] CSVRecord implements Map

2014-01-15 Thread Emmanuel Bourg
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 map = CSVRecordUtils.toMap(record); I had something like that in mind too, but I would rather use record.toMap() and avoid ex

Re: [csv] CSVRecord implements Map

2014-01-15 Thread Gary Gregory
On Wed, Jan 15, 2014 at 4:19 AM, Jörg Schaible wrote: > Hi Adrian, > > Adrian Crum wrote: > > > That would only work if the CSV file had column names. > > No, it works only if it has *unique* column names. Guess, this is normally > the case, but there's no such requirement. > If your column name

Re: [csv] CSVRecord implements Map

2014-01-15 Thread Gary Gregory
On Wed, Jan 15, 2014 at 1:17 AM, Benedikt Ritter wrote: > A wrapper of some kind like Adrian suggested sounds like the way to go > here. Maybe we could have something like: > > Map map = CSVRecordUtils.toMap(record); > Uh, I want to go the other way around. See my use case. Gary > > Benedikt >

Re: [csv] CSVRecord implements Map

2014-01-15 Thread Jörg Schaible
Hi Adrian, Adrian Crum wrote: > That would only work if the CSV file had column names. No, it works only if it has *unique* column names. Guess, this is normally the case, but there's no such requirement. > Maybe make a > class that implements Map and contains a CSVRecord - so it's optional.

Re: [csv] CSVRecord implements Map

2014-01-14 Thread Benedikt Ritter
A wrapper of some kind like Adrian suggested sounds like the way to go here. Maybe we could have something like: Map map = CSVRecordUtils.toMap(record); Benedikt 2014/1/15 Gary Gregory > I have a complex immutable class with a constructor that takes many fields. > > I have a factory that build

Re: [csv] CSVRecord implements Map

2014-01-14 Thread Gary Gregory
I have a complex immutable class with a constructor that takes many fields. I have a factory that builds instances of this class. At runtime, some of the data to build the objects come from CSVRecord objects. At other times, like for tests, I want build sometimes I build the objects from CSVReco

Re: [csv] CSVRecord implements Map

2014-01-14 Thread Emmanuel Bourg
I'm not fond of the idea at the first glance. What is your use case? Emmanuel Le 14/01/2014 23:27, Gary Gregory a écrit : > Hi All: > > Any thoughts on making CSVRecord implement Map ? > > It would certainly help remove duplicate code in a use case of mine. > > Gary > -

Re: [csv] CSVRecord implements Map

2014-01-14 Thread Adrian Crum
That would only work if the CSV file had column names. Maybe make a class that implements Map and contains a CSVRecord - so it's optional. Adrian Crum Sandglass Software www.sandglass-software.com On 1/14/2014 5:27 PM, Gary Gregory wrote: Hi All: Any thoughts on making CSVRecord implement Map

[csv] CSVRecord implements Map

2014-01-14 Thread Gary Gregory
Hi All: Any thoughts on making CSVRecord implement Map ? It would certainly help remove duplicate code in a use case of mine. Gary -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition JUnit in Action, Second Edi