jaroslav@52: /*
jaroslav@52: * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
jaroslav@52: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jaroslav@52: *
jaroslav@52: * This code is free software; you can redistribute it and/or modify it
jaroslav@52: * under the terms of the GNU General Public License version 2 only, as
jaroslav@52: * published by the Free Software Foundation. Oracle designates this
jaroslav@52: * particular file as subject to the "Classpath" exception as provided
jaroslav@52: * by Oracle in the LICENSE file that accompanied this code.
jaroslav@52: *
jaroslav@52: * This code is distributed in the hope that it will be useful, but WITHOUT
jaroslav@52: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jaroslav@52: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jaroslav@52: * version 2 for more details (a copy is included in the LICENSE file that
jaroslav@52: * accompanied this code).
jaroslav@52: *
jaroslav@52: * You should have received a copy of the GNU General Public License version
jaroslav@52: * 2 along with this work; if not, write to the Free Software Foundation,
jaroslav@52: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jaroslav@52: *
jaroslav@52: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jaroslav@52: * or visit www.oracle.com if you need additional information or have any
jaroslav@52: * questions.
jaroslav@52: */
jaroslav@52:
jaroslav@52: package java.lang;
jaroslav@52:
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * A CharSequence is a readable sequence of char
values. This
jaroslav@52: * interface provides uniform, read-only access to many different kinds of
jaroslav@52: * char
sequences.
jaroslav@52: * A char
value represents a character in the Basic
jaroslav@52: * Multilingual Plane (BMP) or a surrogate. Refer to Unicode Character Representation for details.
jaroslav@52: *
jaroslav@52: *
This interface does not refine the general contracts of the {@link jaroslav@52: * java.lang.Object#equals(java.lang.Object) equals} and {@link jaroslav@52: * java.lang.Object#hashCode() hashCode} methods. The result of comparing two jaroslav@52: * objects that implement CharSequence is therefore, in general, jaroslav@52: * undefined. Each object may be implemented by a different class, and there jaroslav@52: * is no guarantee that each class will be capable of testing its instances jaroslav@52: * for equality with those of the other. It is therefore inappropriate to use jaroslav@52: * arbitrary CharSequence instances as elements in a set or as keys in jaroslav@52: * a map.
jaroslav@52: * jaroslav@52: * @author Mike McCloskey jaroslav@52: * @since 1.4 jaroslav@52: * @spec JSR-51 jaroslav@52: */ jaroslav@52: jaroslav@52: public interface CharSequence { jaroslav@52: jaroslav@52: /** jaroslav@52: * Returns the length of this character sequence. The length is the number jaroslav@52: * of 16-bitchar
s in the sequence.
jaroslav@52: *
jaroslav@52: * @return the number of char
s in this sequence
jaroslav@52: */
jaroslav@52: int length();
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Returns the char
value at the specified index. An index ranges from zero
jaroslav@52: * to length() - 1. The first char
value of the sequence is at
jaroslav@52: * index zero, the next at index one, and so on, as for array
jaroslav@52: * indexing.
jaroslav@52: *
jaroslav@52: * If the char
value specified by the index is a
jaroslav@52: * surrogate, the surrogate
jaroslav@52: * value is returned.
jaroslav@52: *
jaroslav@52: * @param index the index of the char
value to be returned
jaroslav@52: *
jaroslav@52: * @return the specified char
value
jaroslav@52: *
jaroslav@52: * @throws IndexOutOfBoundsException
jaroslav@52: * if the index argument is negative or not less than
jaroslav@52: * length()
jaroslav@52: */
jaroslav@52: char charAt(int index);
jaroslav@52:
jaroslav@52: /**
jaroslav@52: * Returns a new CharSequence
that is a subsequence of this sequence.
jaroslav@52: * The subsequence starts with the char
value at the specified index and
jaroslav@52: * ends with the char
value at index end - 1. The length
jaroslav@52: * (in char
s) of the
jaroslav@52: * returned sequence is end - start, so if start == end
jaroslav@52: * then an empty sequence is returned.