From: paspes <pa...@us...> - 2008-01-15 12:43:55
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2198/modules/scanner/src/com/babeldoc/scanner/worker Modified Files: SqlScanner.java Log Message: SQLScanner multidocument Index: SqlScanner.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/SqlScanner.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** SqlScanner.java 14 Jan 2008 23:40:34 -0000 1.20 --- SqlScanner.java 15 Jan 2008 12:43:58 -0000 1.21 *************** *** 152,176 **** if (columnCount > 0) { ! while (rs.next()) { ! for (int i = 1; i <= columnCount; i++) { ! sb.append(rs.getObject(i).toString()); ! ! if (i != columnCount) { ! sb.append(fieldSeparator); ! } else { ! sb.append(rowSeparator); } - } - if (multiDocument) { this.enqueue(sb.toString().getBytes(), ! new NameValuePair[] { new NameValuePair( ! SCAN_MIMETYPE_KEY, "text/plain") }); } } ! if (!multiDocument) { this.enqueue(sb.toString().getBytes(), ! new NameValuePair[] { new NameValuePair( ! SCAN_MIMETYPE_KEY, "text/plain") }); } } --- 152,184 ---- if (columnCount > 0) { ! if (multiDocument) { ! while (rs.next()) { ! for (int i = 1; i <= columnCount; i++) { ! sb.append(rs.getObject(i).toString()); ! ! if (i != columnCount) { ! sb.append(fieldSeparator); ! } } this.enqueue(sb.toString().getBytes(), ! new NameValuePair[] { new NameValuePair( ! SCAN_MIMETYPE_KEY, "text/plain") }); } } + else{ //Only one document + while (rs.next()) { + for (int i = 1; i <= columnCount; i++) { + sb.append(rs.getObject(i).toString()); ! if (i != columnCount) { ! sb.append(fieldSeparator); ! } else { ! sb.append(rowSeparator); ! } ! } ! } this.enqueue(sb.toString().getBytes(), ! new NameValuePair[] { new NameValuePair( ! SCAN_MIMETYPE_KEY, "text/plain") }); } } *************** *** 187,192 **** int columnCount = rs.getMetaData().getColumnCount(); ! StringBuffer sb = new StringBuffer( ! "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); int rowCount = 0; --- 195,199 ---- int columnCount = rs.getMetaData().getColumnCount(); ! StringBuffer sb = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); int rowCount = 0; *************** *** 212,226 **** sb.append("\t</" + rowTag + ">\n"); if (multiDocument) { enqueue(sb.toString().getBytes("UTF-8"), new NameValuePair[] { new NameValuePair( SCAN_MIMETYPE_KEY, "text/xml") }); } rowCount++; } - sb.append("</" + headingTag + ">\n"); - // only submit the document if we have any rows in the result set if (rowCount > 0 && !multiDocument) { enqueue(sb.toString().getBytes("UTF-8"), new NameValuePair[] { new NameValuePair( --- 219,236 ---- sb.append("\t</" + rowTag + ">\n"); if (multiDocument) { + sb.append("</" + headingTag + ">\n"); enqueue(sb.toString().getBytes("UTF-8"), new NameValuePair[] { new NameValuePair( SCAN_MIMETYPE_KEY, "text/xml") }); + //New document + sb = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + sb.append("<" + headingTag + ">\n"); } rowCount++; } // only submit the document if we have any rows in the result set if (rowCount > 0 && !multiDocument) { + sb.append("</" + headingTag + ">\n"); enqueue(sb.toString().getBytes("UTF-8"), new NameValuePair[] { new NameValuePair( |