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