Commits

tbrugz committed f7367c7

sqldump: generifying

Comments (0)

Files changed (11)

src/tbrugz/sqldump/SQLUtils.java

 
 	static boolean resultSetGetObjectExceptionWarned = false;
 	
-	public static List<Object> getRowObjectListFromRS(ResultSet rs, List<Class> colTypes, int numCol) throws SQLException {
+	public static List<Object> getRowObjectListFromRS(ResultSet rs, List<Class<?>> colTypes, int numCol) throws SQLException {
 		return getRowObjectListFromRS(rs, colTypes, numCol, false);
 	}
 	
-	public static List<Object> getRowObjectListFromRS(ResultSet rs, List<Class> colTypes, int numCol, boolean canReturnResultSet) throws SQLException {
+	public static List<Object> getRowObjectListFromRS(ResultSet rs, List<Class<?>> colTypes, int numCol, boolean canReturnResultSet) throws SQLException {
 		List<Object> ls = new ArrayList<Object>();
 		for(int i=1;i<=numCol;i++) {
 			Object value = null;

src/tbrugz/sqldump/datadump/BlobDataDump.java

 	String outFilePattern;
 	
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 	
 	@Override
 	public void procProperties(Properties prop) {
 		}
 		String rowid = Utils.join(pkVals, ROWID_JOINER);
 		for(int i=0;i<lsColNames.size();i++) {
-			Class c = lsColTypes.get(i);
+			Class<?> c = lsColTypes.get(i);
 			if(! c.equals(Blob.class)) { continue; }
 			
 			String filename = outFilePattern.replaceAll(DataDump.FILENAME_PATTERN_TABLENAME, tableName)

src/tbrugz/sqldump/datadump/CSVDataDump.java

 	String tableName;
 	int numCol;
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 	ResultSetMetaData md;
 	
 	boolean doTableNameHeaderDump = false;
 	@Override
 	public void dumpRow(ResultSet rs, long count, Writer fos) throws IOException, SQLException {
 		StringBuffer sb = new StringBuffer();
-		List vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol);
+		List<?> vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol);
 		for(int i=0;i<lsColTypes.size();i++) {
 			if(ResultSet.class.isAssignableFrom(lsColTypes.get(i))) {
 				

src/tbrugz/sqldump/datadump/DataDump.java

 	
 	static String getPartitionByStr(String partitionByStr, ResultSet rs, List<String> cols) throws SQLException {
 		//XXX: numberformatter (leading 0s) for partitionId?
+		//XXX: add dataformatter? useful for partitioning by year, year-month, ... 
 		for(String c: cols) {
 			String replacement = null;
 			try {

src/tbrugz/sqldump/datadump/DataDumpUtils.java

 	}
 	
 	//dumpers: CSV, FFC
-	public static String getFormattedCSVValue(Object elem, Class type, NumberFormat floatFormatter, String separator, String lineSeparator, String enclosing, String nullValue) {
+	public static String getFormattedCSVValue(Object elem, Class<?> type, NumberFormat floatFormatter, String separator, String lineSeparator, String enclosing, String nullValue) {
 		if(elem == null) {
 			return nullValue;
 		}
 	} 
 
 	//dumpers: JSON
-	public static String getFormattedJSONValue(Object elem, Class type, DateFormat df) {
+	public static String getFormattedJSONValue(Object elem, Class<?> type, DateFormat df) {
 		if(elem == null) {
 			return null;
 		}
 
 	//dumpers: XML, HTML
 	//XXX: XML format: translate '<', '>', '&'?
-	public static String getFormattedXMLValue(Object elem, Class type, NumberFormat floatFormatter, String nullValue) {
+	public static String getFormattedXMLValue(Object elem, Class<?> type, NumberFormat floatFormatter, String nullValue) {
 		if(elem == null) {
 			return nullValue;
 		}
 	static void logResultSetColumnsTypes(ResultSetMetaData md, String tableName) throws SQLException {
 		int numCol = md.getColumnCount();		
 		List<String> lsColNames = new ArrayList<String>();
-		List<Class> lsColTypes = new ArrayList<Class>();
+		List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 		for(int i=0;i<numCol;i++) {
 			lsColNames.add(md.getColumnName(i+1));
 		}

src/tbrugz/sqldump/datadump/DumpSyntax.java

 
 public abstract class DumpSyntax {
 	
-	static final Class[] arr = {
+	static final Class<?>[] arr = {
 		InsertIntoDataDump.class,
 		CSVDataDump.class,
 		XMLDataDump.class,
 	
 	public String nullValueStr = DEFAULT_NULL_VALUE;
 	
-	public static List<Class> getSyntaxes() {
-		return Arrays.asList(arr);
+	public static List<Class<? extends DumpSyntax>> getSyntaxes() {
+		return Arrays.asList((Class<? extends DumpSyntax>[])arr);
 	}
 	
 	public abstract void procProperties(Properties prop);

src/tbrugz/sqldump/datadump/FFCDataDump.java

 	
 	transient int numCol;
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 	boolean showColNames = true, showColNamesLines = true;
 	
 	@Override
 			dumpBuffer(fos);
 		}
 
-		List vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol);
+		List<Object> vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol);
 		List<String> valsStr = new ArrayList<String>();
 		for(int i=0;i<lsColNames.size();i++) {
 			int max = colsMaxLenght.get(i);
 		sb.append(separator);
 	}
 	
-	String getFormattedValue(Object o, Class c) {
+	String getFormattedValue(Object o, Class<?> c) {
 		//if(o==null) return nullValue;
 		return DataDumpUtils.getFormattedCSVValue(o, c, floatFormatter, null, recordDemimiter, null, nullValueStr);
 	}

src/tbrugz/sqldump/datadump/HTMLDataDump.java

 	String tableName;
 	int numCol;
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 
 	String padding = "";
 	
 	public void dumpRow(ResultSet rs, long count, Writer fos) throws IOException, SQLException {
 		StringBuffer sb = new StringBuffer();
 		sb.append("\t"+"<tr>");
-		List vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol, true);
+		List<Object> vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol, true);
 		for(int i=0;i<lsColNames.size();i++) {
 			if(ResultSet.class.isAssignableFrom(lsColTypes.get(i))) {
 				ResultSet rsInt = (ResultSet) vals.get(i);

src/tbrugz/sqldump/datadump/InsertIntoDataDump.java

 	int numCol;
 	String colNames;
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 	boolean doColumnNamesDump = true;
 	
 	@Override
 
 	@Override
 	public void dumpRow(ResultSet rs, long count, Writer fos) throws IOException, SQLException {
-		List vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol);
+		List<Object> vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol);
 		out("insert into "+tableName+" "+
 			colNames+" values ("+
 			DataDumpUtils.join4sql(vals, dateFormatter, ", ")+

src/tbrugz/sqldump/datadump/JSONDataDump.java

 	String tableName;
 	int numCol;
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 	
 	String padding = "";
 	
 		}
 		sb.append("{");
 		
-		List vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol, true);
+		List<Object> vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol, true);
 		for(int i=0;i<lsColNames.size();i++) {
 			if(ResultSet.class.isAssignableFrom(lsColTypes.get(i))) {
 				ResultSet rsInt = (ResultSet) vals.get(i);

src/tbrugz/sqldump/datadump/XMLDataDump.java

 	String tableName;
 	int numCol;
 	List<String> lsColNames = new ArrayList<String>();
-	List<Class> lsColTypes = new ArrayList<Class>();
+	List<Class<?>> lsColTypes = new ArrayList<Class<?>>();
 	
 	String padding = "";
 	
 		StringBuffer sb = new StringBuffer();
 		//XXX: option to define 'row' xml-element
 		sb.append("\t"+"<row>");
-		List vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol, true);
+		List<Object> vals = SQLUtils.getRowObjectListFromRS(rs, lsColTypes, numCol, true);
 		for(int i=0;i<lsColNames.size();i++) {
 			//XXX: prop for selecting ResultSet dumping or not?
 			if(ResultSet.class.isAssignableFrom(lsColTypes.get(i))) {