-package org.simantics.scl.runtime.reporting;\r
-\r
-import java.io.Writer;\r
-\r
-public class SCLReportingWriter extends Writer {\r
- \r
- StringBuilder builder = null;\r
- \r
- public SCLReportingWriter() {\r
- builder = new StringBuilder();\r
- }\r
- \r
- @Override\r
- public void close() {\r
- flush();\r
- }\r
-\r
- @Override\r
- public void flush() {\r
- if (builder.length() > 0) {\r
- SCLReporting.print(builder.toString());\r
- builder.setLength(0);\r
- }\r
- }\r
-\r
- @Override\r
- public void write(char[] buf, int off, int len) {\r
- if (len == 0) return;\r
- \r
- if (len < 0) throw new IllegalArgumentException("Negative buffer region length");\r
- if (off < 0) throw new IllegalArgumentException("Negative buffer region offset");\r
- if (off + len > buf.length) throw new IllegalArgumentException("Buffer region overflow");\r
- \r
- for (int i = 0; i < len; i++) {\r
- if (buf[off + i] == '\n') {\r
- SCLReporting.print(builder.toString());\r
- builder.setLength(0);\r
- }\r
- else {\r
- builder.append(buf[off + i]);\r
- }\r
- }\r
- }\r
-}\r
+package org.simantics.scl.runtime.reporting;
+
+import java.io.Writer;
+
+public class SCLReportingWriter extends Writer {
+
+ StringBuilder builder = null;
+
+ public SCLReportingWriter() {
+ builder = new StringBuilder();
+ }
+
+ @Override
+ public void close() {
+ flush();
+ }
+
+ @Override
+ public void flush() {
+ if (builder.length() > 0) {
+ SCLReporting.print(builder.toString());
+ builder.setLength(0);
+ }
+ }
+
+ @Override
+ public void write(char[] buf, int off, int len) {
+ if (len == 0) return;
+
+ if (len < 0) throw new IllegalArgumentException("Negative buffer region length");
+ if (off < 0) throw new IllegalArgumentException("Negative buffer region offset");
+ if (off + len > buf.length) throw new IllegalArgumentException("Buffer region overflow");
+
+ for (int i = 0; i < len; i++) {
+ if (buf[off + i] == '\n') {
+ SCLReporting.print(builder.toString());
+ builder.setLength(0);
+ }
+ else {
+ builder.append(buf[off + i]);
+ }
+ }
+ }
+}