1 11 package org.eclipse.jface.internal.text.link.contentassist; 12 13 14 import java.io.IOException ; 15 import java.io.Reader ; 16 17 abstract class SingleCharReader extends Reader { 18 19 22 public abstract int read() throws IOException ; 23 24 27 public int read(char cbuf[], int off, int len) throws IOException { 28 int end= off + len; 29 for (int i= off; i < end; i++) { 30 int ch= read(); 31 if (ch == -1) { 32 if (i == off) 33 return -1; 34 return i - off; 35 } 36 cbuf[i]= (char)ch; 37 } 38 return len; 39 } 40 41 44 public boolean ready() throws IOException { 45 return true; 46 } 47 48 53 public String getString() throws IOException { 54 StringBuffer buf= new StringBuffer (); 55 int ch; 56 while ((ch= read()) != -1) { 57 buf.append((char)ch); 58 } 59 return buf.toString(); 60 } 61 } 62 | Popular Tags |