2 *******************************************************************************
3 * Copyright (C) 1996-2010, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
8 package com.ibm.icu.impl;
10 import com.ibm.icu.text.UCharacterIterator;
18 public final class UCharArrayIterator extends UCharacterIterator {
19 private final char[] text;
20 private final int start;
21 private final int limit;
24 public UCharArrayIterator(char[] text, int start, int limit) {
25 if (start < 0 || limit > text.length || start > limit) {
26 throw new IllegalArgumentException("start: " + start + " or limit: "
27 + limit + " out of range [0, "
37 public int current() {
38 return pos < limit ? text[pos] : DONE;
41 public int getLength() {
45 public int getIndex() {
50 return pos < limit ? text[pos++] : DONE;
53 public int previous() {
54 return pos > start ? text[--pos] : DONE;
57 public void setIndex(int index) {
58 if (index < 0 || index > limit - start) {
59 throw new IndexOutOfBoundsException("index: " + index +
61 + (limit - start) + ")");
66 public int getText(char[] fillIn, int offset) {
67 int len = limit - start;
68 System.arraycopy(text, start, fillIn, offset, len);
73 * Creates a copy of this iterator, does not clone the underlying
74 * <code>Replaceable</code>object
75 * @return copy of this iterator
77 public Object clone(){
80 } catch (CloneNotSupportedException e) {
81 return null; // never invoked