From 0591645b8586d37f2c17c9b52236818a3ac17fe8 Mon Sep 17 00:00:00 2001 From: Florian Hoelzl <hoelzl@fortiss.org> Date: Thu, 8 Sep 2011 11:05:16 +0000 Subject: [PATCH] added IdentifierUtils fixed deployment generation of toolcase ECU refs 137 --- .../tooling/kernel/utils/IdentifierUtils.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/IdentifierUtils.java diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/IdentifierUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/IdentifierUtils.java new file mode 100644 index 000000000..290e5fb58 --- /dev/null +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/utils/IdentifierUtils.java @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.utils; + +import org.fortiss.tooling.kernel.model.INamedElement; + +/** + * Utility class for unique identifiers. + * + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: + */ +public class IdentifierUtils { + + /** + * Returns the unique identifier built from the model element's name and ID. + * All non-word characters in the returned string are replace with '_'. + */ + public static String getUniqueIdentifier(INamedElement modelElement) { + return (modelElement.getName() + "_ID_" + modelElement.getId()) + .replaceAll("\\W", "_"); + } + + /** + * Returns the identifier built from the model element's name. All non-word + * characters in the returned string are replace with '_'. + */ + public static String getIdentifier(INamedElement modelElement) { + return modelElement.getName().replaceAll("\\W", "_"); + } +} -- GitLab