Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Tiede2015-04-02 11:45:32 +0000
committerMarkus Tiede2015-04-02 11:45:32 +0000
commite522f209d7391ac8c13d540d1eef0540117e77aa (patch)
tree6cbf42d2bb2d59632c16f879d1101814a989e3e5 /org.eclipse.jubula.client.api
parentbe91fdbdfdbf6ed7b2d2e51baedd0bb322a1329c (diff)
downloadorg.eclipse.jubula.core-e522f209d7391ac8c13d540d1eef0540117e77aa.tar.gz
org.eclipse.jubula.core-e522f209d7391ac8c13d540d1eef0540117e77aa.tar.xz
org.eclipse.jubula.core-e522f209d7391ac8c13d540d1eef0540117e77aa.zip
Sprint task - add MakeR method to create component identifier for a given object mapping key
Diffstat (limited to 'org.eclipse.jubula.client.api')
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/MakeR.java19
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ObjectMappingImpl.java34
-rw-r--r--org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/utils/SerilizationUtils.java3
3 files changed, 39 insertions, 17 deletions
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/MakeR.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/MakeR.java
index 4a94edfab..da7c290ec 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/MakeR.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/MakeR.java
@@ -12,8 +12,12 @@ package org.eclipse.jubula.client;
import java.io.InputStream;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jubula.client.exceptions.LoadResourceException;
import org.eclipse.jubula.client.internal.impl.AUTAgentImpl;
import org.eclipse.jubula.client.internal.impl.ObjectMappingImpl;
+import org.eclipse.jubula.tools.ComponentIdentifier;
/**
* @author BREDEX GmbH
@@ -48,4 +52,19 @@ public final class MakeR {
public static ObjectMapping createObjectMapping(InputStream input) {
return new ObjectMappingImpl(input);
}
+
+ /**
+ * @param <T>
+ * the type of component identifier
+ * @param componentIdentifier
+ * the component identifier string
+ * @return a component identifier instance or <code>null</code>.
+ * @throws LoadResourceException
+ * in case of identifier creation problems
+ */
+ @Nullable
+ public static <T> ComponentIdentifier<T> createCI(
+ @NonNull String componentIdentifier) throws LoadResourceException {
+ return ObjectMappingImpl.getIdentifier(componentIdentifier);
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ObjectMappingImpl.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ObjectMappingImpl.java
index c88f86733..515e46ecc 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ObjectMappingImpl.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/impl/ObjectMappingImpl.java
@@ -61,7 +61,9 @@ public class ObjectMappingImpl implements ObjectMapping {
+ compName);
} else {
try {
- m_map.put(compName, getIdentifier(compName));
+ String encodedString = m_objectMappingAssociations
+ .getProperty(compName);
+ m_map.put(compName, getIdentifier(encodedString));
} catch (LoadResourceException e) {
log.error(e.getLocalizedMessage(), e);
}
@@ -79,33 +81,35 @@ public class ObjectMappingImpl implements ObjectMapping {
return m_map.get(compName);
}
-
+
/**
- * Returns the component identifier for a component name
+ * Returns a component identifier instance for the given encoded component
+ * identifier
*
- * @param compName
- * the component name
- * @return the component identifier or <code>null</code> if no identifier
- * was found
- * @throws LoadResourceException
+ * @param encodedString
+ * the encoded component identifier string
+ * @param <T>
+ * the type of the component
+ * @return the component identifier or <code>null</code>
+ * @throws LoadResourceException
*/
- private ComponentIdentifier getIdentifier(String compName)
- throws LoadResourceException {
+ public static <T> ComponentIdentifier<T> getIdentifier(String encodedString)
+ throws LoadResourceException {
try {
- String encodedString =
- m_objectMappingAssociations.getProperty(compName);
if (encodedString != null) {
Object decodedObject = SerilizationUtils.decode(encodedString);
if (decodedObject instanceof ComponentIdentifier) {
- return (ComponentIdentifier) decodedObject;
+ return (ComponentIdentifier<T>) decodedObject;
}
throw new LoadResourceException("The decoded object is " //$NON-NLS-1$
+ "not of type 'IComponentIdentfier'."); //$NON-NLS-1$
}
} catch (IOException e) {
- throw new LoadResourceException("Could load the given component name", e); //$NON-NLS-1$
+ throw new LoadResourceException(
+ "Could load the given component name", e); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
- throw new LoadResourceException("Problems during deserialization...", e); //$NON-NLS-1$
+ throw new LoadResourceException(
+ "Problems during deserialization...", e); //$NON-NLS-1$
}
return null;
}
diff --git a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/utils/SerilizationUtils.java b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/utils/SerilizationUtils.java
index 6b80165bc..24c81a4ea 100644
--- a/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/utils/SerilizationUtils.java
+++ b/org.eclipse.jubula.client.api/src/org/eclipse/jubula/client/internal/utils/SerilizationUtils.java
@@ -62,5 +62,4 @@ public class SerilizationUtils {
ois.close();
return decodedObject;
}
-
-}
+} \ No newline at end of file

Back to the top