Skip to content
Snippets Groups Projects
Commit 2746b287 authored by Christian Wulf's avatar Christian Wulf
Browse files

corrected rules

parent b6b990fb
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@
</appenders>
<loggers>
<logger name="de.chw.css.script.ProductLineTemplateEngine" level="debug" additivity="false">
<logger name="de.chw.css.script.ProductLineTemplateEngine" level="off" additivity="false">
<appender-ref ref="Console" />
<!-- <appender-ref ref="File" /> -->
</logger>
......
package de.chw.css.script;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
......@@ -27,13 +28,15 @@ public class ProductLineGenerator {
}
}
public void generateFile(String filename) throws IOException {
FileWriter fw = new FileWriter(filename);
public boolean generateFile(String filename) throws IOException {
File file = new File(filename);
FileWriter fw = new FileWriter(file);
try {
fw.write(content);
} finally {
fw.close();
}
return file.setReadOnly();
}
public String getContent() {
......
......@@ -20,11 +20,12 @@ public class ProductLineTemplateEngine {
this.chosenProduct = chosenProduct;
}
private void generateFile(String templateFilename, String outputFilename) throws IOException {
private String generateFile(String templateFilename, String outputFilename) throws IOException {
ProductLineTemplateReader reader = new ProductLineTemplateReader(templateFilename, chosenProduct);
ProductLineGenerator generator = new ProductLineGenerator(reader.getContent(), reader.getVariables());
generator.replaceVariables("/\\*var\\*/");
generator.generateFile(outputFilename);
generator.replaceVariables("/\\*\\s*var\\s*\\*/");
boolean success = generator.generateFile(outputFilename);
return (success) ? outputFilename : null;
}
public void generateBinaryFile(File file) throws IOException {
......@@ -58,25 +59,25 @@ public class ProductLineTemplateEngine {
}
}
public void generateCss(File file) throws IOException {
public String generateCss(File file) throws IOException {
String templateFilename = file.getAbsolutePath();
String outputFilename = templateFilename.replace("_template.css", ".css");
generateFile(templateFilename, outputFilename);
return generateFile(templateFilename, outputFilename);
}
public void generateGroovy(File file) throws IOException {
public String generateGroovy(File file) throws IOException {
String templateFilename = file.getAbsolutePath();
String outputFilename = templateFilename.replace("_template.groovy", ".groovy");
generateFile(templateFilename, outputFilename);
return generateFile(templateFilename, outputFilename);
}
public void generateGsp(File file) throws IOException {
public String generateGsp(File file) throws IOException {
String templateFilename = file.getAbsolutePath();
String outputFilename = templateFilename.replace("_template.gsp", ".gsp");
// generateFile(templateFilename, outputFilename);
return generateFile(templateFilename, outputFilename);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment