--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.utils;\r
+\r
+import java.util.Random;\r
+\r
+/**\r
+ * UniqueID attempts to creates unique IDs. \r
+ * @author Toni Kalajainen\r
+ * @deprecated should be removed in my opinion [Tuukka], no real use.\r
+ */\r
+public class UniqueID {\r
+ \r
+ public static final String RESTORE_PREFIX = "restore-";\r
+ \r
+ protected final static Random RANDOM = new Random(System.currentTimeMillis());\r
+ protected static long COUNTER = RANDOM.nextLong();\r
+ \r
+ public static String _createUniqueID() {\r
+ synchronized(UniqueID.class) {\r
+ Long value = COUNTER++;\r
+ Long random = RANDOM.nextLong();\r
+ return Long.toHexString(value).toUpperCase() + \r
+ Long.toHexString(random);\r
+ }\r
+ } \r
+\r
+ public static String createViewSiteSecondaryID(boolean restore) {\r
+ if (!restore)\r
+ return _createUniqueID();\r
+ return RESTORE_PREFIX+_createUniqueID();\r
+ }\r
+ \r
+ \r
+}\r