X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.linking.ui%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Flinking%2Freport%2Fhtml%2FHTMLStreamElement.java;h=34d435ac706774d8bf1462a393476d142d40f6b6;hb=refs%2Fchanges%2F05%2F2505%2F4;hp=fdb821c8488bc91be43cbfeaa7b3bcb4533310b6;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/html/HTMLStreamElement.java b/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/html/HTMLStreamElement.java index fdb821c84..34d435ac7 100644 --- a/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/html/HTMLStreamElement.java +++ b/bundles/org.simantics.document.linking.ui/src/org/simantics/document/linking/report/html/HTMLStreamElement.java @@ -1,72 +1,72 @@ -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 - * - */ - -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"); - } - - public HTMLStreamElement(HTMLStreamElement parent) throws Exception{ - this.parent = parent; - openStream(); - } - - private void openStream() throws IOException { - file = File.createTempFile("report_content", ".html"); - os = new PrintStream(file,"UTF-8"); - } - - - 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; - } -} +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 + * + */ + +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; + } +}