示例#1
0
  // this method is used to generate source-code based on the Java model as input.
  public void generate() throws IOException {

    XMIResourceFactoryImpl xmiResourceFactoryImpl =
        new XMIResourceFactoryImpl() {
          public Resource createResource(URI uri) {
            XMIResource xmiResource = new XMIResourceImpl(uri);
            return xmiResource;
          }
        };

    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("xmi", xmiResourceFactoryImpl);

    // TesteModisco.javaxmi

    // Generate_JavaStructures jcva = new Generate_JavaStructures(modelURI, targetFolder, arguments)

    GenerateJavaExtended javaGenerator =
        new GenerateJavaExtended(
            URI.createFileURI(
                "/Users/rafaeldurelli/Documents/workspace/GeneratingJavaFromJavaModel/website/novo/TESTEValter/JavaModelRefactoring.javaxmi"),
            new File("/Users/rafaeldurelli/Desktop/src/codigoGerado"),
            new ArrayList<Object>());

    // Generate_JavaStructures javaGenerator = new Generate_JavaStructures(
    // URI.createFileURI("/Users/rafaeldurelli/Documents/workspaceMODISCO/TesteGeneralization/website/TesteModisco.javaxmi"),
    // new File("/Users/rafaeldurelli/Desktop/src/codigoGerado"), new ArrayList<Object>());

    System.out.println("Esta gerando...");
    javaGenerator.doGenerate(null);
    System.out.println("Gerou");
  }
示例#2
0
  // this method is used to generate source-code based on the Java model as input.
  public void generate(String pathToPutTheNewSourceCodeRefactored, String javaModelPath)
      throws IOException {

    XMIResourceFactoryImpl xmiResourceFactoryImpl =
        new XMIResourceFactoryImpl() {
          public Resource createResource(URI uri) {
            XMIResource xmiResource = new XMIResourceImpl(uri);
            return xmiResource;
          }
        };

    Resource.Factory.Registry.INSTANCE
        .getExtensionToFactoryMap()
        .put("xmi", xmiResourceFactoryImpl);

    GenerateJavaExtended javaGenerator =
        new GenerateJavaExtended(
            URI.createFileURI(javaModelPath),
            new File(pathToPutTheNewSourceCodeRefactored),
            new ArrayList<Object>());

    javaGenerator.doGenerate(null);
  }