protected boolean wantToKeep() {
return env.optionSet(ToolConstants.CFG_GEN_NEW_ONLY);
}
protected Writer parseOutputName(String packageName, String filename, String ext) throws ToolException {
FileWriterUtil fw = null;
Writer writer = null;
if (wantToKeep() && isCollision(packageName, filename, ext)) {
Message msg = new Message("SKIP_GEN", LOG, packageName + "." + filename + ext);
LOG.log(Level.INFO, msg.toString());
return null;
}
fw = new FileWriterUtil(getOutputDir(),
(OutputStreamCreator)env.get(OutputStreamCreator.class));
try {
if (".java".equals(ext)) {
writer = fw.getWriter(packageName, filename + ext,
(String)getEnvironment().get(ToolConstants.CFG_ENCODING));
} else {
writer = fw.getWriter(packageName, filename + ext);
}
} catch (IOException ioe) {
Message msg = new Message("FAIL_TO_WRITE_FILE", LOG, packageName + "." + filename + ext);
throw new ToolException(msg, ioe);
}