csvtosql-cvs Mailing List for csvtosql (Page 6)
Brought to you by:
davideconsonni
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(3) |
Apr
(106) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(73) |
Nov
(20) |
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:31
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/renders/exceptions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/renders/exceptions Added Files: InvalidParameterValueException.java MissingRequiredParameterException.java RendererException.java Log Message: no message --- NEW FILE: RendererException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.renders.exceptions; /** * is throwed when any exception occur during rendering. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class RendererException extends java.lang.Exception { public RendererException(String message, Throwable cause) { super(message, cause); } public RendererException(Throwable cause) { super(cause); } } --- NEW FILE: InvalidParameterValueException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.renders.exceptions; /** * throwed when a required renders' parameter has an invalid value. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class InvalidParameterValueException extends RendererException { private String parameterName; private String parameterValue; public InvalidParameterValueException(String parameterName, String parameterValue) { super("invalid parameter value.", null); this.parameterName = parameterName; this.parameterValue = parameterValue; } public String getParameterName() { return parameterName; } public String getParameterValue() { return parameterValue; } public String toString() { return "InvalidParameterValueException, "+ "parametername="+getParameterName()+ ", parametervalue="+getParameterValue(); } } --- NEW FILE: MissingRequiredParameterException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.renders.exceptions; /** * throwed when a required renders' parameter is missing. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class MissingRequiredParameterException extends Exception { private String parameterName; public MissingRequiredParameterException(String parameterName) { super("missing renderer's required parameter: " + parameterName); } public String getMissingParameter() { return parameterName; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:30
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/oracle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars/oracle Added Files: GrammarFactory.java OracleFieldDate.java OracleFieldNumber.java OracleFieldVarchar.java Log Message: no message --- NEW FILE: OracleFieldDate.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class OracleFieldDate extends AbstractField { public OracleFieldDate(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value)) ) { result = getDefaulNullValue(); } else { String inputFormat = this.getFieldProperties().getProperty("inputformat"); if (inputFormat == null) { inputFormat = "dd/MM/yy"; } String outputFormat = this.getFieldProperties().getProperty("outputformat"); if (outputFormat == null) { outputFormat = "dd/MM/yy"; } //check if Date is valid SimpleDateFormat df = new SimpleDateFormat(inputFormat); Date date = df.parse( (String)value ); //custom format df = new SimpleDateFormat(outputFormat); //format Date //result = df.format(date); result = "to_date('"+df.format(date)+"','"+outputFormat+"')"; } } catch (ParseException e) { throw new FieldRenderException(this, value, "not a date", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("inputformat","format of date in input."); hm.put("outputformat","format of date in output."); return hm; } } --- NEW FILE: OracleFieldVarchar.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class OracleFieldVarchar extends AbstractField { public static final String PRE = "\'"; public static final String POST = "\'"; public OracleFieldVarchar(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); //render return PRE + ((String)value).replaceAll("\"", "\\\\\"").replaceAll("'", "\\\\'") + POST; } catch (ClassCastException e) { throw new FieldRenderException(this, value, "not an string", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: OracleFieldNumber.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class OracleFieldNumber extends AbstractField { public OracleFieldNumber(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value).replaceAll(",", "."); float result = Float.parseFloat(strValue.trim()); //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: GrammarFactory.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.oracle; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.grammars.exceptions.GrammarFactoryException; /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class GrammarFactory extends AbstractGrammarFactory { public static final Hashtable<String, String> mapping = new Hashtable<String, String>(); static { //strings mapping.put("VARCHAR", "net.sf.csv2sql.grammars.oracle.OracleFieldVarchar"); mapping.put("VARCHAR2", "net.sf.csv2sql.grammars.oracle.OracleFieldVarchar"); mapping.put("NVARCHAR2", "net.sf.csv2sql.grammars.oracle.OracleFieldVarchar"); mapping.put("CHAR", "net.sf.csv2sql.grammars.oracle.OracleFieldVarchar"); mapping.put("NCHAR", "net.sf.csv2sql.grammars.oracle.OracleFieldVarchar"); //numbers mapping.put("NUMBER", "net.sf.csv2sql.grammars.oracle.OracleFieldNumber"); mapping.put("BINARY_INTEGER", "net.sf.csv2sql.grammars.oracle.OracleFieldNumber"); mapping.put("LONG", "net.sf.csv2sql.grammars.oracle.OracleFieldNumber"); //datetime mapping.put("DATE", "net.sf.csv2sql.grammars.oracle.OracleFieldDate"); } public AbstractField createField(String type, String name, Properties prop) throws GrammarFactoryException { AbstractField field = null; try { String className = (String)mapping.get(type.toUpperCase()); if (className==null || "".equals(className)) { throw new ClassNotFoundException("datatype not found in mapping"); } Constructor c = Class.forName(className). getConstructor(new Class[] { String.class, Properties.class }); Object o = c.newInstance(new Object[] {name, prop }); field = (AbstractField)o; } catch (ClassNotFoundException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getException()); } catch (NoSuchMethodException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InstantiationException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (IllegalAccessException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InvocationTargetException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } if (field==null) { throw new GrammarFactoryException("field type ["+type+"] doesn't exist. (field name: "+name+")", null); } else { return field; } } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:30
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/postgres In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars/postgres Added Files: GrammarFactory.java PostgresFieldCharacter.java PostgresFieldInteger.java Log Message: no message --- NEW FILE: PostgresFieldCharacter.java --- /* Copyright (C) 2004 Alessandro Grimaldi <agr...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.postgres; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class PostgresFieldCharacter extends AbstractField { public static final String PRE = "\'"; public static final String POST = "\'"; public PostgresFieldCharacter(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if (("null".equalsIgnoreCase((String)value)) || (value == null) ) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); //render return PRE + ((String)value).replaceAll("\"", "\\\\\"").replaceAll("'", "\\\\'") + POST; } catch (ClassCastException e) { throw new FieldRenderException(this, value, "not an string", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: GrammarFactory.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.postgres; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.grammars.exceptions.GrammarFactoryException; /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class GrammarFactory extends AbstractGrammarFactory { public static final Hashtable<String, String> mapping = new Hashtable<String, String>(); static { //strings mapping.put("CHARACTER", "net.sf.csv2sql.grammars.postgres.PostgresFieldCharacter"); mapping.put("INET", "net.sf.csv2sql.grammars.postgres.PostgresFieldCharacter"); mapping.put("TIMESTAMP", "net.sf.csv2sql.grammars.postgres.PostgresFieldCharacter"); //numbers mapping.put("INTEGER", "net.sf.csv2sql.grammars.postgres.PostgresFieldInteger"); //datetime } public AbstractField createField(String type, String name, Properties prop) throws GrammarFactoryException { AbstractField field = null; try { String className = (String)mapping.get(type.toUpperCase()); if (className==null || "".equals(className)) { throw new ClassNotFoundException("datatype not found in mapping"); } Constructor c = Class.forName(className). getConstructor(new Class[] { String.class, Properties.class }); Object o = c.newInstance(new Object[] {name, prop }); field = (AbstractField)o; } catch (ClassNotFoundException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getException()); } catch (NoSuchMethodException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InstantiationException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (IllegalAccessException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InvocationTargetException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } if (field==null) { throw new GrammarFactoryException("field type ["+type+"] doesn't exist. (field name: "+name+")", null); } else { return field; } } } --- NEW FILE: PostgresFieldInteger.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.postgres; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class PostgresFieldInteger extends AbstractField { public PostgresFieldInteger(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( ("null".equalsIgnoreCase((String)value)) || (value == null) || ("".equals((String)value))) { result = getDefaulNullValue(); } else { result = String.valueOf(new Double((String)value)).toString(); } } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:29
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/standard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars/standard Added Files: DateField.java FloatField.java GrammarFactory.java IntegerField.java StringField.java Log Message: no message --- NEW FILE: DateField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.standard; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class DateField extends AbstractField { public DateField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value)) ) { result = getDefaulNullValue(); } else { String inputFormat = this.getFieldProperties().getProperty("inputformat"); if (inputFormat == null) { inputFormat = "dd/MM/yy"; } String outputFormat = this.getFieldProperties().getProperty("outputformat"); if (outputFormat == null) { outputFormat = "dd/MM/yy"; } //check if Date is valid SimpleDateFormat df = new SimpleDateFormat(inputFormat); Date date = df.parse( (String)value ); //custom format df = new SimpleDateFormat(outputFormat); //format Date result = "\""+df.format(date)+"\""; } } catch (ParseException e) { throw new FieldRenderException(this, value, "not a date", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("inputformat","format of date in input."); hm.put("outputformat","format of date in output."); return hm; } } --- NEW FILE: IntegerField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.standard; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class IntegerField extends AbstractField { public IntegerField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value))) { result = getDefaulNullValue(); } else { result = String.valueOf(new Integer(Integer.parseInt((String)value)).intValue()); } } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: GrammarFactory.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.standard; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.grammars.exceptions.GrammarFactoryException; /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class GrammarFactory extends AbstractGrammarFactory { public static final Hashtable<String, String> mapping = new Hashtable<String, String>(); static { //strings mapping.put("VARCHAR", "net.sf.csv2sql.grammars.standard.StringField"); mapping.put("STRING", "net.sf.csv2sql.grammars.standard.StringField"); //numbers mapping.put("FLOAT", "net.sf.csv2sql.grammars.standard.FloatField"); mapping.put("INTEGER", "net.sf.csv2sql.grammars.standard.IntegerField"); //datetime mapping.put("DATE", "net.sf.csv2sql.grammars.standard.DateField"); } public AbstractField createField(String type, String name, Properties prop) throws GrammarFactoryException { AbstractField field = null; try { String className = (String)mapping.get(type.toUpperCase()); if (className==null || "".equals(className)) { throw new ClassNotFoundException("datatype not found in mapping"); } Constructor c = Class.forName(className). getConstructor(new Class[] { String.class, Properties.class }); Object o = c.newInstance(new Object[] {name, prop }); field = (AbstractField)o; } catch (ClassNotFoundException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getException()); } catch (NoSuchMethodException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InstantiationException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (IllegalAccessException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InvocationTargetException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } if (field==null) { throw new GrammarFactoryException("field type ["+type+"] doesn't exist. (field name: "+name+")", null); } else { return field; } } } --- NEW FILE: StringField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.standard; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class StringField extends AbstractField { public static final String PRE = "\'"; public static final String POST = "\'"; public StringField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ((value == null) || ("".equals(value))) { result = getDefaulNullValue(); } else { value = this.truncateValue(value); value = this.escapeValue(value); result = PRE + value + POST; } } catch (ClassCastException e) { throw new FieldRenderException(this, value, "not an string", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("truncatelength","truncate the string."); return hm; } protected Object truncateValue(Object value){ if(getFieldProperties().getProperty("truncatelength")!=null){ try{ int length = Integer.parseInt(getFieldProperties().getProperty("truncatelength")); if(((String)value).length()>length) value = ((String)value).substring(0,length); } catch (NumberFormatException nfe){ //if it's not a valid number, ignore it. } } return value; } protected Object escapeValue(Object value){ return ((String)value).replaceAll("\"", "\\\\\"").replaceAll("'", "\\\\'"); } } --- NEW FILE: FloatField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.standard; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class FloatField extends AbstractField { public FloatField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value)) ) { result = getDefaulNullValue(); } else { String strFloat = ((String)value).replaceAll(",", "."); result = String.valueOf(new Float(Float.parseFloat(strFloat))); } } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:29
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/idgenerators In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/idgenerators Added Files: IdGenerator.java Incremental.java Time.java Log Message: no message --- NEW FILE: IdGenerator.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.idgenerators; /** * The id's generator classes simply returns a unique number * that can be used as primary key. * <p> * <b>Extend this class</b> to define a new id generator, you must implement * the <code>getID()</code> method, with must return a unique id * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public interface IdGenerator { /** * return unique key */ public long getID(); } --- NEW FILE: Time.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.idgenerators; /** * create incremental positive id starting from zero based on system tickcount (time). * <p> * example: 1085607797580, 1085607797581, 1085607797582 * <p> * note: max value is <code>Long.MAX_VALUE</code> * @see IdGenerator * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class Time implements IdGenerator { long oldId; public long getID() { long currentId = System.currentTimeMillis(); while (oldId == currentId) { currentId = System.currentTimeMillis(); } oldId = currentId; return currentId; } } --- NEW FILE: Incremental.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.idgenerators; /** * create incremental positive id starting from zero. * <p> * example: 1, 2, 3 * <p> * note: max value is <code>Long.MAX_VALUE</code> * @see IdGenerator * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class Incremental implements IdGenerator { private long currentId = 0; /** * @see IdGenerator#getID */ public long getID() { return currentId++; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:27
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars/db2 Added Files: DB2DateField.java DB2FloatField.java DB2IntegerField.java DB2StringField.java GrammarFactory.java Log Message: no message --- NEW FILE: GrammarFactory.java --- /* Copyright (C) 2004 Dana Cordes <blo...@us...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.db2; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.grammars.exceptions.GrammarFactoryException; /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory * @author <a href="mailto:blo...@us...">Dana Cordes</a> */ public final class GrammarFactory extends AbstractGrammarFactory { public static final Hashtable<String, String> mapping = new Hashtable<String, String>(); static { //strings mapping.put("VARCHAR", "net.sf.csv2sql.grammars.db2.DB2StringField"); mapping.put("STRING", "net.sf.csv2sql.grammars.db2.DB2StringField"); //numbers mapping.put("FLOAT", "net.sf.csv2sql.grammars.db2.DB2FloatField"); mapping.put("INTEGER", "net.sf.csv2sql.grammars.db2.DB2IntegerField"); //datetime mapping.put("DATE", "net.sf.csv2sql.grammars.db2.DB2DateField"); } public AbstractField createField(String type, String name, Properties prop) throws GrammarFactoryException { AbstractField field = null; try { String className = (String)mapping.get(type.toUpperCase()); if (className==null || "".equals(className)) { throw new ClassNotFoundException("datatype not found in mapping"); } Constructor c = Class.forName(className). getConstructor(new Class[] { String.class, Properties.class }); Object o = c.newInstance(new Object[] {name, prop }); field = (AbstractField)o; } catch (ClassNotFoundException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getException()); } catch (NoSuchMethodException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InstantiationException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (IllegalAccessException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InvocationTargetException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } if (field==null) { throw new GrammarFactoryException("field type ["+type+"] doesn't exist. (field name: "+name+")", null); } else { return field; } } } --- NEW FILE: DB2FloatField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.db2; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class DB2FloatField extends AbstractField { public DB2FloatField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value)) ) { result = getDefaulNullValue(); } else { String strFloat = ((String)value).replaceAll(",", "."); result = String.valueOf(new Float(Float.parseFloat(strFloat))); } } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: DB2IntegerField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.db2; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class DB2IntegerField extends AbstractField { public DB2IntegerField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value))) { result = getDefaulNullValue(); } else { result = String.valueOf(new Integer(Integer.parseInt((String)value)).intValue()); } } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: DB2StringField.java --- /* Copyright (C) 2004 Dana Cordes <blo...@us...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.db2; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:blo...@us...">Dana Cordes</a> */ public final class DB2StringField extends AbstractField { public static final String PRE = "\'"; public static final String POST = "\'"; public DB2StringField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ((value == null) || ("".equals(value))) { result = getDefaulNullValue(); } else { value = this.truncateValue(value); value = this.escapeValue(value); result = PRE + value + POST; } } catch (ClassCastException e) { throw new FieldRenderException(this, value, "not an string", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("truncatelength","truncate the string."); return hm; } protected Object truncateValue(Object value){ if(getFieldProperties().getProperty("truncatelength")!=null){ try{ int length = Integer.parseInt(getFieldProperties().getProperty("truncatelength")); if(((String)value).length()>length) value = ((String)value).substring(0,length); } catch (NumberFormatException nfe){ //if it's not a valid number, ignore it. } } return value; } protected Object escapeValue(Object value){ return ((String)value).replaceAll("'", "''"); } } --- NEW FILE: DB2DateField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.db2; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class DB2DateField extends AbstractField { public DB2DateField(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value)) ) { result = getDefaulNullValue(); } else { String inputFormat = this.getFieldProperties().getProperty("inputformat"); if (inputFormat == null) { inputFormat = "dd/MM/yy"; } String outputFormat = this.getFieldProperties().getProperty("outputformat"); if (outputFormat == null) { outputFormat = "dd/MM/yy"; } //check if Date is valid SimpleDateFormat df = new SimpleDateFormat(inputFormat); Date date = df.parse( (String)value ); //custom format df = new SimpleDateFormat(outputFormat); //format Date result = "\""+df.format(date)+"\""; } } catch (ParseException e) { throw new FieldRenderException(this, value, "not a date", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("inputformat","format of date in input."); hm.put("outputformat","format of date in output."); return hm; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:27
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/mysql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars/mysql Added Files: GrammarFactory.java MysqlFieldBigint.java MysqlFieldBit.java MysqlFieldChar.java MysqlFieldDate.java MysqlFieldDouble.java MysqlFieldFloat.java MysqlFieldInt.java MysqlFieldMediumint.java MysqlFieldSmallint.java MysqlFieldTinyint.java Log Message: no message --- NEW FILE: MysqlFieldSmallint.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldSmallint extends AbstractField { public static final int MIN_VALUE = -32768; public static final int MAX_VALUE = 65535; public MysqlFieldSmallint(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); int result = Integer.parseInt(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "small int value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldTinyint.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldTinyint extends AbstractField { public static final int MIN_VALUE = -128; public static final int MAX_VALUE = 255; public MysqlFieldTinyint(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); int result = Integer.parseInt(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "tiny int value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldInt.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldInt extends AbstractField { public static final long MIN_VALUE = Long.parseLong("-2147483648"); public static final long MAX_VALUE = Long.parseLong("4294967295"); public MysqlFieldInt(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); long result = Long.parseLong(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "int value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldMediumint.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldMediumint extends AbstractField { public static final int MIN_VALUE = -8388608; public static final int MAX_VALUE = 16777215; public MysqlFieldMediumint(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); int result = Integer.parseInt(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "medium Int value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldDate.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldDate extends AbstractField { public MysqlFieldDate(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { String result = null; try { if ( (value == null) || ("".equals((String)value)) ) { result = getDefaulNullValue(); } else { String inputFormat = this.getFieldProperties().getProperty("inputformat"); if (inputFormat == null) { inputFormat = "dd/MM/yy"; } String outputFormat = this.getFieldProperties().getProperty("outputformat"); if (outputFormat == null) { outputFormat = "dd/MM/yy"; } //check if Date is valid SimpleDateFormat df = new SimpleDateFormat(inputFormat); Date date = df.parse( (String)value ); //custom format df = new SimpleDateFormat(outputFormat); //format Date result = "\'"+df.format(date)+"\'"; } } catch (ParseException e) { throw new FieldRenderException(this, value, "not a date", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } return result; } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("inputformat","format of date in input."); hm.put("outputformat","format of date in output."); return hm; } } --- NEW FILE: MysqlFieldBigint.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldBigint extends AbstractField { public static final float MIN_VALUE = Float.parseFloat("-9223372036854775808"); public static final float MAX_VALUE = Float.parseFloat("18446744073709551615"); public MysqlFieldBigint(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); float result = Float.parseFloat(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "big Int value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldDouble.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldDouble extends AbstractField { public static final float MIN_VALUE = Float.parseFloat("-1.7976931348623157E+308"); public static final float MAX_VALUE = Float.parseFloat("1.7976931348623157E+308"); public MysqlFieldDouble(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value).replaceAll(",", "."); float result = Float.parseFloat(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "float value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldBit.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldBit extends AbstractField { public static final byte MIN_VALUE = 0; public static final byte MAX_VALUE = 1; public MysqlFieldBit(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); byte result = Byte.parseByte(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "bit value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldFloat.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldFloat extends AbstractField { public static final float MIN_VALUE = Float.parseFloat("-3.402823466E+38"); public static final float MAX_VALUE = Float.parseFloat("3.402823466E+38"); public MysqlFieldFloat(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value).replaceAll(",", "."); long result = Long.parseLong(strValue.trim()); //check integrity if (result < MIN_VALUE || result > MAX_VALUE) { throw new FieldRenderException(this, value, "float value out of range ("+strValue+")", null); } //render return String.valueOf(strValue); } catch (NumberFormatException e) { throw new FieldRenderException(this, value, "not an number", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: MysqlFieldChar.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * @see AbstractField * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class MysqlFieldChar extends AbstractField { public static final String PRE = "\'"; public static final String POST = "\'"; public MysqlFieldChar(String fieldName, Properties properties) throws MissingRequiredParameterException { super(fieldName, properties); } /** * @see AbstractField#render */ protected String doRender(Object value) throws FieldRenderException { if ((value == null) || ("".equals(value))) {return getDefaulNullValue();} try { //get value String strValue = ((String)value); //render return PRE + ((String)value).replaceAll("\"", "\\\\\"").replaceAll("'", "\\\\'") + POST; } catch (ClassCastException e) { throw new FieldRenderException(this, value, "not an string", e); } catch (Exception e) { throw new FieldRenderException(this, value, "generic error", e); } } protected HashMap<String, String> requiredParameterList() { return null; } protected HashMap<String, String> optionalParameterList() { return null; } } --- NEW FILE: GrammarFactory.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.mysql; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import java.util.Properties; import net.sf.csv2sql.grammars.AbstractField; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.grammars.exceptions.GrammarFactoryException; /** * @see net.sf.csv2sql.grammars.AbstractGrammarFactory AbstractGrammarFactory * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class GrammarFactory extends AbstractGrammarFactory { public static final Hashtable<String, String> mapping = new Hashtable<String, String>(); static { //strings mapping.put("VARCHAR", "net.sf.csv2sql.grammars.mysql.MysqlFieldChar"); mapping.put("CHAR", "net.sf.csv2sql.grammars.mysql.MysqlFieldChar"); //numbers mapping.put("BIT", "net.sf.csv2sql.grammars.mysql.MysqlFieldBit"); mapping.put("TINYINT", "net.sf.csv2sql.grammars.mysql.MysqlFieldTinyint"); mapping.put("BOOL", "net.sf.csv2sql.grammars.mysql.MysqlFieldBit"); mapping.put("BOOLEAN", "net.sf.csv2sql.grammars.mysql.MysqlFieldBit"); mapping.put("SMALLINT", "net.sf.csv2sql.grammars.mysql.MysqlFieldSmallint"); mapping.put("MEDIUMINT", "net.sf.csv2sql.grammars.mysql.MysqlFieldMediumint"); mapping.put("INT", "net.sf.csv2sql.grammars.mysql.MysqlFieldInt"); mapping.put("INTEGER", "net.sf.csv2sql.grammars.mysql.MysqlFieldInt"); mapping.put("BIGINT", "net.sf.csv2sql.grammars.mysql.MysqlFieldBigint"); mapping.put("FLOAT", "net.sf.csv2sql.grammars.mysql.MysqlFieldFloat"); mapping.put("DOUBLE", "net.sf.csv2sql.grammars.mysql.MysqlFieldDouble"); mapping.put("REAL", "net.sf.csv2sql.grammars.mysql.MysqlFieldDouble"); mapping.put("DECIMAL", "net.sf.csv2sql.grammars.mysql.MysqlFieldDouble"); mapping.put("DEC", "net.sf.csv2sql.grammars.mysql.MysqlFieldDouble"); mapping.put("NUMERIC", "net.sf.csv2sql.grammars.mysql.MysqlFieldDouble"); mapping.put("FIXED", "net.sf.csv2sql.grammars.mysql.MysqlFieldDouble"); //datetime mapping.put("DATE", "net.sf.csv2sql.grammars.mysql.MysqlFieldDate"); } public AbstractField createField(String type, String name, Properties prop) throws GrammarFactoryException { AbstractField field = null; try { String className = (String)mapping.get(type.toUpperCase()); if (className==null || "".equals(className)) { throw new ClassNotFoundException("datatype not found in mapping"); } Constructor c = Class.forName(className). getConstructor(new Class[] { String.class, Properties.class }); Object o = c.newInstance(new Object[] {name, prop }); field = (AbstractField)o; } catch (ClassNotFoundException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getException()); } catch (NoSuchMethodException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InstantiationException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (IllegalAccessException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } catch (InvocationTargetException e) { throw new GrammarFactoryException("cannot create field. type: "+type+", name: "+name+")", e.getCause()); } if (field==null) { throw new GrammarFactoryException("field type ["+type+"] doesn't exist. (field name: "+name+")", null); } else { return field; } } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:27
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars Added Files: AbstractField.java AbstractGrammarFactory.java Log Message: no message --- NEW FILE: AbstractField.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars; import java.util.HashMap; import java.util.Properties; import net.sf.csv2sql.grammars.exceptions.FieldRenderException; import net.sf.csv2sql.grammars.exceptions.MissingRequiredParameterException; /** * The abstract field classes describe the type of the field * (like varchar, date, ...) in the table and contain information * like the name of the field and how to render rad data, * but doen't containt data itself. * <p> * Row data can be rendered with <code>render()</code> method. * <p> * <b>Extend this class</b> to define a new field, you must implement * the <code>doRender()</code> method, the argument of this method is raw data, * and the output is formatted data based on field type. * <p> * Implement methods * <code>requiredParameterList</code> and <code>optionalParameterList</code> * to return the list of required and the optional parameters * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public abstract class AbstractField { private String fieldName; private Properties fieldProperties = new Properties(); /** * render given value for insert. * <pre>example: * 01/10/2004 with oracle data field will be * to_date('01/10/2004', dd/MM/yyyy)<pre> * @throws FieldRenderException if value can be rendered to given datatype. */ public String render(Object value) throws FieldRenderException { String result = preFilter(value); result = doRender(result); result = postFilter(result); return result; } /** * automatically called BEFORE rendering. */ protected final String preFilter(Object value) throws FieldRenderException { String result = (String)value; //OPTION if ("true".equalsIgnoreCase(getFieldProperties().getProperty("tolowercase")) && result!=null) { result = result.toLowerCase(); } //OPTION if ("true".equalsIgnoreCase(getFieldProperties().getProperty("touppercase")) && result!=null) { result = result.toUpperCase(); } return result; } /** * rendering method. */ protected abstract String doRender(Object value) throws FieldRenderException; /** * automatically called AFTER rendering. */ protected final String postFilter(Object value) throws FieldRenderException { return (String)value; } /** * init fields' parameters * @see MissingRequiredParameterException MissingRequiredParameterException * @throws MissingRequiredParameterException if required parameter is missing */ public AbstractField(String fieldName, Properties properties) throws MissingRequiredParameterException { this.fieldName = fieldName; this.fieldProperties = properties; //check for required properties Object[] required = getRequiredParameterList().keySet().toArray(); for (int i=0; i< required.length; i++) { String parameter = (required[i]).toString(); String configParameter = properties.getProperty(parameter); if (configParameter==null) { throw new MissingRequiredParameterException(parameter); } } } public void setFieldName(String fieldName) { this.fieldName = fieldName; } public String getFieldName() { return this.fieldName; } public Properties getFieldProperties() { return this.fieldProperties; } public final String getDefaulNullValue() { //OPTION String notNullValue = getFieldProperties().getProperty("notnullvalue"); if (notNullValue!=null) { return notNullValue; } else { return "NULL"; } } public HashMap<String, String> getRequiredParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.putAll((commonRequiredParameterList()==null ? new HashMap<String, String>() : commonRequiredParameterList())); hm.putAll((requiredParameterList()==null ? new HashMap<String, String>() : requiredParameterList())); return hm; } public HashMap<String, String> getOptionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.putAll((commonOptionalParameterList()==null ? new HashMap<String, String>() : commonOptionalParameterList())); hm.putAll((optionalParameterList()==null ? new HashMap<String, String>() : optionalParameterList())); return hm; } private HashMap<String, String> commonRequiredParameterList() { return null; } private HashMap<String, String> commonOptionalParameterList() { HashMap<String, String> hm = new HashMap<String, String>(); hm.put("notnullvalue", "value to put when the culumn is 'not null'."); hm.put("tolowercase", "convert field to lower case."); hm.put("touppercase", "convert field to upper case."); return hm; } protected abstract HashMap<String, String> requiredParameterList(); protected abstract HashMap<String, String> optionalParameterList(); } --- NEW FILE: AbstractGrammarFactory.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars; import java.util.Properties; import net.sf.csv2sql.grammars.exceptions.GrammarFactoryException; /** * The grammars factory classes match field type read * from configuration file and return an <code>AbstractField</code> * based on database type. * <p> * <b>Extend this class</b> to define a new grammar factory, * you must implement the <code>createField()</code> * method, the arguments of this method are type * (like varchar, string, integer) and the name of the * field in the table. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public abstract class AbstractGrammarFactory { /** * factory method, create fields. */ public abstract AbstractField createField(String type, String name, Properties prop) throws GrammarFactoryException; } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:27
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/grammars/exceptions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/grammars/exceptions Added Files: FieldRenderException.java GrammarFactoryException.java MissingRequiredParameterException.java Log Message: no message --- NEW FILE: GrammarFactoryException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.exceptions; /** * Is throwed when the grammar factory can't create the selected field. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class GrammarFactoryException extends Exception { public GrammarFactoryException(String message, Throwable cause) { super(message, cause); } public GrammarFactoryException(Throwable cause) { super(cause); } } --- NEW FILE: FieldRenderException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.grammars.exceptions; import net.sf.csv2sql.grammars.AbstractField; /** * Is throwed when the fiel cannot render the value. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class FieldRenderException extends java.lang.Exception { private AbstractField field; private Object value; public FieldRenderException(AbstractField field, Object value, String message, Throwable cause) { super(message, cause); this.field = field; this.value = value; } public AbstractField getField() { return this.field; } public Object getValue() { return this.value; } } --- NEW FILE: MissingRequiredParameterException.java --- package net.sf.csv2sql.grammars.exceptions; /** * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class MissingRequiredParameterException extends Exception { private String parameterName; public MissingRequiredParameterException(String parameterName) { super("missing field's required parameter : " + parameterName); } public String getMissingParameter() { return parameterName; } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:26
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration/sections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/configuration/sections Added Files: TableStructure.java WriterList.java Log Message: no message --- NEW FILE: TableStructure.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.configuration.sections; import java.util.List; import java.util.ArrayList; import net.sf.csv2sql.grammars.AbstractField; /** * Utility class for rappresenting a real database table. * <p> * contain the name of the table passed in the constructor * (can be retrived with the <code>getTableName()</code> getter) and * the list of the field (identified by a list of <code>AbstractField</code> class). * <p> * field can be add by the <code>addField()</code> method. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public final class TableStructure { private String tableName; private List<AbstractField> fields = new ArrayList<AbstractField>(); public TableStructure(String tableName) throws IllegalArgumentException { if (tableName==null || "".equals(tableName)) { throw new IllegalArgumentException("no table name specified."); } this.tableName = tableName; } public void setTableName(String tableName) { this.tableName = tableName; } public String getTableName() { return this.tableName; } public List getFields() { return this.fields; } public void addField(AbstractField field) throws IllegalArgumentException { if (field==null) { throw new IllegalArgumentException("field can't be null."); } fields.add(field); } } --- NEW FILE: WriterList.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.configuration.sections; import java.util.List; import java.util.ArrayList; import java.util.Iterator; import net.sf.csv2sql.writers.AbstractWriter; /** * Utility class that use decorator to implement * an object with accept only <code>AbstractWriter</code> * and permits to iterate on added writer. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class WriterList { private List<AbstractWriter> writers = new ArrayList<AbstractWriter>(); public void addWriter(AbstractWriter writer) throws IllegalArgumentException { if (writer==null) { throw new IllegalArgumentException("writer can't be null."); } this.writers.add(writer); } public Iterator<AbstractWriter> iterator() { return writers.iterator(); } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:26
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/frontends/console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/frontends/console Added Files: ConsoleMain.java Log Message: no message --- NEW FILE: ConsoleMain.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.frontends.console; import java.io.File; import java.util.List; import java.util.Iterator; import net.sf.csv2sql.configuration.XmlConfigurator; import net.sf.csv2sql.writers.AbstractWriter; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.PosixParser; /** * csv2sql console frontends * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class ConsoleMain { private static ConsoleMain self = new ConsoleMain(); /** * singleton pattern * return THE istance of main * @return istance of ConsoleMain */ public static ConsoleMain getInstance() { return self; } private static String usage() { return " Usage: csv2sql -d filename [-b]\n\n"+ " --descriptor [-d] file containing conversion descriptor\n"+ " --benchmark [-b] misure conversion time in millis\n"+ " --version [-v] display version information\n"+ " --help [-h] display this help\n"; } private static String version() { return "csv2sql, Copyright (C) 2004 Davide Consonni <dco...@en...>\n"+ "Convert a csv file in sql file\n\n"; } /** * buisness logic * @param descriptor point to conversion descriptor file * @throws Exception if any error occured */ public void run(File descriptor) throws Exception { //read configuration XmlConfigurator config = new XmlConfigurator(); config.load(descriptor); if (config.CURRENT_DESCRIPTOR_VERSION != config.getDescriptorVersion()) { throw new Exception("version mismatch"); } //generate statements config.getRender().render(); //output statements Iterator it = config.getWriters().iterator(); while (it.hasNext()) { AbstractWriter writer = (AbstractWriter)it.next(); writer.write(); } } /** * program entry point * @param args argument list */ public static void main(String args []) { try { CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption( "d", "descriptor", true, "descriptor file"); options.addOption( "b", "benchmark", false, "misure conversion time in millis" ); options.addOption( "v", "version", false, "display csv2sql version" ); options.addOption( "h", "help", false, "display help" ); CommandLine line = parser.parse( options, args ); //no arguments ? no party. if (args.length <= 0) { System.out.println(version()); System.out.println(usage()); System.exit(1); } //display version version if( line.hasOption( "v" ) ) { System.out.println(version()); System.exit(0); } //display version if( line.hasOption( "h" ) ) { System.out.println(version()); System.out.println(usage()); System.exit(0); } //read descriptor filename File descriptor = null; if( line.hasOption( "d" ) ) { try { descriptor = new File(line.getOptionValue("d")); } catch (Exception e) { System.exit(1); } } else { System.out.println(version()); System.out.println(usage()); System.out.println("ERROR: option --descriptor is mandatory.\n"); System.exit(1); } //start benchmark long start = System.currentTimeMillis(); // RUN CONVERSION ConsoleMain.getInstance().run(descriptor); if (line.hasOption( "b" )) { //stop benchmark and print results System.out.println("\nCsv converted in: "+String.valueOf(System.currentTimeMillis()-start)+" ms"); } } catch( Exception e ) { e.printStackTrace(); } } } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:06
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src/net/sf/csv2sql/configuration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138/net/sf/csv2sql/configuration Added Files: Configurator.java ConfiguratorException.java ManualConfigurator.java XmlConfigurator.java Log Message: no message --- NEW FILE: XmlConfigurator.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.configuration; import java.io.File; import java.util.Properties; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import net.sf.csv2sql.configuration.sections.TableStructure; import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.writers.AbstractWriter; import net.sf.csv2sql.storage.Storage; /** * configure csvtosql from xmlfile * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class XmlConfigurator implements Configurator { private Document document; private WriterList writers; private AbstractRender renderer; private AbstractGrammarFactory abstractGrammarFactory; private TableStructure structure; private Storage storage; private File configurationFile; public String getConfigurationDirectory() { return configurationFile.getParent(); } public void load(File configurationFile) throws ConfiguratorException { this.configurationFile = configurationFile; try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.parse(configurationFile); this.document = doc; } catch (Exception e) { throw new ConfiguratorException(e.getMessage()); } } public TableStructure getTableStructure() throws ConfiguratorException { try { if (structure!=null) {return structure;} Node structureNode = document.getElementsByTagName("structure").item(0); structure = new TableStructure(structureNode.getAttributes().getNamedItem("tablename").getNodeValue()); AbstractGrammarFactory grammarFactory = this.getGrammar(); //read the fields NodeList list = structureNode.getChildNodes(); for (int i = 0; i<list.getLength(); i++) { if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { //read parameter of childs Properties p = new Properties(); NodeList parameters = list.item(i).getChildNodes(); for (int j = 0; j<parameters.getLength(); j++) { if (parameters.item(j).getNodeType() == Node.ELEMENT_NODE) { p.setProperty( parameters.item(j).getAttributes().getNamedItem("name").getNodeValue(), parameters.item(j).getAttributes().getNamedItem("value").getNodeValue() ); } } //add field structure.addField(grammarFactory.createField( list.item(i).getAttributes().getNamedItem("type").getNodeValue(), list.item(i).getAttributes().getNamedItem("name").getNodeValue(), p )); } } return structure; } catch (Exception e) { e.printStackTrace(); throw new ConfiguratorException(e.getMessage()); } } public int getDescriptorVersion() throws ConfiguratorException { try { Node descriptorNode = document.getElementsByTagName("descriptor").item(0); return new Integer(descriptorNode.getAttributes().getNamedItem("version").getNodeValue()).intValue(); } catch (Exception e) { throw new ConfiguratorException("descriptor version can't be found"); } } /** grammars */ private String getGrammarClassName() throws ConfiguratorException { try { return document.getElementsByTagName("grammar").item(0). getAttributes().getNamedItem("class").getNodeValue(); } catch (Exception e) { throw new ConfiguratorException(e.getMessage()); } } public AbstractGrammarFactory getGrammar() throws ConfiguratorException { try { if (abstractGrammarFactory!=null) {return abstractGrammarFactory;} //instantiating grammar abstractGrammarFactory = (AbstractGrammarFactory)Class.forName(getGrammarClassName()).newInstance(); return abstractGrammarFactory; } catch (Exception e) { throw new ConfiguratorException(e.getMessage()); } } /** renderers */ private String getRenderClassName() throws ConfiguratorException { try { return document.getElementsByTagName("render").item(0). getAttributes().getNamedItem("class").getNodeValue(); } catch (Exception e) { throw new ConfiguratorException(e.getMessage()); } } public AbstractRender getRender() throws ConfiguratorException { try { if (renderer!=null) {return renderer;} //instantiating the renderer renderer = (AbstractRender)Class.forName(getRenderClassName()).newInstance(); //setting render properties Properties renderProps = new Properties(); Node renderNode = document.getElementsByTagName("render").item(0); NodeList list = renderNode.getChildNodes(); for (int i = 0; i<list.getLength(); i++) { if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { renderProps.setProperty( list.item(i).getAttributes().getNamedItem("name").getNodeValue(), list.item(i).getAttributes().getNamedItem("value").getNodeValue() ); } } renderProps.setProperty("configdirectory", getConfigurationDirectory()+System.getProperty("file.separator")); renderer.configure(renderProps, this.getTableStructure(), getStorage()); return renderer; } catch (Exception e) { e.printStackTrace(); throw new ConfiguratorException(e.getMessage()); } } public WriterList getWriters() throws ConfiguratorException { try { if (writers!=null) {return writers;} writers = new WriterList(); NodeList writerAppenders = document.getElementsByTagName("writerAppender"); //all appenders for(int i=0; i<writerAppenders.getLength() ; i++){ Node writerAppenderNode = writerAppenders.item(i); if(writerAppenderNode.getNodeType() == Node.ELEMENT_NODE){ //the writer must be activated if ("true".equals(writerAppenderNode.getAttributes().getNamedItem("active").getNodeValue())) { String writerAppenderClassName = writerAppenderNode.getAttributes().getNamedItem("class").getNodeValue(); AbstractWriter writer = (AbstractWriter)Class.forName(writerAppenderClassName).newInstance(); //setting render properties Properties writerProps = new Properties(); NodeList list = writerAppenderNode.getChildNodes(); for (int j = 0; j<list.getLength(); j++) { if (list.item(j).getNodeType() == Node.ELEMENT_NODE) { writerProps.setProperty( list.item(j).getAttributes().getNamedItem("name").getNodeValue(), list.item(j).getAttributes().getNamedItem("value").getNodeValue() ); } } writer.configure(writerProps, getStorage()); //finally add it writers.addWriter(writer); } } } return writers; } catch (Exception e) {e.printStackTrace(); throw new ConfiguratorException(e.getMessage()); } } /** storage */ private String getStorageClassName() throws ConfiguratorException { try { return document.getElementsByTagName("storage").item(0). getAttributes().getNamedItem("class").getNodeValue(); } catch (Exception e) { throw new ConfiguratorException(e.getMessage()); } } public Storage getStorage() throws ConfiguratorException { try { if (storage!=null) {return storage;} //instantiating the renderer storage = (Storage)Class.forName(getStorageClassName()).newInstance(); //setting render properties Properties props = new Properties(); Node node = document.getElementsByTagName("storage").item(0); NodeList list = node.getChildNodes(); for (int i = 0; i<list.getLength(); i++) { if (list.item(i).getNodeType() == Node.ELEMENT_NODE) { props.setProperty( list.item(i).getAttributes().getNamedItem("name").getNodeValue(), list.item(i).getAttributes().getNamedItem("value").getNodeValue() ); } } props.setProperty("configdirectory", getConfigurationDirectory()+System.getProperty("file.separator")); storage.configure(props); return storage; } catch (Exception e) { e.printStackTrace(); throw new ConfiguratorException(e.getMessage()); } } } --- NEW FILE: ConfiguratorException.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.configuration; /** * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class ConfiguratorException extends Exception { public ConfiguratorException(String message) { super(message); } } --- NEW FILE: ManualConfigurator.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.configuration; import net.sf.csv2sql.configuration.sections.TableStructure; import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.storage.Storage; /** * configure csvtosql from code (very useful when you use it as library) * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public class ManualConfigurator implements Configurator { int descriptorVersion = -1 ; AbstractGrammarFactory grammarFactory; AbstractRender render; TableStructure tableStructure; WriterList writerList; Storage storage; public void setDescriptorVersion(int descriptorVersion) throws IllegalArgumentException { if (descriptorVersion != CURRENT_DESCRIPTOR_VERSION) { throw new IllegalArgumentException("invalid descriptor version. current version is "+CURRENT_DESCRIPTOR_VERSION); } this.descriptorVersion = descriptorVersion; } public int getDescriptorVersion() throws ConfiguratorException { if (this.descriptorVersion == -1) { throw new ConfiguratorException("descriptor version not set"); } return this.descriptorVersion; } public void setAbstractGrammarFactory(AbstractGrammarFactory grammarFactory) throws IllegalArgumentException { if (grammarFactory==null) { throw new IllegalArgumentException("null grammar factory"); } this.grammarFactory = grammarFactory; } public AbstractGrammarFactory getGrammar() throws ConfiguratorException { if (grammarFactory==null) { throw new ConfiguratorException("grammar factory not set"); } return this.grammarFactory; } public void setRender(AbstractRender render) throws IllegalArgumentException { if (render==null) { throw new IllegalArgumentException("null render"); } this.render = render; } public AbstractRender getRender() throws ConfiguratorException { if (render==null) { throw new ConfiguratorException("render not set"); } return this.render; } public void setTableStructure(TableStructure tableStructure) throws IllegalArgumentException { if (tableStructure==null) { throw new IllegalArgumentException("null tableStructure"); } this.tableStructure = tableStructure; } public TableStructure getTableStructure() throws ConfiguratorException { if (tableStructure==null) { throw new ConfiguratorException("table structure not set"); } return this.tableStructure; } public void setWriters(WriterList writerList) throws IllegalArgumentException { if (writerList==null) { throw new IllegalArgumentException("null writerList"); } this.writerList = writerList; } public WriterList getWriters() throws ConfiguratorException { if (writerList==null) { throw new ConfiguratorException("writerList not set"); } return this.writerList; } public void setStorage(Storage storage) throws IllegalArgumentException { if (storage==null) { throw new IllegalArgumentException("null storage"); } this.storage = storage; } public Storage getStorage() throws ConfiguratorException { if (storage==null) { throw new IllegalArgumentException("null storage"); } return this.storage = storage; } } --- NEW FILE: Configurator.java --- /* Copyright (C) 2004 Davide Consonni <dco...@en...> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sf.csv2sql.configuration; import net.sf.csv2sql.configuration.sections.TableStructure; import net.sf.csv2sql.configuration.sections.WriterList; import net.sf.csv2sql.grammars.AbstractGrammarFactory; import net.sf.csv2sql.renders.AbstractRender; import net.sf.csv2sql.storage.Storage; /** * define the standard for all configurators. * @author <a href="mailto:dco...@en...">Davide Consonni</a> */ public interface Configurator { public TableStructure getTableStructure() throws ConfiguratorException; public AbstractGrammarFactory getGrammar() throws ConfiguratorException; public AbstractRender getRender() throws ConfiguratorException; public WriterList getWriters() throws ConfiguratorException; public int getDescriptorVersion() throws ConfiguratorException; public Storage getStorage() throws ConfiguratorException; /* * v1 - startup * v2 - storage support * v3 - port to jdk5.0 */ public static final int CURRENT_DESCRIPTOR_VERSION = 3; } |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:53:06
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15138 Added Files: VERSION manifest.mf Log Message: no message --- NEW FILE: manifest.mf --- Manifest-Version: 1.0 Class-Path: ../lib/commons-cli-1.0.jar ../lib/jaxp.jar ../lib/AbsoluteLayout.jar ../lib/liquidlnf.jar ../lib/jxl.jar ../lib/metouia.jar ../lib/org.sadun.util.jar ../lib/javadbf-0.4.0.jar Created-By: NetBeans IDE Specified-By: bin/csv2sql.jarContent Main-Class: net.sf.csv2sql.frontends.gui.simple.ThinGui --- NEW FILE: VERSION --- 3.0.0 |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:52:05
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14830 Added Files: AbsoluteLayout.jar commons-cli-1.0.jar javadbf-0.4.0.jar jaxp.jar jxl.jar liquidlnf.jar metouia.jar Log Message: no message --- NEW FILE: commons-cli-1.0.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jaxp.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: liquidlnf.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: javadbf-0.4.0.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jxl.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: metouia.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: AbsoluteLayout.jar --- (This appears to be a binary file; contents omitted.) |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:51:20
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14729 Added Files: LICENSE.txt README.txt WHATSNEW.txt Log Message: no message --- NEW FILE: WHATSNEW.txt --- Changes from csvtosql 2.1.4 to csvtosql 2.2.0 ============================================= * Dana Cordes <blo...@us...> To the JdbcBatchWriter, I've added some additional debug reporting when exceptions are thrown. I've also added a clearBatch() statement after each batch is sent. I don't know if that's strictly required, but some documentation I was reading suggested that it was. I also added a closing executeBatch() to make sure that the last few queries are executed. * Dana Cordes <blo...@us...> I've modified the standard StringField grammer to make it more easily extensible. Basically, I moved the sting escaping logic out into it's own method, to be overridden by decending classes. And I've added a truncateValue method that will truncate the string if the field properties define a truncatelength. I added the later functionality because some of the CSV values that I was being given were longer than their associated DB fields and causing errors. * Dana Cordes <blo...@us...> I've also added a db2 grammer. Currently it decending entirely from the standard grammer, except I extend the StringField and override the escaping logic to provide escaping appropriate for db2. It's by absolutely no means a complete implementation of db2. It's just enough for what I needed at the time. Changes from csvtosql 2.1.3 to csvtosql 2.1.4 ============================================= * added presql and postsql options to SqlInsertRendererFromExcel * added acceptwrongrows optional parameters in SqlInsertRendererFromExcel * added acceptwrongrows optional parameters in SqlInsertRendererFromArray Changes from csvtosql 2.1.2 to csvtosql 2.1.3 ============================================= * added new example test.excel.skip * added "skipfields" support to SqlInsertRenderFromExcel Changes from csvtosql 2.1.1 to csvtosql 2.1.2 ============================================= * added startrow/stoprow support to SqlInsertRendererFromExcel render Changes from csvtosql 2.1.0 to csvtosql 2.1.1 ============================================= * bugfix on mysql date field * new splitter "Standard" * new splitter "Simple" * added splitters support Changes from csvtosql 2.0.2 to csvtosql 2.1.0 ============================================= * better exception handling on all exceptions * added temporary storage menu to ThinGui * sadun-util no longer used to load jdbc driver out of classpath, now using an utility class (Roberto Chiaretti) * XmlConfiguration optimization * storage exceptions * new storage "Disk" (tested with 236595 rows) * added sample test.stress.1 * added storage support (no more arraylists between renders and writers) * new storage "memory" (manage ~50000 rows) * upgraded descriptor to version 2 * updated samples Changes from csvtosql 2.0.1 to csvtosql 2.0.2 ============================================= * removed rowcount option from excel, last row is automatic now * does not feed emptylines anymore for csv and excel * converted all ArrayList to List Changes from csvtosql 2.0.0 to csvtosql 2.0.1 ============================================= * ThinGui: more detailed info on descriptor * added arguments check on TableStructure * added arguments check on WriterList * changed Configurator class to interface * better exception handling on AbstactField * new sample "test.dbf" * added new rendering filter "tolowercase" * added new rendering filter "touppercase" * added support rendering filters * bugfix optional parameters in ThreadedStandardOutputWriter * added SqlInsertRendererFromDBF * added check if number of values equals to number of fields * added new writer SqlMultipleFileWriter * better exception handling on writers * "removedoublequotes" only remove quotes when there are some. (Robert Huitema) * added "notnullvalue" support for all fields (Robert Huitema) Changes from csvtosql 1.8 to csvtosql 2.0.0 =========================================== * javadoc is uptodate * added new examples (and uptodate the olds) * added option "skiplines" to SqlInsertRenderer (Robert Huitema) * added option "presql" to SqlInsertRenderer (Robert Huitema) * added option "postsql" to SqlInsertRenderer (Robert Huitema) * more robust options required/optional management for fields * thread support for writers (with progress support !) * more robust options required/optional management for writers and renders - automatically check for required parameters - better exception handling for wrong or missing parameters * new configurator ManualConfigurator * new render SqlInsertRendererFromArray * new gui "thingui" * bugfix duoble comma in SqlFileWriter * bugfix in split function * added ignore empty lines * bugfix field mapping in net.sf.csv2sql.grammars.standard.GrammarFactory (Robert Huitema) Changes from csvtosql 1.7 to csvtosql 1.8 ========================================= * new examples * bugfix 1007865 * bugfix on mysql varchar field * print out line with errors Changes from csvtosql 1.6 to csvtosql 1.7 ========================================= * metouia lookandfeel * oracle date bugfix Changes from csvtosql 1.5 to csvtosql 1.6 ========================================= * better exception handling * new detailed grammar system Changes from csvtosql 1.4 to csvtosql 1.5 ========================================= * better exception handling * standard grammars date bugfix * mysql grammars date bugfix * can load jdbc driver at runtime Changes from csvtosql 1.3 to csvtosql 1.4 ========================================= * bugfix oracle grammar (Radovan Sninsky) * bugfix jdbcWriter (Radovan Sninsky) * added new writer JdbcBatchWriter (Radovan Sninsky) Changes from csvtosql 1.2 to csvtosql 1.3 ========================================= * added field parameters Changes from csvtosql 1.1 to csvtosql 1.2 ======================================= * excel file support * added ant build * added classes documentation (javadoc) Changes from csvtosql 1.0 to csvtosql 1.1 ========================================= * added Oracle grammar * added JdbcWriter * better Time id generator handling * configuration version handling Changes from csvtosql 1.0 to csvtosql 1.0 ========================================= * first release * added Mysql grammar * added generic grammar * added standard output writer * added file writer writer --- NEW FILE: LICENSE.txt --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. --- NEW FILE: README.txt --- What is it? ----------- csv2sql is highly configurable Java based conversion tool that convert csv based data into sql statements. The Latest Version ------------------ Details of the latest version can be found on the csv2sql Project web site <http://sourceforge.net/csv2sql/>. Getting Involved ---------------- You can contact me at Davide Consonni <dco...@en...>. Greetings --------- to netbeans (http://www.netbeans.org/) to jakarta for common-cli (http://jakarta.apache.org/) to sun (http://java.sun.com) to sourceforge (http://www.sourceforge.net) to Liquid Look and Feel (http://liquidlnf.sourceforge.net/) to java Excel api (http://www.andykhan.com/jexcelapi/) to sadun-util (http://sadun-util.sourceforge.net/) to Metouia Look and Feel (http://mlf.sourceforge.net/) Thanks To --------- Radovan Sninsky <sn...@po...> Cristiano Sadun <cri...@xt...> Robert Huitema <ro...@42...> Roberto Chiaretti <rob...@az...> Dana Cordes <blo...@us...> Licensing --------- This software is licensed under the terms you may find in the file named "LICENSE" in this directory. Thanks for using csv2sql. Davide Consonni <dco...@en...> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:51:06
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14661 Added Files: run.bat run.sh runGUI.bat runGUI.sh Log Message: no message --- NEW FILE: run.sh --- java -classpath csvtosql.jar net.sf.csv2sql.frontends.console.ConsoleMain $1 $2 $3 $4 $5 $6 $7 $8 --- NEW FILE: runGUI.sh --- java -jar csvtosql.jar --- NEW FILE: run.bat --- java -classpath csvtosql.jar net.sf.csv2sql.frontends.console.ConsoleMain %1 %2 %3 %4 %5 %6 %7 %8 --- NEW FILE: runGUI.bat --- javaw -jar csvtosql.jar |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:52
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.stress.1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.stress.1 Added Files: csvdata.txt descriptor.xml Log Message: no message --- NEW FILE: csvdata.txt --- John,Doe,120 jefferson st.,Riverside, NJ, 08075 Jack,McGinnis,220 hobo Av.,Phila, PA,09119 "John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075 Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234 ,Blankman,,SomeTown, SD, 00298 "Joan ""the bone"", Anne",Jet"9th at Terrace plc",Desert City,CO,00123 --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_dummy"> <field name="one" type="VARCHAR"/> <field name="two" type="VARCHAR"/> <field name="three" type="VARCHAR"/> <field name="four" type="VARCHAR"/> <field name="five" type="VARCHAR"/> <field name="six" type="VARCHAR"/> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="csvdata.txt"/> <param name="separator" value=","/> <!--optional--> <param name="trimdata" value="false"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="false"/> <!-- decomment for add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:51
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.simple.thread In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.simple.thread Added Files: descriptor.xml users.txt Log Message: no message --- NEW FILE: users.txt --- 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value [...2960 lines suppressed...] 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999, 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979,dummy value 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984, --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="ID" type="NUMBER"/> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"/> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> <field name="borndate" type="DATE"> <param name="inputformat" value="dd/MM/yy"/> <param name="outputformat" value="yyyy-MM-dd"/> </field> <field name="dummyField" type="VARCHAR"> <param name="notnullvalue" value="'10'"/> </field> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="users.txt"/> <param name="separator" value=","/> <!--optional--> <param name="trimdata" value="true"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="false"/> <!-- decomment for add id autogeneated field --> <param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.ThreadedStandardOutputWriter"> <param name="printprogress" value="true"/> <param name="stopatprogress" value="100"/> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:51
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.stress In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.stress Added Files: csvdata.txt descriptor.xml Log Message: no message --- NEW FILE: csvdata.txt --- Hello;World 123;456 LU;"86.25|""11/4/1998""|""2:19PM""|+4.0625" "bad ""input""";1.23E+03 XYZZY;"|""OReilly & Associates| Inc.""|""Darwin| Ian""|""a \""glug\"" bit|""|5|""Memory fault| core NOT dumped""" --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_dummy"> <field name="columnONE" type="VARCHAR"/> <field name="columnTWO" type="VARCHAR"/> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="csvdata.txt"/> <param name="separator" value=";"/> <!--optional--> <param name="trimdata" value="false"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="false"/> <!-- decomment for add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:50
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.simple.quoted In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.simple.quoted Added Files: descriptor.xml users.txt Log Message: no message --- NEW FILE: users.txt --- "1", "John","Doe","120 jefferson st.", "Riverside", "NJ", "08075", "23/8/1980" "0", "Jack","McGinnis","220 hobo Av.", "Phila", "PA","09119", "14/1/1984" "1", "John Da Man","Repici","120 Jefferson St.","Riverside", "NJ", "08075" , "19/10/1979" "0", "Stephen", "Tyler","7452 Terrace At the Plaza road","SomeTown","SD", "91234", "25/11/1999" --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="ID" type="NUMBER"/> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"/> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> <field name="borndate" type="DATE"> <param name="inputformat" value="dd/MM/yy"/> <param name="outputformat" value="yyyy-MM-dd"/> </field> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="users.txt"/> <param name="separator" value=","/> <!--optional--> <param name="trimdata" value="true"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="true"/> <!-- decomment for add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="false" class="net.sf.csv2sql.writers.SqlFileWriter"> <param name="filename" value="users.sql"/> </writerAppender> <writerAppender active="true" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:49
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.simple.multiplefile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.simple.multiplefile Added Files: descriptor.xml users.txt Log Message: no message --- NEW FILE: users.txt --- 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234 --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="ID" type="NUMBER"/> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"/> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="users.txt"/> <param name="separator" value=","/> <!--optional--> <!--<param name="trimdata" value="false"/>--> <!--<param name="suppressheader" value="false"/>--> <!--<param name="removedoublequotes" value="false"/>--> <!--<param name="skiplines" value="0"/>--> <!-- decomment for add id autogeneated field --> <param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.SqlMultipleFileWriter"> <param name="filename" value="multiple_test.sql"/> <param name="breaklines" value="20"/> </writerAppender> <writerAppender active="false" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:49
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.simple.loadjar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.simple.loadjar Added Files: descriptor.xml users.txt Log Message: no message --- NEW FILE: users.txt --- 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075, 23/8/1980 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119, 14/1/1984 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 , 19/10/1979 0, Stephen,Tyler,7452 Terrace At the Plaza road,SomeTown,SD, 91234, 25/11/1999 --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="ID" type="NUMBER"/> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"/> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> <field name="borndate" type="DATE"> <param name="inputformat" value="dd/MM/yy"/> <param name="outputformat" value="yyyy-MM-dd"/> </field> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="users.txt"/> <param name="separator" value=","/> <!--optional--> <param name="trimdata" value="true"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="false"/> <!-- decomment for add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <!-- change parameters and activate it --> <writerAppender active="false" class="net.sf.csv2sql.writers.JdbcWriter"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql://localhost/test"/> <param name="username" value="root"/> <!--optional--> <!--<param name="password" value="secret"/>--> <!--<param name="commit" value="false"/>--> <param name="jdbcjar" value="/root/myJdbcDriver.jar"/> </writerAppender> <!-- change parameters and activate it --> <writerAppender active="false" class="net.sf.csv2sql.writers.JdbcBatchWriter"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql://localhost/test"/> <param name="username" value="root"/> <param name="batchcount" value="10"/> <!--optional--> <!--<param name="password" value="secret"/>--> <!--<param name="commitbatchcount" value="0"/>--> <param name="jdbcjar" value="/root/myJdbcDriver.jar"/> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:49
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.simple Added Files: descriptor.xml users.txt Log Message: no message --- NEW FILE: users.txt --- 1, John,Doe,120 jefferson st.,Riverside, NJ, 08075 0, Jack,McGinnis,220 hobo Av.,Phila, PA,09119 1, John Da Man,Repici,120 Jefferson St.,Riverside, NJ, 08075 0, Stephen,Tyler,"7452, Terrace At the Plaza road",SomeTown,SD, 91234 --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="ID" type="NUMBER"/> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"/> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRenderer"> <param name="inputfile" value="users.txt"/> <param name="separator" value=","/> <!--optional--> <param name="splitter" value="net.sf.csv2sql.renders.splitters.Standard"/> <!-- Simple or Standard--> <!-- <param name="suppresstrailingsemicolon" value="true"/>--> <!-- <param name="acceptwrongrows" value="true"/>--> <param name="trimdata" value="true"/> <!-- <param name="suppressheader" value="true"/>--> <!-- <param name="removedoublequotes" value="true"/>--> <!-- <param name="skiplines" value="0"/>--> <!-- decomment for add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> </output> </root> |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:49
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.excel.skip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.excel.skip Added Files: descriptor.xml users.xls Log Message: no message --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"> <param name="notnullvalue" value="'mystring'"/> </field> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> <field name="borndate" type="Date"> <param name="inputformat" value="MM/dd/yyyy"/> <param name="outputformat" value="yyyy-MM-dd"/> </field> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRendererFromExcel"> <param name="inputfile" value="users.xls"/> <!--optional--> <param name="trimdata" value="true"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="false"/> <!--name of fields to skip separated by blank --> <param name="skipfields" value="name address"/> <!-- decomment to add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> <!--<param name="startrow" value="2"/>--> <!--<param name="stoprow" value="4"/>--> <!--<param name="presql" value="BEGIN TRANSACTION;"/>--> <!--<param name="postsql" value="COMMIT;"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.SqlFileWriter"> <param name="filename" value="users.sql"/> </writerAppender> <writerAppender active="true" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> <!-- change parameters and activate it --> <writerAppender active="false" class="net.sf.csv2sql.writers.JdbcWriter"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql://localhost/test"/> <param name="username" value="root"/> <!--optional--> <!--<param name="password" value="secret"/>--> <!--<param name="commit" value="false"/>--> <!--<param name="jdbcjar" value="/root/myJdbcDriver.jar"/>--> </writerAppender> <!-- change parameters and activate it --> <writerAppender active="false" class="net.sf.csv2sql.writers.JdbcBatchWriter"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql://localhost/test"/> <param name="username" value="root"/> <param name="batchcount" value="10"/> <!--optional--> <!--<param name="password" value="secret"/>--> <!--<param name="commitbatchcount" value="0"/>--> <!--<param name="jdbcjar" value="/root/myJdbcDriver.jar"/>--> </writerAppender> </output> </root> --- NEW FILE: users.xls --- (This appears to be a binary file; contents omitted.) |
|
From: consonni d. <dav...@us...> - 2005-04-25 10:50:48
|
Update of /cvsroot/csvtosql/csvtosql_jdk50/examples/test.excel In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14241/test.excel Added Files: descriptor.xml users.xls Log Message: no message --- NEW FILE: descriptor.xml --- <?xml version="1.0" encoding="UTF-8"?> <root> <!-- CONFIGURATOR DATA --> <descriptor version="3"/> <!-- DEFINE HERE TABLE STRUCTURE --> <structure tablename="tab_users"> <field name="name" type="VARCHAR"/> <field name="surname" type="VARCHAR"> <param name="notnullvalue" value="'mystring'"/> </field> <field name="address" type="VARCHAR"/> <field name="city" type="VARCHAR"/> <field name="state" type="VARCHAR"/> <field name="cap" type="VARCHAR"/> <field name="borndate" type="Date"> <param name="inputformat" value="MM/dd/yyyy"/> <param name="outputformat" value="yyyy-MM-dd"/> </field> </structure> <!-- WHAT GRAMMAR USE --> <grammar class="net.sf.csv2sql.grammars.oracle.GrammarFactory"/> <!-- TEMPORARY STORAGE --> <storage class="net.sf.csv2sql.storage.Memory"/> <!-- RENDERER CONFIGURATION --> <render class="net.sf.csv2sql.renders.SqlInsertRendererFromExcel"> <param name="inputfile" value="users.xls"/> <!--optional--> <param name="trimdata" value="true"/> <param name="suppressheader" value="false"/> <param name="removedoublequotes" value="false"/> <!-- decomment for add id autogeneated field --> <!--<param name="idGenerator" value="net.sf.csv2sql.idgenerators.Incremental"/>--> <!--<param name="startrow" value="2"/>--> <!--<param name="stoprow" value="4"/>--> <!--<param name="presql" value="BEGIN TRANSACTION;"/>--> <!--<param name="postsql" value="COMMIT;"/>--> </render> <!-- WRITER CONFIGURATION --> <output> <writerAppender active="true" class="net.sf.csv2sql.writers.SqlFileWriter"> <param name="filename" value="users.sql"/> </writerAppender> <writerAppender active="true" class="net.sf.csv2sql.writers.StandardOutputWriter"> </writerAppender> <!-- change parameters and activate it --> <writerAppender active="false" class="net.sf.csv2sql.writers.JdbcWriter"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql://localhost/test"/> <param name="username" value="root"/> <!--optional--> <!--<param name="password" value="secret"/>--> <!--<param name="commit" value="false"/>--> <!--<param name="jdbcjar" value="/root/myJdbcDriver.jar"/>--> </writerAppender> <!-- change parameters and activate it --> <writerAppender active="false" class="net.sf.csv2sql.writers.JdbcBatchWriter"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql://localhost/test"/> <param name="username" value="root"/> <param name="batchcount" value="10"/> <!--optional--> <!--<param name="password" value="secret"/>--> <!--<param name="commitbatchcount" value="0"/>--> <!--<param name="jdbcjar" value="/root/myJdbcDriver.jar"/>--> </writerAppender> </output> </root> --- NEW FILE: users.xls --- (This appears to be a binary file; contents omitted.) |