BF [2869877] - Initial Client Setup - Accounting schema - empty line

http://sourceforge.net/tracker/?func=detail&atid=879332&aid=2869877&group_id=176962
This commit is contained in:
trifonnt 2009-11-07 19:06:43 +00:00
parent 24ac862363
commit d85ab868e5
1 changed files with 17 additions and 5 deletions

View File

@ -100,9 +100,12 @@ public final class NaturalAccountMap<K,V> extends CCache<K,V>
String errMsg = ""; String errMsg = "";
// read lines // read lines
while ((line = in.readLine()) != null && errMsg.length() == 0) int lineNo= 1;
errMsg = parseLine(line); while ((line = in.readLine()) != null && errMsg.length() == 0) {
line = ""; errMsg = parseLine(line, lineNo);
lineNo++;
}
line = null;
in.close(); in.close();
// Error // Error
@ -137,13 +140,22 @@ public final class NaturalAccountMap<K,V> extends CCache<K,V>
* @throws Exception * @throws Exception
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String parseLine (String line) throws Exception public String parseLine (String line, int lineNo) throws Exception
{ {
log.config(line); log.config(lineNo+" : "+line);
if (line.trim().length()==0) {
log.log(Level.WARNING, "Line "+lineNo+" is empty, ignored. ");
return "";
}
// Fields with ',' are enclosed in " // Fields with ',' are enclosed in "
StringBuffer newLine = new StringBuffer(); StringBuffer newLine = new StringBuffer();
StringTokenizer st = new StringTokenizer(line, "\"", false); StringTokenizer st = new StringTokenizer(line, "\"", false);
if ((st==null )||(st.countTokens()==0)) {
log.log(Level.SEVERE, "Parse error: No \\\" found in line: "+lineNo);
return "";
}
newLine.append(st.nextToken()); // first part newLine.append(st.nextToken()); // first part
while (st.hasMoreElements()) while (st.hasMoreElements())
{ {