@Test public void testFormattedString() throws Exception { translator.setFormat("%05d"); String stringVal = new String("123"); JdbcResultRow row = new JdbcResultRow(); row.setFieldValue("testField", stringVal, Types.INTEGER); { String translated = translator.translate(row, 0); assertEquals(expected, translated); } { String translated = translator.translate(row, "testField"); assertEquals(expected, translated); } }
@Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object integerObject = rs.getFieldValue(column); if(integerObject instanceof Integer) return toString((Integer) rs.getFieldValue(column)); else return toString(new Integer(rs.getFieldValue(column).toString())); }
IntegerColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object integerObject = rs.getFieldValue(column); if(integerObject instanceof Integer) return toString((Integer) rs.getFieldValue(column)); else return toString(new Integer(rs.getFieldValue(column).toString())); } }
IntegerColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object integerObject = rs.getFieldValue(column); if(integerObject instanceof Integer) return toString((Integer) rs.getFieldValue(column)); else return toString(new Integer(rs.getFieldValue(column).toString())); } IntegerColumnTranslator(); }
IntegerColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object integerObject = rs.getFieldValue(column); if(integerObject instanceof Integer) return toString((Integer) rs.getFieldValue(column)); else return toString(new Integer(rs.getFieldValue(column).toString())); } IntegerColumnTranslator(); @Override String translate(JdbcResultRow rs, int column); @Override String translate(JdbcResultRow rs, String column); }
IntegerColumnTranslator extends FormattableColumnTranslator { @Override public String translate(JdbcResultRow rs, int column) throws SQLException, IOException { Object integerObject = rs.getFieldValue(column); if(integerObject instanceof Integer) return toString((Integer) rs.getFieldValue(column)); else return toString(new Integer(rs.getFieldValue(column).toString())); } IntegerColumnTranslator(); @Override String translate(JdbcResultRow rs, int column); @Override String translate(JdbcResultRow rs, String column);  }