Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/Moka/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/ToInteger.java')
-rw-r--r--sandbox/Moka/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/ToInteger.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/sandbox/Moka/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/ToInteger.java b/sandbox/Moka/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/ToInteger.java
new file mode 100644
index 00000000000..8f135402051
--- /dev/null
+++ b/sandbox/Moka/org.eclipse.papyrus.moka.fuml.standardlibrary/src/org/eclipse/papyrus/moka/fuml/standardlibrary/library/real/ToInteger.java
@@ -0,0 +1,36 @@
+package org.eclipse.papyrus.moka.fuml.standardlibrary.library.real;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.Activator;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.IntegerValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.RealValue;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.OpaqueBehaviorExecution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+
+public class ToInteger extends OpaqueBehaviorExecution {
+
+ @Override
+ public void doBody(List<ParameterValue> inputParameters, List<ParameterValue> outputParameters) {
+ try {
+ Double x = ((RealValue)inputParameters.get(0).values.get(0)).value;
+ String y = x.toString();
+ IntegerValue result = new IntegerValue();
+ result.value = new Integer(y);
+ result.type = this.locus.factory.getBuiltInType("Real");
+ List<Value> outputs = new ArrayList<Value>();
+ outputs.add(result);
+ outputParameters.get(0).values = outputs;
+ } catch (Exception e) {
+ Activator.log.error("An error occured during the execution of ToInteger " + e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public Value new_() {
+ // ADDED
+ return new ToInteger();
+ }
+} \ No newline at end of file

Back to the top