Generates source code into the given file object from the given data model, utilizing the templating engine.
@param fileObject Target file object
@param model Data model for source code generation
@throws IOException
@author vvakame
543781
public static void writeGen(JavaFileObject fileObject, JsonModelModel model)
			throws IOException {
		MvelTemplate.writeGen(fileObject, model);
	}
757036
private void writeObject(ObjectOutputStream out) throws IOException {
		out.writeInt(batchSize);
		this.conf.write(out);
		out.writeUTF(schema.toString());

		out.writeInt(selectedFields.length);
		for (int f : selectedFields) {
			out.writeInt(f);
		}

		out.writeInt(conjunctPredicates.size());
		for (Predicate p : conjunctPredicates) {
			out.writeObject(p);
		}
	}
264266
private void generate(TemplateFile input, List<OutputFile> outputs, TemplateOptions templateOptions) throws IOException {
    final String targetFileName = targetFileName(templatesPath.relativize(input.path).toString(), templateOptions);
    final OutputFile output = new OutputFile(outputPath.resolve(targetFileName).toAbsolutePath().normalize());

    if (incremental &&
        Files.exists(output.path) &&
        Files.getLastModifiedTime(output.path).toMillis() >= Files.getLastModifiedTime(input.path).toMillis()) {
      // No need to re-render but mark as generated.
      output.upToDate = true;
      outputs.add(output);
      return;
    }

    String template = new String(Files.readAllBytes(input.path), StandardCharsets.UTF_8);

    timeVelocity.start();
    template = filterVelocity(input, template, templateOptions);
    timeVelocity.stop();

    // Check if template requested ignoring a given type combination.
    if (templateOptions.isIgnored()) {
      return;
    }

    getLog().debug("Processing: " + input.getFileName() + " => " + output.path);
    try {
      timeIntrinsics.start();
      template = filterIntrinsics(template, templateOptions);
      timeIntrinsics.stop();
  
      timeComments.start();
      template = filterComments(template);
      timeComments.stop();
  
      timeTypeClassRefs.start();
      template = filterTypeClassRefs(template, templateOptions);
      template = filterStaticTokens(template, templateOptions);
      timeTypeClassRefs.stop();
    } catch (RuntimeException e) {
      getLog().error("Error processing: " + input.getFileName() + " => " + output.path + ":\n\t" + e.getMessage());
      throw e;
    }

    Files.createDirectories(output.path.getParent());
    Files.write(output.path, template.getBytes(StandardCharsets.UTF_8));

    outputs.add(output);
  }
342594
public static void copy(File sourceFile, File targetFile) throws IOException {
	FileInputStream in = new FileInputStream(sourceFile);
	try {
	    FileOutputStream out = new FileOutputStream(targetFile);
	    try {
		copy(in, out);
	    } finally {
		out.close();
	    }
	} finally {
	    in.close();
	}
    }
99765
static OutputStream toXlsxFile(final IDataModel dataModel) {
        ByteArrayOutputStream xlsx = new ByteArrayOutputStream();
        
        try { toWorkbook(dataModel, (Workbook) null).write(xlsx); }
        catch (IOException e) { throw new CalculationEngineException(e); }
        
        return xlsx;
    }
441513
public String[] generateTypeMismatchCodes(final String objectName, final String field, final Class<?> fileType) {
        return generateCodes(getTypeMismatchCode(), objectName, field, fileType);
    }
1355591
protected File generateTemplate(File template, Instance instance) throws IOException {

		String scriptName = instance.getName().replace( "\\s+", "_" );
		File generated = File.createTempFile( scriptName, ".script");
		InstanceTemplateHelper.injectInstanceImports(instance, template, generated);

		return generated;
	}
553392
def prepare(datasource = nil)
      # Compile it, if needed
      if @source_file && ((!@object_file.exist? && @source_file.exist?) || (@source_file.exist? && @source_file.mtime > @object_file.mtime))
        _JasperCompileManager = Rjb.import('net.sf.jasperreports.engine.JasperCompileManager')
        _JasperCompileManager.compileReportToFile(@source_file.to_s, @object_file.to_s)
      end
      load_datasource(datasource)
    end
910062
@Override
	public void actionPerformed(ActionEvent arg0) {

        try {
		final OWLWorkspace workspace = editorKit.getWorkspace();
            if (obdaModel.getSources().isEmpty())
            {
                JOptionPane.showMessageDialog(workspace, "The data source is missing. Create one in ontop Mappings. ");
            }
            else {
                // Get the path of the file of the active OWL model
                OWLOntology activeOntology = modelManager.getActiveOntology();
                IRI documentIRI = modelManager.getOWLOntologyManager().getOntologyDocumentIRI(activeOntology);

                File ontologyDir = new File(documentIRI.toURI().getPath());

                final JFileChooser fc = new JFileChooser(ontologyDir);
                final String shortForm = documentIRI.getShortForm();
                int i = shortForm.lastIndexOf(".");
                String ontologyName = (i < 1)?
                        shortForm:
                        shortForm.substring(0, i);
                fc.setSelectedFile(new File(ontologyName + "-mapping.ttl"));
                //fc.setSelectedFile(new File(sourceID + "-mapping.ttl"));

                int approve = fc.showSaveDialog(workspace);

                if(approve == JFileChooser.APPROVE_OPTION) {


                    final File file = fc.getSelectedFile();

                    Thread th = new Thread("R2RML Export Action Thread"){
                        @Override
                        public void run() {
                            try {
                                OBDAProgressMonitor monitor = new OBDAProgressMonitor(
                                        "Exporting the mapping to R2RML...", workspace);
                                R2RMLExportThread t = new R2RMLExportThread();
                                monitor.addProgressListener(t);
                                monitor.start();
                                t.run(file);
                                monitor.stop();
                                JOptionPane.showMessageDialog(workspace,
                                        "R2RML Export completed.", "Done",
                                        JOptionPane.INFORMATION_MESSAGE);
                            } catch (Exception e) {
                                JOptionPane.showMessageDialog(workspace, "An error occurred. For more info, see the logs.");
                                log.error("Error during R2RML export. \n", e.getMessage());
                                e.printStackTrace();
                            }
                        }
                    };
                    th.start();


                }
            }
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(getWorkspace(), "An error occurred. For more info, see the logs.");
            log.error("Error during R2RML export. \n");
            ex.printStackTrace();
        }

	}
