KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > util > UniqueIDGenerator


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/util/UniqueIDGenerator.java,v 1.10 2004/08/18 12:26:09 hkollmann Exp $
3  * $Revision: 1.10 $
4  * $Date: 2004/08/18 12:26:09 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.util;
25
26
27 /**
28  * DOCUMENT ME!
29  *
30  * @version $Revision: 1.10 $
31  * @author $author$
32  */

33 public class UniqueIDGenerator {
34    private static int counter = 0;
35
36    /**
37     * may be optimized in future versions
38     * @return DOCUMENT ME!
39     */

40    public static synchronized String JavaDoc getUniqueID() {
41       long first = new java.util.Date JavaDoc().getTime();
42       int second = (int) (Math.random() * 100);
43       counter++;
44
45       return Long.toString(first) + Integer.toString(second)
46              + Integer.toString(counter);
47    }
48 }
49
Popular Tags