Revision 9634 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/driver/csvstring/CSVStringDriver.java
CSVStringDriver.java | ||
---|---|---|
1 | 1 |
package com.hardcode.gdbms.driver.csvstring; |
2 | 2 |
|
3 |
import java.awt.event.KeyEvent; |
|
3 | 4 |
import java.io.BufferedReader; |
4 | 5 |
import java.io.File; |
5 | 6 |
import java.io.FileNotFoundException; |
... | ... | |
34 | 35 |
private BufferedReader reader; |
35 | 36 |
private ArrayList lineas; |
36 | 37 |
private ValueWriter vWriter = ValueWriter.internalValueWriter; |
38 |
public static String DEFAULT_SEPARATOR=","; |
|
39 |
private String separator=DEFAULT_SEPARATOR; |
|
37 | 40 |
|
38 | 41 |
/** |
39 | 42 |
* @see com.hardcode.gdbms.driver.Driver#getName() |
... | ... | |
89 | 92 |
int colCount; |
90 | 93 |
String[] campos; |
91 | 94 |
if ((aux = reader.readLine()) != null) { |
92 |
campos = aux.split(";");
|
|
95 |
campos = aux.split(DEFAULT_SEPARATOR);
|
|
93 | 96 |
lineas.add(campos); |
94 | 97 |
colCount = campos.length; |
95 | 98 |
while ((aux = reader.readLine()) != null) { |
96 |
campos = aux.split(";");
|
|
99 |
campos = aux.split(DEFAULT_SEPARATOR);
|
|
97 | 100 |
if (campos.length < colCount) { |
98 | 101 |
for (int i=campos.length;i < colCount;i++){ |
99 | 102 |
aux = aux +" ;"; |
100 | 103 |
} |
101 |
campos = aux.split(";");
|
|
104 |
campos = aux.split(DEFAULT_SEPARATOR);
|
|
102 | 105 |
} |
103 | 106 |
lineas.add(campos); |
104 | 107 |
} |
... | ... | |
147 | 150 |
String fieldRow = dataWare.getFieldName(0); |
148 | 151 |
|
149 | 152 |
for (int i = 1; i < (dataWare.getFieldCount() - 1); i++) { |
150 |
fieldRow += (";" + dataWare.getFieldName(i));
|
|
153 |
fieldRow += (DEFAULT_SEPARATOR + dataWare.getFieldName(i));
|
|
151 | 154 |
} |
152 | 155 |
|
153 | 156 |
out.println(fieldRow); |
... | ... | |
156 | 159 |
String row = dataWare.getFieldValue(i, 0).getStringValue(this); |
157 | 160 |
|
158 | 161 |
for (int j = 1; j < (dataWare.getFieldCount() - 1); j++) { |
159 |
row += (";" +
|
|
162 |
row += (DEFAULT_SEPARATOR +
|
|
160 | 163 |
dataWare.getFieldValue(i, j).getStringValue(this)); |
161 | 164 |
} |
162 | 165 |
|
... | ... | |
179 | 182 |
|
180 | 183 |
String header = fieldNames[0]; |
181 | 184 |
for (int i = 1; i < fieldNames.length; i++) { |
182 |
header += ";" + fieldNames[i];
|
|
185 |
header += DEFAULT_SEPARATOR + fieldNames[i];
|
|
183 | 186 |
} |
184 | 187 |
out.println(header); |
185 | 188 |
|
... | ... | |
303 | 306 |
public int getFieldWidth(int i) throws DriverException { |
304 | 307 |
return 30; |
305 | 308 |
} |
309 |
|
|
310 |
public String getSeparator() { |
|
311 |
return separator; |
|
312 |
} |
|
313 |
|
|
314 |
public void setSeparator(String separator) { |
|
315 |
this.separator = separator; |
|
316 |
DEFAULT_SEPARATOR=separator; |
|
317 |
} |
|
306 | 318 |
} |
Also available in: Unified diff