Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Fix #41
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 17, 2014
1 parent 5190aaf commit 327fa1c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/main/java/com/fasterxml/jackson/dataformat/csv/CsvParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ public void setSchema(FormatSchema schema)
}

@Override
public int releaseBuffered(Writer out) throws IOException
{
public int releaseBuffered(Writer out) throws IOException {
return _reader.releaseBuffered(out);
}

Expand Down Expand Up @@ -397,14 +396,12 @@ public Object getInputSource() {
*/

@Override
public String getCurrentName() throws IOException, JsonParseException
{
public String getCurrentName() throws IOException, JsonParseException {
return _currentName;
}

@Override
public void overrideCurrentName(String name)
{
public void overrideCurrentName(String name) {
_currentName = name;
}

Expand Down Expand Up @@ -613,21 +610,33 @@ protected void _readHeaderLine() throws IOException, JsonParseException
// For now we do not store char[] representation...
@Override
public boolean hasTextCharacters() {
if (_currToken == JsonToken.FIELD_NAME) {
return false;
}
return _textBuffer.hasTextAsCharacters();
}

@Override
public String getText() throws IOException, JsonParseException {
if (_currToken == JsonToken.FIELD_NAME) {
return _currentName;
}
return _currentValue;
}

@Override
public char[] getTextCharacters() throws IOException, JsonParseException {
if (_currToken == JsonToken.FIELD_NAME) {
return _currentName.toCharArray();
}
return _textBuffer.contentsAsArray();
}

@Override
public int getTextLength() throws IOException, JsonParseException {
if (_currToken == JsonToken.FIELD_NAME) {
return _currentName.length();
}
return _textBuffer.size();
}

Expand Down
21 changes: 21 additions & 0 deletions src/test/java/com/fasterxml/jackson/dataformat/csv/TestParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,25 @@ public void testStringNullHandlingForInteger() throws Exception
assertNull(result.y);
assertNull(result.z);
}

// [Issue#41]
public void testIncorrectDups41() throws Exception
{
final String INPUT = "\"foo\",\"bar\",\"foo\"";
CsvSchema schema = CsvSchema.builder().addColumn("Col1").addColumn("Col2")
.addColumn("Col3").build();

MappingIterator<Object> iter = new CsvMapper().reader(Object.class)
.with(schema).readValues(INPUT);

Map<?,?> m = (Map<?,?>) iter.next();
assertFalse(iter.hasNextValue());

if (m.size() != 3) {
fail("Should have 3 entries, but got: "+m);
}
assertEquals("foo", m.get("Col1"));
assertEquals("bar", m.get("Col2"));
assertEquals("foo", m.get("Col3"));
}
}

0 comments on commit 327fa1c

Please sign in to comment.