Removed UI.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / DocumentCharacterIterator.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/DocumentCharacterIterator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/DocumentCharacterIterator.java
deleted file mode 100644 (file)
index 1aabb54..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
-package net.sourceforge.phpdt.internal.ui.text;
-
-import java.text.CharacterIterator;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * An <code>IDocument</code> based implementation of <code>CharacterIterator</code>.
- * 
- * @since 3.0
- */
-public class DocumentCharacterIterator implements CharacterIterator, CharSequence {
-
-       private int fIndex= -1;
-       private final IDocument fDocument;
-       private final int fFirst;
-       private final int fLast;
-       
-       private void invariant() {
-               Assert.isTrue(fIndex >= fFirst);
-               Assert.isTrue(fIndex <= fLast);
-       }
-       
-       /**
-        * Creates an iterator for the entire sequence.
-        * 
-        * @param sequence the sequence backing this iterator
-        */
-       public DocumentCharacterIterator(IDocument sequence) {
-               this(sequence, 0);
-       }
-       
-       /**
-        * Creates an iterator.
-        * 
-        * @param sequence the sequence backing this iterator
-        * @param first the first character to consider
-        * @throws IllegalArgumentException if the indices are out of bounds
-        */
-       public DocumentCharacterIterator(IDocument sequence, int first) throws IllegalArgumentException {
-               this(sequence, first, sequence.getLength());
-       }
-
-       /**
-        * Creates an iterator.
-        * 
-        * @param sequence the sequence backing this iterator
-        * @param first the first character to consider
-        * @param last the last character index to consider
-        * @throws IllegalArgumentException if the indices are out of bounds
-        */
-       public DocumentCharacterIterator(IDocument sequence, int first, int last) throws IllegalArgumentException {
-               if (sequence == null)
-                       throw new NullPointerException();
-               if (first < 0 || first > last)
-                       throw new IllegalArgumentException();
-               if (last > sequence.getLength())
-                       throw new IllegalArgumentException();
-               fDocument= sequence;
-               fFirst= first;
-               fLast= last;
-               fIndex= first;
-               invariant();
-       }
-
-       /*
-        * @see java.text.CharacterIterator#first()
-        */
-       public char first() {
-               return setIndex(getBeginIndex());
-       }
-
-       /*
-        * @see java.text.CharacterIterator#last()
-        */
-       public char last() {
-               if (fFirst == fLast)
-                       return setIndex(getEndIndex());
-               else
-                       return setIndex(getEndIndex() - 1);
-       }
-
-       /*
-        * @see java.text.CharacterIterator#current()
-        */
-       public char current() {
-               if (fIndex >= fFirst && fIndex < fLast)
-                       try {
-                               return fDocument.getChar(fIndex);
-                       } catch (BadLocationException e) {
-                               // ignore
-                       }
-               return DONE;
-       }
-
-       /*
-        * @see java.text.CharacterIterator#next()
-        */
-       public char next() {
-               return setIndex(Math.min(fIndex + 1, getEndIndex()));
-       }
-
-       /*
-        * @see java.text.CharacterIterator#previous()
-        */
-       public char previous() {
-               if (fIndex > getBeginIndex()) {
-                       return setIndex(fIndex - 1);
-               } else {
-                       return DONE;
-               }
-       }
-
-       /*
-        * @see java.text.CharacterIterator#setIndex(int)
-        */
-       public char setIndex(int position) {
-               if (position >= getBeginIndex() && position <= getEndIndex())
-                       fIndex= position;
-               else
-                       throw new IllegalArgumentException();
-               
-               invariant();
-               return current();
-       }
-
-       /*
-        * @see java.text.CharacterIterator#getBeginIndex()
-        */
-       public int getBeginIndex() {
-               return fFirst;
-       }
-
-       /*
-        * @see java.text.CharacterIterator#getEndIndex()
-        */
-       public int getEndIndex() {
-               return fLast;
-       }
-
-       /*
-        * @see java.text.CharacterIterator#getIndex()
-        */
-       public int getIndex() {
-               return fIndex;
-       }
-
-       /*
-        * @see java.text.CharacterIterator#clone()
-        */
-       public Object clone() {
-               try {
-                       return super.clone();
-               } catch (CloneNotSupportedException e) {
-                       throw new InternalError();
-               }
-       }
-
-       /*
-        * @see java.lang.CharSequence#length()
-        */
-       public int length() {
-               return getEndIndex() - getBeginIndex();
-       }
-
-       /*
-        * @see java.lang.CharSequence#charAt(int)
-        */
-       public char charAt(int index) {
-               if (index >= getBeginIndex() && index <= getEndIndex())
-                       try {
-                               return fDocument.getChar(index);
-                       } catch (BadLocationException e) {
-                               // ignore and return DONE
-                               return DONE;
-                       }
-               else
-                       throw new IllegalArgumentException();
-       }
-
-       /*
-        * @see java.lang.CharSequence#subSequence(int, int)
-        */
-       public CharSequence subSequence(int start, int end) {
-               return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + start + end);
-       }
-}