emul/mini/src/main/java/java/lang/CharSequence.java
branchemul
changeset 554 05224402145d
parent 52 94c1a17117f3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/emul/mini/src/main/java/java/lang/CharSequence.java	Wed Jan 23 20:39:23 2013 +0100
     1.3 @@ -0,0 +1,111 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.lang;
    1.30 +
    1.31 +
    1.32 +/**
    1.33 + * A <tt>CharSequence</tt> is a readable sequence of <code>char</code> values. This
    1.34 + * interface provides uniform, read-only access to many different kinds of
    1.35 + * <code>char</code> sequences.
    1.36 + * A <code>char</code> value represents a character in the <i>Basic
    1.37 + * Multilingual Plane (BMP)</i> or a surrogate. Refer to <a
    1.38 + * href="Character.html#unicode">Unicode Character Representation</a> for details.
    1.39 + *
    1.40 + * <p> This interface does not refine the general contracts of the {@link
    1.41 + * java.lang.Object#equals(java.lang.Object) equals} and {@link
    1.42 + * java.lang.Object#hashCode() hashCode} methods.  The result of comparing two
    1.43 + * objects that implement <tt>CharSequence</tt> is therefore, in general,
    1.44 + * undefined.  Each object may be implemented by a different class, and there
    1.45 + * is no guarantee that each class will be capable of testing its instances
    1.46 + * for equality with those of the other.  It is therefore inappropriate to use
    1.47 + * arbitrary <tt>CharSequence</tt> instances as elements in a set or as keys in
    1.48 + * a map. </p>
    1.49 + *
    1.50 + * @author Mike McCloskey
    1.51 + * @since 1.4
    1.52 + * @spec JSR-51
    1.53 + */
    1.54 +
    1.55 +public interface CharSequence {
    1.56 +
    1.57 +    /**
    1.58 +     * Returns the length of this character sequence.  The length is the number
    1.59 +     * of 16-bit <code>char</code>s in the sequence.</p>
    1.60 +     *
    1.61 +     * @return  the number of <code>char</code>s in this sequence
    1.62 +     */
    1.63 +    int length();
    1.64 +
    1.65 +    /**
    1.66 +     * Returns the <code>char</code> value at the specified index.  An index ranges from zero
    1.67 +     * to <tt>length() - 1</tt>.  The first <code>char</code> value of the sequence is at
    1.68 +     * index zero, the next at index one, and so on, as for array
    1.69 +     * indexing. </p>
    1.70 +     *
    1.71 +     * <p>If the <code>char</code> value specified by the index is a
    1.72 +     * <a href="{@docRoot}/java/lang/Character.html#unicode">surrogate</a>, the surrogate
    1.73 +     * value is returned.
    1.74 +     *
    1.75 +     * @param   index   the index of the <code>char</code> value to be returned
    1.76 +     *
    1.77 +     * @return  the specified <code>char</code> value
    1.78 +     *
    1.79 +     * @throws  IndexOutOfBoundsException
    1.80 +     *          if the <tt>index</tt> argument is negative or not less than
    1.81 +     *          <tt>length()</tt>
    1.82 +     */
    1.83 +    char charAt(int index);
    1.84 +
    1.85 +    /**
    1.86 +     * Returns a new <code>CharSequence</code> that is a subsequence of this sequence.
    1.87 +     * The subsequence starts with the <code>char</code> value at the specified index and
    1.88 +     * ends with the <code>char</code> value at index <tt>end - 1</tt>.  The length
    1.89 +     * (in <code>char</code>s) of the
    1.90 +     * returned sequence is <tt>end - start</tt>, so if <tt>start == end</tt>
    1.91 +     * then an empty sequence is returned. </p>
    1.92 +     *
    1.93 +     * @param   start   the start index, inclusive
    1.94 +     * @param   end     the end index, exclusive
    1.95 +     *
    1.96 +     * @return  the specified subsequence
    1.97 +     *
    1.98 +     * @throws  IndexOutOfBoundsException
    1.99 +     *          if <tt>start</tt> or <tt>end</tt> are negative,
   1.100 +     *          if <tt>end</tt> is greater than <tt>length()</tt>,
   1.101 +     *          or if <tt>start</tt> is greater than <tt>end</tt>
   1.102 +     */
   1.103 +    CharSequence subSequence(int start, int end);
   1.104 +
   1.105 +    /**
   1.106 +     * Returns a string containing the characters in this sequence in the same
   1.107 +     * order as this sequence.  The length of the string will be the length of
   1.108 +     * this sequence. </p>
   1.109 +     *
   1.110 +     * @return  a string consisting of exactly this sequence of characters
   1.111 +     */
   1.112 +    public String toString();
   1.113 +
   1.114 +}