(refs #7325) Fixed incorrect call of write in FilterCRWriter
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / resourceFiles / FilterCRWriter.java
1 package org.simantics.graph.compiler.internal.resourceFiles;
2
3 import java.io.FilterWriter;
4 import java.io.IOException;
5 import java.io.Writer;
6
7 public class FilterCRWriter extends FilterWriter {
8
9     public FilterCRWriter(Writer out) {
10         super(out);
11     }
12     
13     @Override
14     public void write(int c) throws IOException {
15         if(c != '\r')
16             out.write(c);
17     }
18     
19     @Override
20     public void write(char[] cbuf, int off, int len) throws IOException {
21         int begin = 0;
22         for(int i=0;i<len;++i) {
23             if(cbuf[off+i] == '\r') {
24                 if(i > begin)
25                     out.write(cbuf, off+begin, i-begin);
26                 begin = i+1;
27             }
28         }
29         if(len > begin)
30             out.write(cbuf, off+begin, len-begin);
31     }
32     
33     @Override
34     public void write(String str, int off, int len) throws IOException {
35         int begin = 0;
36         for(int i=0;i<len;++i) {
37             if(str.charAt(off+i) == '\r') {
38                 if(i > begin)
39                     out.write(str, off+begin, i-begin);
40                 begin = i+1;
41             }
42         }
43         if(len > begin)
44             out.write(str, off+begin, len-begin);
45     }
46
47 }