Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2014-11-27 13:56:04 +0000
committerSebastian Struckmann2014-11-27 13:56:18 +0000
commitf1053776f525c7e03e43b9ae80f3de822b46ef8f (patch)
tree7604262918a9d4fb85493ef809a0a60b8ebd1d9e /org.eclipse.jubula.toolkit.api.gen
parent600226289f1b19366110f714c6247b69f9caa8d3 (diff)
downloadorg.eclipse.jubula.core-f1053776f525c7e03e43b9ae80f3de822b46ef8f.tar.gz
org.eclipse.jubula.core-f1053776f525c7e03e43b9ae80f3de822b46ef8f.tar.xz
org.eclipse.jubula.core-f1053776f525c7e03e43b9ae80f3de822b46ef8f.zip
Sprint task - Java API - Introduced using of just the class name if a parameter type is from java.lang or a jubula enum
Diffstat (limited to 'org.eclipse.jubula.toolkit.api.gen')
-rw-r--r--org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java25
-rw-r--r--org.eclipse.jubula.toolkit.api.gen/templates/ClassGenerator.javajet3
2 files changed, 27 insertions, 1 deletions
diff --git a/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java b/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java
index 3dcf94d3f..6b29a8216 100644
--- a/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java
+++ b/org.eclipse.jubula.toolkit.api.gen/src/org/eclipse/jubula/toolkit/api/gen/internal/utils/NameLoader.java
@@ -13,6 +13,7 @@ package org.eclipse.jubula.toolkit.api.gen.internal.utils;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
+import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
@@ -61,6 +62,14 @@ public class NameLoader {
/** specific path for implementation classes */
private static final String TOOLKITINFO_NAME_EXTENSION =
"ToolkitInfo"; //$NON-NLS-1$
+
+ /** Pattern for detecting types in java.lang */
+ private static Pattern javaLang = Pattern.compile(
+ "java\\.lang\\.([A-Z][a-zA-Z]*)"); //$NON-NLS-1$
+
+ /** Pattern for detecting types in org.eclipse.jubula.toolkit.enums.ValueSets */
+ private static Pattern jubulaEnum = Pattern.compile(
+ "org\\.eclipse\\.jubula\\.toolkit\\.enums\\.ValueSets\\.([A-Z][a-zA-Z]*)"); //$NON-NLS-1$
/**
* <code>instance</code> the singleton instance
@@ -73,7 +82,6 @@ public class NameLoader {
/** the enum mapping properties */
private Properties m_enumMappingProperties;
-
/**
* The constructor.
*/
@@ -264,4 +272,19 @@ public class NameLoader {
public String getEnumForParam(String paramType) {
return m_enumMappingProperties.getProperty(paramType);
}
+
+ /**
+ * Cuts the path of a type name if it is from the java.lang package or
+ * from org.eclipse.jubula.toolkit.enums.ValueSets or leaves it as it is
+ * @param paramType the type name
+ * @return the shortened type name
+ */
+ public static String beautifyParamType(String paramType) {
+ if (javaLang.matcher(paramType).matches()) {
+ return paramType.replaceAll(javaLang.pattern(), "$1"); //$NON-NLS-1$
+ } else if (jubulaEnum.matcher(paramType).matches()) {
+ return paramType.replaceAll(jubulaEnum.pattern(), "$1"); //$NON-NLS-1$
+ }
+ return paramType;
+ }
}
diff --git a/org.eclipse.jubula.toolkit.api.gen/templates/ClassGenerator.javajet b/org.eclipse.jubula.toolkit.api.gen/templates/ClassGenerator.javajet
index caa8624a4..1ccb21344 100644
--- a/org.eclipse.jubula.toolkit.api.gen/templates/ClassGenerator.javajet
+++ b/org.eclipse.jubula.toolkit.api.gen/templates/ClassGenerator.javajet
@@ -87,6 +87,7 @@ package <%=packageName%>;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jubula.communication.CAP;
+import org.eclipse.jubula.toolkit.enums.ValueSets.*;
import javax.annotation.Generated;
<%if (!genInterface) {%>
@@ -191,6 +192,7 @@ public <%if (genInterface) {%>interface<%} else {%>class<%}%> <%=className%>
String type = param.getType();
String name = param.getName();
String paramType = nameLoader.findTypeForParameter(type, name);
+ paramType = NameLoader.beautifyParamType(paramType);
String paramName = nameLoader.translateFromCompSystem(name);
String fixedType = nameLoader.getRealTypeForParameter(type, name);
paramMap.put(name, paramType);
@@ -226,6 +228,7 @@ public <%if (genInterface) {%>interface<%} else {%>class<%}%> <%=className%>
<%}%>
return messageCap;
}<%}%>
+
<%}%>
}
<%}%> \ No newline at end of file

Back to the top