Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java')
-rw-r--r--extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java
new file mode 100644
index 00000000000..309f94f1d57
--- /dev/null
+++ b/extraplugins/cpp-codegen/org.eclipse.papyrus.cpp.codegen/jetsrc/org/eclipse/papyrus/cpp/codegen/jet/util/CppInterfaceInheritedDeclarations.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2006 CEA List.
+ * All rights reserved. This program and the accompanying materials
+ * are property of the CEA, their use is subject to specific agreement
+ * with the CEA.
+ *
+ * Contributors:
+ * CEA List - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.papyrus.cpp.codegen.jet.util;
+
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Generalization;
+import java.util.Iterator;
+import Cpp.*;
+import org.eclipse.papyrus.cpp.codegen.utils.GenUtils;
+
+public class CppInterfaceInheritedDeclarations
+{
+ protected static String nl;
+ public static synchronized CppInterfaceInheritedDeclarations create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ CppInterfaceInheritedDeclarations result = new CppInterfaceInheritedDeclarations();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Java preparation
+//////////////////////////////////////////////////////////////////////////////////////////
+
+ // Retrieve the interface
+ Classifier currentClass = (Classifier) argument;
+ String decl = "";
+ String visibility = "";
+
+ // Get generalization and implementation relationships
+ Iterator<Generalization> genIt = currentClass.getGeneralizations().iterator();
+
+ // Parse generalizations
+ while (genIt.hasNext()) {
+
+ Generalization currentGen = genIt.next();
+
+ visibility = GenUtils.getVisibility(currentGen);
+
+ // If not <NoCodeGen>
+ Classifier tmpClassifier = currentGen.getGeneral();
+ if (!GenUtils.hasStereotype(tmpClassifier, CppNoCodeGen.class)) {
+
+ String targetName = tmpClassifier.getName();
+
+ if (!decl.equals("")) {
+ decl = decl + ", ";
+ }
+ decl = decl+visibility+" "+targetName;
+ }
+ }
+
+ // ":" only if decl not empty
+ String prefix = "";
+ if (!decl.equals("")) {
+ prefix = ": ";
+ visibility = "public ";
+ }
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// The following part contains the template
+//////////////////////////////////////////////////////////////////////////////////////////
+ stringBuffer.append(TEXT_1);
+ stringBuffer.append( prefix );
+ stringBuffer.append( decl );
+ return stringBuffer.toString();
+ }
+} \ No newline at end of file

Back to the top