1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.utils;
\r
14 import java.util.Random;
\r
17 * UniqueID attempts to creates unique IDs.
\r
18 * @author Toni Kalajainen
\r
19 * @deprecated should be removed in my opinion [Tuukka], no real use.
\r
21 public class UniqueID {
\r
23 public static final String RESTORE_PREFIX = "restore-";
\r
25 protected final static Random RANDOM = new Random(System.currentTimeMillis());
\r
26 protected static long COUNTER = RANDOM.nextLong();
\r
28 public static String _createUniqueID() {
\r
29 synchronized(UniqueID.class) {
\r
30 Long value = COUNTER++;
\r
31 Long random = RANDOM.nextLong();
\r
32 return Long.toHexString(value).toUpperCase() +
\r
33 Long.toHexString(random);
\r
37 public static String createViewSiteSecondaryID(boolean restore) {
\r
39 return _createUniqueID();
\r
40 return RESTORE_PREFIX+_createUniqueID();
\r