463734
private static void text2binModel(String inText,String outBin) throws IOException {
		ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream (
				new GZIPOutputStream (new FileOutputStream(outBin))));
		String rules = loadtxt(inText);
		Pattern p = Pattern.compile(rules);
		out.writeObject(p);
		out.close();
	}
390518
public static void writeCSV(DataObjectModel model, Collection<? extends DataObject> collection, OutputStream os) throws IOException
    {
        BufferedOutputStream bos = new BufferedOutputStream(os);
        OutputStreamWriter osw = new OutputStreamWriter(bos, "ISO-8859-1");
        CSVWriter writer = new CSVWriter(osw, ',', '"', "\r\n");
        String[] line = model.getProperties();
        writer.writeNext(line);
        for (DataObject dob : collection)
        {
            int index = 0;
            for (String property : model.getPropertyList())
            {
                Object value = dob.get(property);
                if (value != null)
                {
                    line[index++] = value.toString();
                }
                else
                {
                    line[index++] = "";
                }
            }
            writer.writeNext(line);
        }
        writer.flush();
    }
128883
JavaFileObject printSource(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
        JavaFileObject outFile
            = fileManager.getJavaFileForOutput(CLASS_OUTPUT,
                                               cdef.sym.flatname.toString(),
                                               JavaFileObject.Kind.SOURCE,
                                               null);
        if (inputFiles.contains(outFile)) {
            log.error(cdef.pos(), "source.cant.overwrite.input.file", outFile);
            return null;
        } else {
            BufferedWriter out = new BufferedWriter(outFile.openWriter());
            try {
                new Pretty(out, true).printUnit(env.toplevel, cdef);
                if (verbose)
                    log.printVerbose("wrote.file", outFile);
            } finally {
                out.close();
            }
            return outFile;
        }
    }
613534
private static void generateJavaFiles(final StatusUpdateTemplate template,
			final String workingPath) throws FileNotFoundException {
		final String javaPath = WORKING_DIR + template.getName() + ".java";
		final File javaFile = new File(javaPath);
		final String[] optionsAndSources = { "-classpath", workingPath,
				"-proc:none", "-source", "1.7", "-target", "1.7", javaPath };

		// write java file
		final PrintWriter writer = new PrintWriter(javaFile);
		writer.write(template.getJavaCode());
		writer.flush();
		writer.close();

		// delete previous class file
		final File classFile = new File(WORKING_DIR + template.getName()
				+ ".class");
		classFile.delete();

		// compile java file to class file
		final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
		compiler.run(System.in, System.out, System.err, optionsAndSources);

		// delete java file
		javaFile.delete();
	}
395128
private void generateClasses() throws IOException {
		for (BindEntity entity : model.getEntities()) {
			final BindEntity item = entity;

			BindTypeBuilder.generate(filer, item);
		}
	}
701622
public GroovyCodeSource createGroovyCodeSource(final ClassSource source) throws IOException {
    checkNotNull(source);

    if (source.getUrl() != null) {
      return new GroovyCodeSource(source.getUrl());
    }
    if (source.getFile() != null) {
      return new GroovyCodeSource(source.getFile());
    }
    if (source.getInline() != null) {
      Inline inline = source.getInline();
      return new GroovyCodeSource(inline.getInput(), inline.getName(), inline.getCodeBase());
    }

    throw new Error("Unable to create GroovyCodeSource from: " + source);
  }
55414
public static void writeModel(@NonNull Model model, @NonNull String path, boolean saveUpdater) throws IOException {
        try (BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(path))) {
            writeModel(model, stream, saveUpdater);
        }
    }
912269
public void write() throws IOException {
		{
			Filer filer = processingEnv.getFiler();
			String generateClassName =
					jsonModel.getPackageName() + "." + jsonModel.getTarget() + postfix;
			JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
			Template.writeGen(fileObject, jsonModel);
		}
		if (jsonModel.isBuilder()) {
			Filer filer = processingEnv.getFiler();
			String generateClassName =
					jsonModel.getPackageName() + "." + jsonModel.getTarget() + "JsonMeta";
			JavaFileObject fileObject = filer.createSourceFile(generateClassName, classElement);
			Template.writeJsonMeta(fileObject, jsonModel);
		}
	}