You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2007/10/08 08:58:51 UTC
svn commit: r582730 -
/ofbiz/trunk/framework/datafile/src/org/ofbiz/datafile/Record.java
Author: jleroux
Date: Sun Oct 7 23:58:49 2007
New Revision: 582730
URL: http://svn.apache.org/viewvc?rev=582730&view=rev
Log:
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;