diff --git a/AlgebraicDataflowArchitectureModel/src/algorithm/CodeGenerator.java b/AlgebraicDataflowArchitectureModel/src/algorithm/CodeGenerator.java index 61cb9b0..4486d9d 100644 --- a/AlgebraicDataflowArchitectureModel/src/algorithm/CodeGenerator.java +++ b/AlgebraicDataflowArchitectureModel/src/algorithm/CodeGenerator.java @@ -3,15 +3,33 @@ import java.util.ArrayList; import models.*; +import models.dataConstraintModel.IdentifierTemplate; import models.dataFlowModel.*; public class CodeGenerator { - static public ArrayList doGenerate(ResourceDependencyGraph graph){ + static public ArrayList doGenerate(ResourceDependencyGraph graph) { ArrayList codes = new ArrayList<>(); - for(Node n:graph.getNodes()) { + codes.add("public class Main {"); + for (Node n : graph.getNodes()) { + ResourceNode resource = (ResourceNode) n; + String str = "\t" + "private " + + resource.getIdentifierTemplate().getResourceName().substring(0, 1).toUpperCase() + + resource.getIdentifierTemplate().getResourceName().substring(1) + " " + + resource.getIdentifierTemplate().getResourceName() + " = new " + + resource.getIdentifierTemplate().getResourceName().substring(0, 1).toUpperCase() + + resource.getIdentifierTemplate().getResourceName().substring(1) + "("; + if (((StoreAttribute) resource.getAttribute()).isStored()) { + for (Node pn : resource.getSuccessors()) { + str += ((ResourceNode) pn).getIdentifierTemplate().getResourceName().substring(0, 1).toUpperCase() + ((ResourceNode) pn).getIdentifierTemplate().getResourceName().substring(1) + ","; + } + } + str = str + ");"; + codes.add(str); + } + codes.add("}"); + for (Node n : graph.getNodes()) { ResourceNode resource = (ResourceNode) n; codes.add("public class " + resource.getIdentifierTemplate().getResourceName() + " {"); - ((StoreAttribute) resource.getAttribute()).isStored(); codes.add("}"); } return codes;