Author: jleroux
Date: Sun Oct 7 23:58:49 2007
New Revision: 582730
URL:
http://svn.apache.org/viewvc?rev=582730&view=revLog:
To allow to deal with last column empty in CSV files
To allow to render an empty string when null
Modified:
ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java
Modified: ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java?rev=582730&r1=582729&r2=582730&view=diff==============================================================================
--- ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java (original)
+++ ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java Sun Oct 7 23:58:49 2007
@@ -95,6 +95,17 @@
return object.toString();
}
+ public String getStringAndEmpty(String name) {
+ Object object = get(name);
+
+ if (object == null)
+ return "";
+ if (object instanceof java.lang.String)
+ return (String) object;
+ else
+ return object.toString();
+ }
+
public java.sql.Timestamp getTimestamp(String name) {
return (java.sql.Timestamp) get(name);
}
@@ -510,7 +521,13 @@
public static Record createDelimitedRecord(String line, int lineNum, ModelRecord modelRecord, char delimiter) throws DataFileException {
Record record = new Record(modelRecord);
- StringTokenizer st = new StringTokenizer(line, "" + delimiter, true);
+ StringTokenizer st = null;
+ if (line.endsWith(String.valueOf(delimiter))) {
+ st = new StringTokenizer(line + " ", "" + delimiter, true);
+ }
+ else {
+ st = new StringTokenizer(line, "" + delimiter, true);
+ }
for (int i = 0; i < modelRecord.fields.size(); i++) {
ModelField modelField = (ModelField) modelRecord.fields.get(i);
String strVal = null;