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