Browse Source

Remove obsolete StorageToken class

René Beckmann 7 years ago
parent
commit
da91bc0126

+ 5 - 2
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/IStringShortener.java

@@ -23,9 +23,12 @@ import com.google.inject.ImplementedBy;
 @ImplementedBy(TreeStringShortener.class)
 public interface IStringShortener {
 	public void setMaxLength(int length);
-	public StorageToken addString(List<String> s);
 	
-	public String getString(StorageToken token);
+	/** Adds a string to the shortener. Can be retreived later in shortened form via getString using the token. */
+	public void addString(List<String> s, Object token);
+	
+	/** Retrieves a shortened String from the shortener, using the token that was specified on depositing the original String. */
+	public String getString(Object token);
 	
 	public void reset();
 }

+ 0 - 33
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/StorageToken.java

@@ -1,33 +0,0 @@
-/**
- * Copyright (c) 2018 committers of YAKINDU 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:
- * 	rbeckmann - initial API and implementation
- * 
- */
-package org.yakindu.sct.model.sexec.naming;
-
-/**
- * @author rbeckmann
- *
- * Objects that are created when a string is inserted into the StringShortener, so that whoever
- * put the (long) string into it can get the (short) string back later - like a wardrobe.
- */
-public class StorageToken {
-	protected static long tokenID = 0;
-	
-	protected long myID;
-	
-	public StorageToken() {
-		myID = tokenID;
-		tokenID += 1;
-	}
-	
-	@Override
-	public String toString() {
-		return "StorageToken[" + myID + "]";
-	}
-}

+ 6 - 13
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/tree/TreeNamingService.xtend

@@ -11,7 +11,6 @@
 
 package org.yakindu.sct.model.sexec.naming.tree
 
-import com.google.common.collect.Maps
 import java.util.ArrayList
 import java.util.List
 import java.util.Map
@@ -27,7 +26,6 @@ import org.yakindu.sct.model.sexec.extensions.SExecExtensions
 import org.yakindu.sct.model.sexec.naming.ElementNameProvider
 import org.yakindu.sct.model.sexec.naming.INamingService
 import org.yakindu.sct.model.sexec.naming.IStringShortener
-import org.yakindu.sct.model.sexec.naming.StorageToken
 import org.yakindu.sct.model.sexec.transformation.StatechartExtensions
 import org.yakindu.sct.model.sgraph.CompositeElement
 import org.yakindu.sct.model.sgraph.Region
@@ -64,8 +62,6 @@ class TreeNamingService implements INamingService {
 	 */
 	protected Map<NamedElement, String> map
 	
-	protected Map<NamedElement, StorageToken> tokens
-
 	// if the naming service is initialized with a flow, activeStatechart is null, and vice versa.
 	protected ExecutionFlow activeFlow;
 	protected Statechart activeStatechart;
@@ -82,7 +78,6 @@ class TreeNamingService implements INamingService {
 	
 	def protected void reset() {
 		map = newHashMap
-		tokens = newHashMap
 		activeFlow = null
 		activeStatechart = null
 		
@@ -176,10 +171,7 @@ class TreeNamingService implements INamingService {
 		segments.addAll(prefix);
 		segments.addAll(name);
 		segments.addAll(suffix);
-		if (!segments.isEmpty()) {
-			tokens.put(elem, shortener.addString(addSeparator(segments)))
-		}
-	// System.out.println(name);
+		shortener.addString(addSeparator(segments), elem)
 	}
 
 	def protected asIndexPosition(ExecutionScope it) {
@@ -217,13 +209,14 @@ class TreeNamingService implements INamingService {
 		if (map.containsKey(element)) {
 			return map.get(element);
 		}
-		// if not, check if element is located in the shortener
-		if (!tokens.containsKey(element)) {
+
+		var name = shortener.getString(element)
+		
+		if (name === null) {
 			addElement(element, new ArrayList<String>(), new ArrayList<String>());
+			name = shortener.getString(element)
 		}
 
-		val name = shortener.getString(tokens.get(element))
-
 		map.put(element, name);
 		return name;
 	}

+ 5 - 8
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/naming/tree/TreeStringShortener.xtend

@@ -15,7 +15,6 @@ import java.util.List
 import java.util.Map
 import org.eclipse.xtend.lib.annotations.Accessors
 import org.yakindu.sct.model.sexec.naming.IStringShortener
-import org.yakindu.sct.model.sexec.naming.StorageToken
 
 /**
  * @author rbeckmann
@@ -31,23 +30,21 @@ class TreeStringShortener implements IStringShortener {
 	
 	protected boolean validState = false
 	
-	protected Map<StorageToken, String> result
-	protected Map<StorageToken, StringTreeNode> storage
-	protected Map<StorageToken, List<String>> originalStrings = newHashMap
+	protected Map<Object, String> result
+	protected Map<Object, StringTreeNode> storage
+	protected Map<Object, List<String>> originalStrings = newHashMap
 	
 	override reset() {
 		originalStrings = newHashMap
 		validState = false
 	}
 
-	override addString(List<String> s) {
+	override addString(List<String> s, Object token) {
 		validState = false
-		val token = new StorageToken()
 		originalStrings.put(token, s)
-		return token
 	}
 	
-	override getString(StorageToken token) {
+	override getString(Object token) {
 		if(!originalStrings.containsKey(token)) {
 			return null
 		}