@Test public void testIllegalFormat() throws Exception { translator.setFormat("%zZX"); String floatVal = new String("123"); JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", floatVal, Types.FLOAT); try { translator.translate(row, 0); fail(); } catch (Exception ex) { } try { translator.translate(row, "testField"); fail(); } catch (Exception ex) { } }
@Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object doubleObject = rs.getFieldValue(column); if(doubleObject instanceof Float) return toString((Float) rs.getFieldValue(column)); else return toString(new Float(rs.getFieldValue(column).toString())); }
FloatColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object doubleObject = rs.getFieldValue(column); if(doubleObject instanceof Float) return toString((Float) rs.getFieldValue(column)); else return toString(new Float(rs.getFieldValue(column).toString())); } }
FloatColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object doubleObject = rs.getFieldValue(column); if(doubleObject instanceof Float) return toString((Float) rs.getFieldValue(column)); else return toString(new Float(rs.getFieldValue(column).toString())); } FloatColumnTranslator();  FloatColumnTranslator(String format); }
FloatColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object doubleObject = rs.getFieldValue(column); if(doubleObject instanceof Float) return toString((Float) rs.getFieldValue(column)); else return toString(new Float(rs.getFieldValue(column).toString())); } FloatColumnTranslator();  FloatColumnTranslator(String format); @Override String translate(JdbcResultRow rs, int column); @Override String translate(JdbcResultRow rs, String column); }
FloatColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object doubleObject = rs.getFieldValue(column); if(doubleObject instanceof Float) return toString((Float) rs.getFieldValue(column)); else return toString(new Float(rs.getFieldValue(column).toString())); } FloatColumnTranslator();  FloatColumnTranslator(String format); @Override String translate(JdbcResultRow rs, int column); @Override String translate(JdbcResultRow rs, String column);  }