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++;
}
}
|