X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.utils%2Fsrc%2Forg%2Fsimantics%2Futils%2FUniqueID.java;h=f2f853197308c9ea64b782718f71fb749a2e4a36;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=938d5b106cc91e87c9059f45d6e42f17da9bbc68;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.utils/src/org/simantics/utils/UniqueID.java b/bundles/org.simantics.utils/src/org/simantics/utils/UniqueID.java index 938d5b106..f2f853197 100644 --- a/bundles/org.simantics.utils/src/org/simantics/utils/UniqueID.java +++ b/bundles/org.simantics.utils/src/org/simantics/utils/UniqueID.java @@ -1,44 +1,44 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.utils; - -import java.util.Random; - -/** - * UniqueID attempts to creates unique IDs. - * @author Toni Kalajainen - * @deprecated should be removed in my opinion [Tuukka], no real use. - */ -public class UniqueID { - - public static final String RESTORE_PREFIX = "restore-"; - - protected final static Random RANDOM = new Random(System.currentTimeMillis()); - protected static long COUNTER = RANDOM.nextLong(); - - public static String _createUniqueID() { - synchronized(UniqueID.class) { - Long value = COUNTER++; - Long random = RANDOM.nextLong(); - return Long.toHexString(value).toUpperCase() + - Long.toHexString(random); - } - } - - public static String createViewSiteSecondaryID(boolean restore) { - if (!restore) - return _createUniqueID(); - return RESTORE_PREFIX+_createUniqueID(); - } - - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.utils; + +import java.util.Random; + +/** + * UniqueID attempts to creates unique IDs. + * @author Toni Kalajainen + * @deprecated should be removed in my opinion [Tuukka], no real use. + */ +public class UniqueID { + + public static final String RESTORE_PREFIX = "restore-"; + + protected final static Random RANDOM = new Random(System.currentTimeMillis()); + protected static long COUNTER = RANDOM.nextLong(); + + public static String _createUniqueID() { + synchronized(UniqueID.class) { + Long value = COUNTER++; + Long random = RANDOM.nextLong(); + return Long.toHexString(value).toUpperCase() + + Long.toHexString(random); + } + } + + public static String createViewSiteSecondaryID(boolean restore) { + if (!restore) + return _createUniqueID(); + return RESTORE_PREFIX+_createUniqueID(); + } + + +}