-package org.simantics.document.linking.report.html;\r
-\r
-import java.io.BufferedInputStream;\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.io.PrintStream;\r
-\r
-/**\r
- * Base class for single HTML stream.\r
- * \r
- * @author Marko Luukkainen <marko.luukkainen@vtt.fi>\r
- *\r
- */\r
-\r
-public class HTMLStreamElement implements HTMLElement{\r
- \r
- protected HTMLStreamElement parent;\r
- protected File file;\r
- protected PrintStream os;\r
- \r
- public HTMLStreamElement(File file) throws Exception{\r
- parent = null;\r
- this.file = file;\r
- os = new PrintStream(file,"UTF-8");\r
- }\r
- \r
- public HTMLStreamElement(HTMLStreamElement parent) throws Exception{\r
- this.parent = parent;\r
- openStream();\r
- }\r
- \r
- private void openStream() throws IOException {\r
- file = File.createTempFile("report_content", ".html");\r
- os = new PrintStream(file,"UTF-8");\r
- }\r
- \r
-\r
- protected void copyData(File source, PrintStream dest)throws Exception {\r
- BufferedInputStream is = new BufferedInputStream(new FileInputStream(source));\r
- while (true) {\r
- int read = is.read();\r
- if (read == -1)\r
- break;\r
- dest.write(read);\r
- }\r
- is.close();\r
- }\r
- \r
- public PrintStream getPrintStream() {\r
- return os;\r
- }\r
- \r
- /**\r
- * Closes the stream and copies the contents to the parent stream.\r
- * @throws Exception\r
- */\r
- public void close() throws Exception {\r
- os.flush();\r
- os.close();\r
- if (parent != null) {\r
- copyData(file, parent.os);\r
- file.delete();\r
- }\r
- os = null;\r
- }\r
- \r
- @Override\r
- public String getId() {\r
- return null;\r
- }\r
-}\r
+package org.simantics.document.linking.report.html;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+
+/**
+ * Base class for single HTML stream.
+ *
+ * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
+ *
+ */
+
+public class HTMLStreamElement implements HTMLElement{
+
+ protected HTMLStreamElement parent;
+ protected File file;
+ protected PrintStream os;
+
+ public HTMLStreamElement(File file) throws Exception{
+ parent = null;
+ this.file = file;
+ os = new PrintStream(file,"UTF-8"); //$NON-NLS-1$
+ }
+
+ public HTMLStreamElement(HTMLStreamElement parent) throws Exception{
+ this.parent = parent;
+ openStream();
+ }
+
+ private void openStream() throws IOException {
+ file = File.createTempFile("report_content", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
+ os = new PrintStream(file,"UTF-8"); //$NON-NLS-1$
+ }
+
+
+ protected void copyData(File source, PrintStream dest)throws Exception {
+ BufferedInputStream is = new BufferedInputStream(new FileInputStream(source));
+ while (true) {
+ int read = is.read();
+ if (read == -1)
+ break;
+ dest.write(read);
+ }
+ is.close();
+ }
+
+ public PrintStream getPrintStream() {
+ return os;
+ }
+
+ /**
+ * Closes the stream and copies the contents to the parent stream.
+ * @throws Exception
+ */
+ public void close() throws Exception {
+ os.flush();
+ os.close();
+ if (parent != null) {
+ copyData(file, parent.os);
+ file.delete();
+ }
+ os = null;
+ }
+
+ @Override
+ public String getId() {
+ return null;
+ }
+}