Permalink
Browse files

[studio] Fix bigdecimal issue

  • Loading branch information...
cchantep
cchantep committed Feb 13, 2014
1 parent 1da3e0d commit 654575844c3386a5471c01cf2c1710ab9a29d7e4
Showing with 22 additions and 7 deletions.
  1. +13 −5 studio/src/main/java/acolyte/RowFormatter.java
  2. +9 −2 studio/src/main/java/acolyte/Studio.java
@@ -1,5 +1,7 @@
package acolyte;
import java.math.BigDecimal;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Iterator;
@@ -242,8 +244,6 @@ static void appendValues(final ResultRow rs,
final ColumnType col = cols.next();
System.out.println("#col=" + col);
if (rs.isNull(colIndex)) {
appendNull(ap, fmt, col);
appendValues(rs, ap, charset, fmt, cols, colIndex+1);
@@ -256,7 +256,8 @@ static void appendValues(final ResultRow rs,
switch (col) {
case BigDecimal:
ap.append(String.format(fmt.someBigDecimal,
rs.getString(colIndex)));
rs.getBigDecimal(colIndex)));
break;
case Boolean:
@@ -329,8 +330,6 @@ protected static void appendRows(final Iterator<ResultRow> it,
final Formatting fmt,
final Iterable<ColumnType> cols) {
System.out.println("#cols=" + cols);
int i = 0;
while (it.hasNext()) {
if (i++ > 0) {
@@ -515,6 +514,7 @@ private static void execWith(final Appender ap,
public java.sql.Time getTime(int p);
public java.sql.Timestamp getTimestamp(int p);
public boolean isNull(int p);
public BigDecimal getBigDecimal(int p);
} // end of interface ResultRow
/**
@@ -618,6 +618,14 @@ public long getLong(int p) {
}
}
public BigDecimal getBigDecimal(int p) {
try {
return rs.getBigDecimal(p+1);
} catch (SQLException e) {
throw new RuntimeException("Fails to get value", e);
}
}
public boolean isNull(int p) {
try {
return rs.getObject(p+1) == null;
@@ -2,6 +2,7 @@
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.Enumeration;
import java.util.Properties;
import java.util.ArrayList;
@@ -524,8 +525,8 @@ public void actionPerformed(final ActionEvent e) {
final Number n = xlm.getNumber();
final Vector<ColumnType> cd = colData.elementAt(0);
final int len = cd.size();
final HashMap<String,ColumnType> map =
new HashMap<String,ColumnType>(len);
final LinkedHashMap<String,ColumnType> map =
new LinkedHashMap<String,ColumnType>(len);
for (int c = 0; c < len; c++) { // zip col data
map.put(colNames.elementAt(c), cd.elementAt(c));
@@ -1524,6 +1525,9 @@ public void actionPerformed(final ActionEvent evt) {
public Void doInBackground() throws Exception {
try {
f.call();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
try { end.call(); } catch (Exception e) { }
}
@@ -1959,6 +1963,9 @@ public boolean hasNext() {
public Timestamp getTimestamp(int p) {
return (Timestamp) v.elementAt(p);
}
public BigDecimal getBigDecimal(int p) {
return (BigDecimal) v.elementAt(p);
}
public boolean isNull(int p) { return v.elementAt(p) == null; }
} // end of class VectorRow
} // end of class Studio

0 comments on commit 6545758

Please sign in to comment.