12ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/* GENERATED SOURCE. DO NOT MODIFY. */
22ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/**
32ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller*******************************************************************************
42ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller* Copyright (C) 1996-2010, International Business Machines Corporation and    *
52ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller* others. All Rights Reserved.                                                *
62ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller*******************************************************************************
72ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller*/
82ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
92ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpackage android.icu.impl;
102ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
112ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerimport android.icu.text.UCharacterIterator;
122ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
132ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
142ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller/**
152ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller * @author Doug Felt
16836e6b40a94ec3fb7545a76cb072960442b7eee9Neil Fuller * @hide Only a subset of ICU is exposed in Android
171537b2f39245c07b00aa78c3600f7aebcb172490Neil Fuller *
182ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller */
192ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
202ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fullerpublic final class UCharArrayIterator extends UCharacterIterator {
212ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private final char[] text;
222ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private final int start;
232ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private final int limit;
242ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    private int pos;
252ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
262ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public UCharArrayIterator(char[] text, int start, int limit) {
272ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        if (start < 0 || limit > text.length || start > limit) {
282ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            throw new IllegalArgumentException("start: " + start + " or limit: "
292ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                                               + limit + " out of range [0, "
302ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                                               + text.length + ")");
312ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
322ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.text = text;
332ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.start = start;
342ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.limit = limit;
352ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
362ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        this.pos = start;
372ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
382ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
392ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int current() {
402ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return pos < limit ? text[pos] : DONE;
412ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
422ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
432ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int getLength() {
442ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return limit - start;
452ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
462ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
472ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int getIndex() {
482ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return pos - start;
492ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
502ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
512ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int next() {
522ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return pos < limit ? text[pos++] : DONE;
532ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
542ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
552ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int previous() {
562ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return pos > start ? text[--pos] : DONE;
572ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
582ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
592ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public void setIndex(int index) {
602ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        if (index < 0 || index > limit - start) {
612ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            throw new IndexOutOfBoundsException("index: " + index +
622ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                                                " out of range [0, "
632ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller                                                + (limit - start) + ")");
642ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
652ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        pos = start + index;
662ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
672ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
682ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public int getText(char[] fillIn, int offset) {
692ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        int len = limit - start;
702ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        System.arraycopy(text, start, fillIn, offset, len);
712ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        return len;
722ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
732ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller
742ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    /**
752ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * Creates a copy of this iterator, does not clone the underlying
762ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * <code>Replaceable</code>object
772ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     * @return copy of this iterator
782ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller     */
792ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    public Object clone(){
802ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        try {
812ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller          return super.clone();
822ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        } catch (CloneNotSupportedException e) {
832ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller            return null; // never invoked
842ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller        }
852ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller    }
862ae130017183d2f66d55bf0ca51f8da3294644fdNeil Fuller}