From: <mg...@us...> - 2008-02-15 19:24:46
|
Revision: 1517 http://obo.svn.sourceforge.net/obo/?rev=1517&view=rev Author: mgibson Date: 2008-02-15 11:24:45 -0800 (Fri, 15 Feb 2008) Log Message: ----------- fixed bug where if tabs deleted in a line delim would choke now just skips - todo - give better error message and read in partial line but at least now it will read rest of file and not collapse Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java 2008-02-15 00:21:38 UTC (rev 1516) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java 2008-02-15 19:24:45 UTC (rev 1517) @@ -64,11 +64,20 @@ private boolean isTerm() { return charField.isTerm(); } - void parseField(String items[],CharacterI chr) { + void parseField(String items[],CharacterI chr) throws DelimitedEx { + if (columnIndex >= items.length) + throw new DelimitedEx("No more fields in line to parse "+items+" "+chr); // if term, first id then name String value = items[columnIndex]; try { - String danglerName = charField.isTerm() ? items[columnIndex+1] : null; + String danglerName = null; + // if it is a term then grab next item for dangler name, but + if (charField.isTerm()) { + //look out for mangled data that lacks a term name (user mutzed) + if (columnIndex+1 >= items.length) + throw new DelimitedEx("No more fields in line to parse "+items+" "+chr); + danglerName = items[columnIndex+1]; + } CharFieldValue cfv = chr.setValue(charField,value,danglerName); // if term, and id not found, dangler -> set name of dangler //if (cfv.isDangler()) // throw error if not term? Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2008-02-15 00:21:38 UTC (rev 1516) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2008-02-15 19:24:45 UTC (rev 1517) @@ -173,6 +173,8 @@ String[] items = splitLine(line); if (items.length==0) throw new DelimitedEx(line); // BlankEx? for (DelimFieldParser p : fieldParsers) { + // throws DelEx if array not long enough for Parser (missing tabs) + // should ex be caught and go on? p.parseField(items,character); // add cfv to char or ret cfv? } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |