1 19 package org.netbeans.modules.xml.text.syntax; 20 21 import java.util.*; 22 import java.io.*; 23 24 import javax.swing.text.Document ; 25 import javax.swing.text.BadLocationException ; 26 27 import org.openide.windows.*; 28 29 import org.netbeans.editor.Syntax; 30 import org.netbeans.editor.BaseDocument; 31 import org.netbeans.modules.editor.NbEditorKit; 32 import org.netbeans.modules.editor.*; 33 34 import org.netbeans.modules.xml.core.lib.EncodingHelper; 35 36 44 public class UniKit extends NbEditorKit { 45 46 47 private static final long serialVersionUID = -940485353900594155L; 48 49 50 public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException { 51 52 String enc = EncodingHelper.detectEncoding(in); 54 if ( enc == null ) { 55 enc = "UTF8"; } 57 Reader r = new InputStreamReader(in, enc); 59 super.read(r, doc, pos); 60 61 } 62 63 65 public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException { 66 super.read(in, doc, pos); 67 } 68 69 70 public void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException { 71 String enc = EncodingHelper.detectEncoding(doc); 72 if ( enc == null ) { 73 enc = "UTF8"; } 75 super.write( new OutputStreamWriter(out, enc), doc, pos, len); 77 } 78 79 81 public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException { 82 super.write(out, doc, pos, len); 83 } 84 85 } 86 | Popular Tags |