diff options
author | david_williams | 2008-03-31 18:16:19 +0000 |
---|---|---|
committer | david_williams | 2008-03-31 18:16:19 +0000 |
commit | 07056e653117f1e722e1ca6af33f0f89a2cb2c1a (patch) | |
tree | 13d3a9fca037b9287c1e50b961f5422c5ae8468b /plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/utilities/IDUtil.java | |
parent | c52a5d005b0d92cfc2b959bfe56df939d7182f18 (diff) | |
download | webtools.common-200803311818.tar.gz webtools.common-200803311818.tar.xz webtools.common-200803311818.zip |
This commit was manufactured by cvs2svn to create tag 'v200803311818'.v200803311818
Diffstat (limited to 'plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/utilities/IDUtil.java')
-rw-r--r-- | plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/utilities/IDUtil.java | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/utilities/IDUtil.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/utilities/IDUtil.java deleted file mode 100644 index 388986cf5..000000000 --- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/utilities/IDUtil.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * 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: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.common.internal.emf.utilities; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.xmi.XMLResource; - -public class IDUtil { - - /** - * This method is invoked to assign a unique ID to the object. The object must be contained in a - * resource. - */ - public static void assignID(EObject object) { - Resource aResource = object.eResource(); - if (aResource instanceof XMLResource) - assignID(object, (XMLResource) aResource); - - } - - public static String getOrAssignID(EObject object) { - Resource aResource = object.eResource(); - if (aResource instanceof XMLResource) - return getOrAssignID(object, (XMLResource) aResource); - return null; - } - - public static String getOrAssignID(EObject object, XMLResource aResource) { - String id = aResource.getID(object); - if (id == null) - return assignID(object, aResource); - return id; - } - - public static String assignID(EObject object, XMLResource aResource) { - String name = getBaseIDForAssignment(object); - if (name == null) - return null; - String id = ensureUniqueID(aResource, name); - aResource.setID(object, id); - return id; - } - - protected static String ensureUniqueID(XMLResource aResource, String baseIDName) { - baseIDName += "_"; //$NON-NLS-1$ - //Change to use the current time instead of incremental numbers to help - //support team development. - long currentTime = System.currentTimeMillis(); - String id = baseIDName + currentTime; - while (aResource.getEObject(id) != null) { - ++currentTime; - id = baseIDName + currentTime; - } - return id; - } - - protected static String getBaseIDForAssignment(EObject object) { - EClass metaO = object.eClass(); - return metaO.getName(); - } - -} |