1 /*
2  *  Licensed to the Apache Software Foundation (ASF) under one or more
3  *  contributor license agreements.  See the NOTICE file distributed with
4  *  this work for additional information regarding copyright ownership.
5  *  The ASF licenses this file to You under the Apache License, Version 2.0
6  *  (the "License"); you may not use this file except in compliance with
7  *  the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17 
18 package java.lang;
19 
20 
21 /**
22  * This interface represents an ordered set of characters and defines the
23  * methods to probe them.
24  */
25 public interface CharSequence {
26 
27     /**
28      * Returns the number of characters in this sequence.
29      *
30      * @return the number of characters.
31      */
length()32     public int length();
33 
34     /**
35      * Returns the character at {@code index}.
36      * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >= length()}.
37      */
charAt(int index)38     public char charAt(int index);
39 
40     /**
41      * Returns a {@code CharSequence} from the {@code start} index (inclusive)
42      * to the {@code end} index (exclusive) of this sequence.
43      *
44      * @param start
45      *            the start offset of the sub-sequence. It is inclusive, that
46      *            is, the index of the first character that is included in the
47      *            sub-sequence.
48      * @param end
49      *            the end offset of the sub-sequence. It is exclusive, that is,
50      *            the index of the first character after those that are included
51      *            in the sub-sequence
52      * @return the requested sub-sequence.
53      * @throws IndexOutOfBoundsException
54      *             if {@code start < 0}, {@code end < 0}, {@code start > end},
55      *             or if {@code start} or {@code end} are greater than the
56      *             length of this sequence.
57      */
subSequence(int start, int end)58     public CharSequence subSequence(int start, int end);
59 
60     /**
61      * Returns a string with the same characters in the same order as in this
62      * sequence.
63      *
64      * @return a string based on this sequence.
65      */
toString()66     public String toString();
67 }
68