From 9d7354465ab229641c2da9cfe93584e1c21c6fd8 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Wed, 31 Aug 2011 15:13:48 +0200 Subject: Use resources for template streams. --- org/madore/damlengine/DamlEngine.java | 12 +++++++----- org/madore/damlengine/WeblogIndexSelect.java | 3 ++- org/madore/damlengine/WeblogSelect.java | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'org/madore') diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index 6581f37..070cbab 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -1,5 +1,7 @@ package org.madore.damlengine; +import java.io.InputStream; +import java.io.FileInputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import javax.xml.XMLConstants; @@ -87,13 +89,13 @@ public final class DamlEngine { processDocument(doc, null); } - public static void fullProcess(String fname, OutputStream out, + public static void fullProcess(InputStream in, OutputStream out, Context.WeblogSelectionContext wsc) throws Exception { final DocumentBuilder db = GetDocumentBuilder.db; - Document doc = db.parse(fname); + Document doc = db.parse(in); processDocument(doc, wsc); doc.normalizeDocument(); Unparser unparser @@ -103,9 +105,9 @@ public final class DamlEngine { } - public static void fullProcess(String fname, OutputStream out) + public static void fullProcess(InputStream in, OutputStream out) throws Exception { - fullProcess(fname, out, null); + fullProcess(in, out, null); } public static void main(String[] args) @@ -116,7 +118,7 @@ public final class DamlEngine { } for (String fname : args) { - fullProcess (fname, System.out); + fullProcess (new FileInputStream(fname), System.out); } } diff --git a/org/madore/damlengine/WeblogIndexSelect.java b/org/madore/damlengine/WeblogIndexSelect.java index 5d6bc53..c9bf617 100644 --- a/org/madore/damlengine/WeblogIndexSelect.java +++ b/org/madore/damlengine/WeblogIndexSelect.java @@ -9,7 +9,8 @@ public final class WeblogIndexSelect { public static void main(String[] args) throws Exception { - DamlEngine.fullProcess("weblog-index-template.daml", System.out, null); + DamlEngine.fullProcess(DamlEngine.class.getResourceAsStream("weblog-index-template.daml"), + System.out, null); } diff --git a/org/madore/damlengine/WeblogSelect.java b/org/madore/damlengine/WeblogSelect.java index ad61cbc..cb263e6 100644 --- a/org/madore/damlengine/WeblogSelect.java +++ b/org/madore/damlengine/WeblogSelect.java @@ -36,7 +36,8 @@ public final class WeblogSelect { wsc.xmlData.add(content); } - DamlEngine.fullProcess("weblog-month-template.daml", System.out, wsc); + DamlEngine.fullProcess(DamlEngine.class.getResourceAsStream("weblog-month-template.daml"), + System.out, wsc); } -- cgit v1.2.3