You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Emmanuel Bourg <eb...@apache.org> on 2014/01/21 08:38:12 UTC
Re: svn commit: r1559905 - in /commons/proper/csv/trunk/src: main/java/org/apache/commons/csv/CSVRecord.java
test/java/org/apache/commons/csv/CSVRecordTest.java
Le 21/01/2014 03:12, ggregory@apache.org a écrit :
> /**
> + * Puts all values of this record into the given Map.
> + *
> + * @param map The Map to populate.
> + * @return the given map.
> + */
> + public Map<String, String> putIn(Map<String, String> map) {
> + for (Entry<String, Integer> entry : mapping.entrySet()) {
> + map.put(entry.getKey(), values[entry.getValue().intValue()]);
> + }
> + return map;
> + }
If you don't mind Gary I'd rather keep CSVRecord minimal and hide or
remove putIn().
> + /**
> + * Converts this record into a Map.
> + *
> + * @return A new Map. The map is empty if the record has no headers.
> + */
> + public Map<String, String> toMap() {
> + return putIn(new HashMap<String, String>(values.length));
> + }
I wonder if it would make sense to return a read only wrapper around the
record instead.
Emmanuel Bourg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org