diff options
author | David A. Madore <david+git@madore.org> | 2011-09-02 18:10:30 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2011-09-02 18:10:30 +0200 |
commit | 97aabc8ab1def8bbc44166c50e045a488593bdaf (patch) | |
tree | 805ce88e1d59fd49cf33c40f7362c3c74aab7754 /org | |
parent | 0d02ad0c80c59dbd080d3653f88f7348523a3e7d (diff) | |
download | damlengine-97aabc8ab1def8bbc44166c50e045a488593bdaf.tar.gz damlengine-97aabc8ab1def8bbc44166c50e045a488593bdaf.tar.bz2 damlengine-97aabc8ab1def8bbc44166c50e045a488593bdaf.zip |
Add an "echo" command for synchronization. Close output files.
Diffstat (limited to 'org')
-rw-r--r-- | org/madore/damlengine/DamlEngine.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index 8b0b63d..c0010b6 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -9,6 +9,7 @@ import java.io.OutputStream; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.io.BufferedReader; +import java.io.PrintStream; import javax.xml.XMLConstants; import javax.xml.namespace.NamespaceContext; import javax.xml.parsers.DocumentBuilderFactory; @@ -138,6 +139,8 @@ public final class DamlEngine { ? new FileOutputStream(outf) : System.out; fullProcess(in, out); + if ( out != System.out ) + out.close(); } else if ( (matcher=Pattern.compile("process-weblog-month\\s+(\\d{4})\\-(\\d{2})(?:\\s+\\>\\s*(\\S+))?\\s*").matcher(line)).matches() ) { String year = matcher.group(1); String month = matcher.group(2); @@ -147,6 +150,8 @@ public final class DamlEngine { : System.out; WeblogSelect.fullProcess(new Context.WeblogMonthSelectionContext(year,month), out); + if ( out != System.out ) + out.close(); } else if ( (matcher=Pattern.compile("process-weblog-cat\\s+([a-z0-9\\-]+)(?:\\s+\\>\\s*(\\S+))?\\s*").matcher(line)).matches() ) { String code = matcher.group(1); String outf = matcher.group(2); @@ -155,6 +160,8 @@ public final class DamlEngine { : System.out; WeblogSelect.fullProcess(new Context.WeblogCategorySelectionContext(code), out); + if ( out != System.out ) + out.close(); } else if ( (matcher=Pattern.compile("process-weblog-recent\\s+(\\d+)(?:\\s+\\>\\s*(\\S+))?\\s*").matcher(line)).matches() ) { int count = Integer.parseInt(matcher.group(1)); String outf = matcher.group(2); @@ -169,16 +176,29 @@ public final class DamlEngine { ? new FileOutputStream(outf) : System.out; WeblogIndexSelect.fullProcess(out); + if ( out != System.out ) + out.close(); } else if ( (matcher=Pattern.compile("process-weblog-rss(?:\\s+\\>\\s*(\\S+))?\\s*").matcher(line)).matches() ) { String outf = matcher.group(1); OutputStream out = (outf != null) ? new FileOutputStream(outf) : System.out; WeblogRSS.fullProcess(out); + if ( out != System.out ) + out.close(); } else if ( (matcher=Pattern.compile("populate-weblog\\s+(\\S+)\\s*").matcher(line)).matches() ) { String inf = matcher.group(1); InputStream in = new FileInputStream(inf); WeblogPopulate.populate(in); + } else if ( (matcher=Pattern.compile("echo\\s+(\\S+)(?:\\s+\\>\\s*(\\S+))?\\s*").matcher(line)).matches() ) { + String str = matcher.group(1); + String outf = matcher.group(2); + OutputStream out = (outf != null) + ? new FileOutputStream(outf) + : System.out; + new PrintStream(out, true).println(str); + if ( out != System.out ) + out.close(); } else { throw new IllegalArgumentException("couldn't understand command"); } |