1 11 package org.eclipse.search.internal.core.text; 12 13 import org.eclipse.jface.text.BadLocationException; 14 import org.eclipse.jface.text.IDocument; 15 16 19 public class DocumentCharSequence implements CharSequence { 20 21 private final IDocument fDocument; 22 23 26 public DocumentCharSequence(IDocument document) { 27 fDocument= document; 28 } 29 30 33 public int length() { 34 return fDocument.getLength(); 35 } 36 37 40 public char charAt(int index) { 41 try { 42 return fDocument.getChar(index); 43 } catch (BadLocationException e) { 44 throw new IndexOutOfBoundsException (); 45 } 46 } 47 48 51 public CharSequence subSequence(int start, int end) { 52 try { 53 return fDocument.get(start, end - start); 54 } catch (BadLocationException e) { 55 throw new IndexOutOfBoundsException (); 56 } 57 } 58 59 } 60 | Popular Tags |