@Test public void testConvertNoClass() throws Exception { StatementParameter sp = new StatementParameter(); try { sp.convertToQueryClass(STRING_VALUE); fail("Expected ServiceException"); } catch (ServiceException expected) { } }
protected Object convertToQueryClass(final Object value) throws ServiceException { if (value == null && convertNull()) { return ""; } else { if(value instanceof String) { String v = (String) value; try { Class<?> clazz = Class.forName(queryClass); Object obj = null; Constructor<?> construct = clazz.getConstructor(new Class[] { String.class }); obj = construct.newInstance(new Object[] { v }); return obj; } catch (Exception e) { throw new ServiceException("Failed to convert input String [" + v + "] to type [" + queryClass + "]", e); } } else return value; } }
StatementParameter extends StatementParameterImpl { protected Object convertToQueryClass(final Object value) throws ServiceException { if (value == null && convertNull()) { return ""; } else { if(value instanceof String) { String v = (String) value; try { Class<?> clazz = Class.forName(queryClass); Object obj = null; Constructor<?> construct = clazz.getConstructor(new Class[] { String.class }); obj = construct.newInstance(new Object[] { v }); return obj; } catch (Exception e) { throw new ServiceException("Failed to convert input String [" + v + "] to type [" + queryClass + "]", e); } } else return value; } } }
StatementParameter extends StatementParameterImpl { protected Object convertToQueryClass(final Object value) throws ServiceException { if (value == null && convertNull()) { return ""; } else { if(value instanceof String) { String v = (String) value; try { Class<?> clazz = Class.forName(queryClass); Object obj = null; Constructor<?> construct = clazz.getConstructor(new Class[] { String.class }); obj = construct.newInstance(new Object[] { v }); return obj; } catch (Exception e) { throw new ServiceException("Failed to convert input String [" + v + "] to type [" + queryClass + "]", e); } } else return value; } } StatementParameter();  StatementParameter(String query, Class<?> clazz, QueryType type);  StatementParameter(String query, String classname, QueryType type);  StatementParameter(String query, String classname, QueryType type, Boolean nullConvert);  StatementParameter(String query, String classname, QueryType type, Boolean nullConvert, String paramName);  StatementParameter(String query, Class<?> clazz, QueryType type, Boolean nullConvert); }
StatementParameter extends StatementParameterImpl { protected Object convertToQueryClass(final Object value) throws ServiceException { if (value == null && convertNull()) { return ""; } else { if(value instanceof String) { String v = (String) value; try { Class<?> clazz = Class.forName(queryClass); Object obj = null; Constructor<?> construct = clazz.getConstructor(new Class[] { String.class }); obj = construct.newInstance(new Object[] { v }); return obj; } catch (Exception e) { throw new ServiceException("Failed to convert input String [" + v + "] to type [" + queryClass + "]", e); } } else return value; } } StatementParameter();  StatementParameter(String query, Class<?> clazz, QueryType type);  StatementParameter(String query, String classname, QueryType type);  StatementParameter(String query, String classname, QueryType type, Boolean nullConvert);  StatementParameter(String query, String classname, QueryType type, Boolean nullConvert, String paramName);  StatementParameter(String query, Class<?> clazz, QueryType type, Boolean nullConvert); @Override void apply(int parameterIndex, PreparedStatement statement, AdaptrisMessage msg); void setQueryClass(String clazz); String getQueryClass(); StatementParameter makeCopy(); }
StatementParameter extends StatementParameterImpl { protected Object convertToQueryClass(final Object value) throws ServiceException { if (value == null && convertNull()) { return ""; } else { if(value instanceof String) { String v = (String) value; try { Class<?> clazz = Class.forName(queryClass); Object obj = null; Constructor<?> construct = clazz.getConstructor(new Class[] { String.class }); obj = construct.newInstance(new Object[] { v }); return obj; } catch (Exception e) { throw new ServiceException("Failed to convert input String [" + v + "] to type [" + queryClass + "]", e); } } else return value; } } StatementParameter();  StatementParameter(String query, Class<?> clazz, QueryType type);  StatementParameter(String query, String classname, QueryType type);  StatementParameter(String query, String classname, QueryType type, Boolean nullConvert);  StatementParameter(String query, String classname, QueryType type, Boolean nullConvert, String paramName);  StatementParameter(String query, Class<?> clazz, QueryType type, Boolean nullConvert); @Override void apply(int parameterIndex, PreparedStatement statement, AdaptrisMessage msg); void setQueryClass(String clazz); String getQueryClass(); StatementParameter makeCopy();  }