public static Map defaultParams(DataAccessFactory factory) { Map defaults = new HashMap(); Param[] params = factory.getParametersInfo(); for (int i = 0; i < params.length; i++) { Param param = params[i]; String key = param.key; String value = null; // if (param.required ) { if (param.sample != null) { // Required params may have nice sample values // value = param.text(param.sample); } if (value == null) { // or not value = ""; } // } if (value != null) { defaults.put(key, value); } } return defaults; }
/** * Overide text to unwap the array of strings back into a space * limited text string. * TODO: (JD) perhaps this should be done by param? I guess we would have to * agree on the delimiter for collection or array based parameters. */ public String text(Object value) { if ( value instanceof String[] ) { String[] values = (String[]) value; StringBuffer sb = new StringBuffer(); for ( int i = 0; i < values.length; i++ ) { sb.append( values[i] + " " ); } sb.setLength( sb.length() - 1); return sb.toString(); } return super.text( value ); } };