/** * Creates a configured CodeWriter that produces files into the specified directory. * * @return * @throws java.io.IOException */ public CodeWriter createCodeWriter() throws IOException { return createCodeWriter(new FileCodeWriter(targetDir, readOnly, encoding)); }
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { return new FileOutputStream(getFile(pkg,fileName)); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File dir; if(pkg.isUnnamed()) dir = target; else dir = new File(target, toDirName(pkg)); if(!dir.exists()) dir.mkdirs(); File fn = new File(dir,fileName); if (fn.exists()) { if (!fn.delete()) throw new IOException(fn + ": Can't delete previous version"); } if(readOnly) readonlyFiles.add(fn); return fn; }
/** * Creates a configured CodeWriter that produces files into the specified directory. * * @return * @throws java.io.IOException */ public CodeWriter createCodeWriter() throws IOException { return createCodeWriter(new FileCodeWriter(targetDir, readOnly, encoding)); }
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { return new FileOutputStream(getFile(pkg,fileName)); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File dir; if(pkg == null || pkg.isUnnamed()) dir = target; else dir = new File(target, toDirName(pkg)); if(!dir.exists()) dir.mkdirs(); File fn = new File(dir,fileName); if (fn.exists()) { if (!fn.delete()) throw new IOException(fn + ": Can't delete previous version"); } if(readOnly) readonlyFiles.add(fn); return fn; }
/** * Creates a configured CodeWriter that produces files into the specified directory. */ public CodeWriter createCodeWriter() throws IOException { return createCodeWriter(new FileCodeWriter( targetDir, readOnly )); }
@Override public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { return new FileOutputStream(getFile(pkg,fileName)); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File dir; if(pkg.isUnnamed()) dir = target; else dir = new File(target, toDirName(pkg)); if(!dir.exists()) dir.mkdirs(); File fn = new File(dir,fileName); if (fn.exists()) { if (!fn.delete()) throw new IOException(fn + ": Can't delete previous version"); } if(readOnly) readonlyFiles.add(fn); return fn; }
/** * Creates a configured CodeWriter that produces files into the specified directory. * * @return * @throws java.io.IOException */ public CodeWriter createCodeWriter() throws IOException { return createCodeWriter(new FileCodeWriter(targetDir, readOnly, encoding)); }
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { return new FileOutputStream(getFile(pkg,fileName)); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File dir; if(pkg.isUnnamed()) dir = target; else dir = new File(target, toDirName(pkg)); if(!dir.exists()) dir.mkdirs(); File fn = new File(dir,fileName); if (fn.exists()) { if (!fn.delete()) throw new IOException(fn + ": Can't delete previous version"); } if(readOnly) readonlyFiles.add(fn); return fn; }
protected void writeJavaFile(File packageDirectory, JCodeModel codeModel) { try { FileCodeWriter fcw = new FileCodeWriter(packageDirectory); codeModel.build(fcw); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { return new FileOutputStream(getFile(pkg,fileName)); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File dir; if(pkg == null || pkg.isUnnamed()) dir = target; else dir = new File(target, toDirName(pkg)); if(!dir.exists()) dir.mkdirs(); File fn = new File(dir,fileName); if (fn.exists()) { if (!fn.delete()) throw new IOException(fn + ": Can't delete previous version"); } if(readOnly) readonlyFiles.add(fn); return fn; }
/** * Creates a configured CodeWriter that produces files into the specified directory. */ public CodeWriter createCodeWriter() throws IOException { return createCodeWriter(new FileCodeWriter( targetDir, readOnly )); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File f = super.getFile(pkg, fileName); options.addGeneratedFile(f); // we can't really tell the file type, for we don't know // what this file is used for. Fortunately, // FILE_TYPE doesn't seem to be used, so it doesn't really // matter what we set. return f; } }
public void generate(final File targetFolder, final String comment) throws IOException { if (!targetFolder.exists()) { targetFolder.mkdirs(); } final CodeWriter sourceCodeWriter = new SourceCodeWriter(targetFolder, comment); final CodeWriter fileCodeWriter = new FileCodeWriter(targetFolder); this.codeModel.build(sourceCodeWriter, fileCodeWriter); }
protected File getFile(JPackage pkg, String fileName ) throws IOException { File f = super.getFile(pkg, fileName); options.addGeneratedFile(f); // we can't really tell the file type, for we don't know // what this file is used for. Fortunately, // FILE_TYPE doesn't seem to be used, so it doesn't really // matter what we set. return f; } }
/** * Generates Java source code. * A convenience method that calls {@link #build(CodeWriter,CodeWriter)}. * * @param srcDir * Java source files are generated into this directory. * @param resourceDir * Other resource files are generated into this directory. * @param status * if non-null, progress indication will be sent to this stream. */ public void build( File srcDir, File resourceDir, PrintStream status ) throws IOException { CodeWriter src = new FileCodeWriter(srcDir); CodeWriter res = new FileCodeWriter(resourceDir); if(status!=null) { src = new ProgressCodeWriter(src, status ); res = new ProgressCodeWriter(res, status ); } build(src,res); }