1 18 package org.apache.batik.util.io; 19 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 23 29 public abstract class AbstractCharDecoder implements CharDecoder { 30 31 34 protected final static int BUFFER_SIZE = 8192; 35 36 39 protected InputStream inputStream; 40 41 44 protected byte[] buffer = new byte[BUFFER_SIZE]; 45 46 49 protected int position; 50 51 54 protected int count; 55 56 60 protected AbstractCharDecoder(InputStream is) { 61 inputStream = is; 62 } 63 64 67 public void dispose() throws IOException { 68 inputStream.close(); 69 inputStream = null; 70 } 71 72 75 protected void fillBuffer() throws IOException { 76 count = inputStream.read(buffer, 0, BUFFER_SIZE); 77 position = 0; 78 } 79 80 85 protected void charError(String encoding) throws IOException { 86 throw new IOException 87 (Messages.formatMessage("invalid.char", 88 new Object [] { encoding })); 89 } 90 91 95 protected void endOfStreamError(String encoding) throws IOException { 96 throw new IOException 97 (Messages.formatMessage("end.of.stream", 98 new Object [] { encoding })); 99 } 100 } 101 | Popular Tags |