1 package org.apache.lucene.analysis.icu.segmentation;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.text.CharacterIterator;
23 * Wraps a char[] as CharacterIterator for processing with a BreakIterator
24 * @lucene.experimental
26 final class CharArrayIterator implements CharacterIterator {
33 public char [] getText() {
37 public int getStart() {
41 public int getLength() {
46 * Set a new region of text to be examined by this iterator
48 * @param array text buffer to examine
49 * @param start offset into buffer
50 * @param length maximum length to examine
52 void setText(final char array[], int start, int length) {
57 this.limit = start + length;
60 public char current() {
61 return (index == limit) ? DONE : array[index];
69 public int getBeginIndex() {
73 public int getEndIndex() {
77 public int getIndex() {
82 index = (limit == start) ? limit : limit - 1;
87 if (++index >= limit) {
95 public char previous() {
96 if (--index < start) {
104 public char setIndex(int position) {
105 if (position < getBeginIndex() || position > getEndIndex())
106 throw new IllegalArgumentException("Illegal Position: " + position);
107 index = start + position;
112 public Object clone() {
113 CharArrayIterator clone = new CharArrayIterator();
114 clone.setText(array, start, length);