/** * This generation strategy can be used to generate files on-the-fly. It will create * {@link java.io.BufferedWriter}s so that files are written to disk whenever needed. This is the least * memory-expansive strategy; however it is not aware of VCSs as it does not check for write access before * writing the files. This is not to be used with a project under clearcase for example. * * @author Laurent Goubet * @since 3.0 */ public class DefaultStrategy extends AbstractGenerationStrategy { . . . @Override public AbstractAcceleoWriter createWriterFor(File file, AbstractAcceleoWriter previous, boolean appendMode, boolean hasJMergeTags, String charset) throws IOException { final AbstractAcceleoWriter writer; if (!file.getParentFile().exists()) { if (!file.getParentFile().mkdirs()) { throw new AcceleoEvaluationException(AcceleoEngineMessages.getString( "AcceleoEvaluationContext.FolderCreationError", file.getParentFile())); //$NON-NLS-1$ } } if (file.isDirectory()) { throw new AcceleoEvaluationException(AcceleoEngineMessages.getString( "AcceleoEvaluationContext.FileNameIsDirectory", file)); //$NON-NLS-1$ } boolean fileExisted = file.exists(); if (appendMode) { // <-- changed here if (charset != null) { if (Charset.isSupported(charset)) { writer = new GeneratorFileWriter(file, appendMode, charset); } else { final String message = AcceleoEngineMessages.getString( "AcceleoGenerationStrategy.UnsupportedCharset", charset); //$NON-NLS-1$ AcceleoEnginePlugin.log(message, false); writer = new AcceleoFileWriter(file, appendMode); } } else { writer = new GeneratorFileWriter(file, appendMode); } if (appendMode && fileExisted) { writer.append(readLineSeparator(file)); } } else { if (charset != null) { if (Charset.isSupported(charset)) { writer = new GeneratorFileWriter(file.getPath(), hasJMergeTags, charset); // <-- changed here } else { final String message = AcceleoEngineMessages.getString( "AcceleoGenerationStrategy.UnsupportedCharset", charset); //$NON-NLS-1$ AcceleoEnginePlugin.log(message, false); writer = new GeneratorFileWriter(file.getPath(), hasJMergeTags); // <-- changed here } } else { writer = new GeneratorFileWriter(file.getPath(), hasJMergeTags); // <-- changed here } } return writer; } . . . }