/** * Returns <tt>true</tt> if, and only if, {@link #length()} is <tt>0</tt>. * * @return <tt>true</tt> if {@link #length()} is <tt>0</tt>, otherwise * <tt>false</tt> */ public final boolean isEmpty() { return toString().isEmpty(); }
/** * Returns the length of this string. * The length is equal to the number of <a href="Character.html#unicode">Unicode * code units</a> in the string. * * @return the length of the sequence of characters represented by this * object. */ public int length() { return toString().length(); }
/** * Returns true if and only if this string contains the specified * sequence of char values. * * @param s the sequence to search for * @return true if this string contains <code>s</code>, false otherwise * @throws NullPointerException if <code>s</code> is <code>null</code> */ public final boolean contains(CharSequence s) { return toString().contains(s); } }
/** * Returns <tt>true</tt> if, and only if, {@link #length()} is <tt>0</tt>. * * @return <tt>true</tt> if {@link #length()} is <tt>0</tt>, otherwise * <tt>false</tt> */ public final boolean isEmpty() { return toString().isEmpty(); }
/** * Returns true if and only if this string contains the specified * sequence of char values. * * @param s the sequence to search for * @return true if this string contains <code>s</code>, false otherwise * @throws NullPointerException if <code>s</code> is <code>null</code> */ public final boolean contains(CharSequence s) { return toString().contains(s); } }
/** * Returns the length of this string. * The length is equal to the number of <a href="Character.html#unicode">Unicode * code units</a> in the string. * * @return the length of the sequence of characters represented by this * object. */ public int length() { return toString().length(); }
/** * Compares this string to the specified {@code CharSequence}. The result * is {@code true} if and only if this {@code String} represents the same * sequence of char values as the specified sequence. * * @param cs * The sequence to compare this {@code String} against * * @return {@code true} if this {@code String} represents the same * sequence of char values as the specified sequence, {@code * false} otherwise */ public final boolean contentEquals(CharSequence cs) { return toString().contentEquals(cs); }
/** * Compares this string to the specified {@code CharSequence}. The result * is {@code true} if and only if this {@code LangString} represents the same * sequence of char values as the specified sequence. * * @param cs * The sequence to compare this {@code LangString} against * * @return {@code true} if this {@code LangString} represents the same * sequence of char values as the specified sequence, {@code * false} otherwise */ public final boolean contentEquals(CharSequence cs) { return toString().contentEquals(cs); }
/** * Tests if this string ends with the specified suffix. * * @param suffix the suffix. * @return <code>true</code> if the character sequence represented by the * argument is a suffix of the character sequence represented by * this object; <code>false</code> otherwise. Note that the * result will be <code>true</code> if the argument is the * empty string or is equal to this <code>String</code> object * as determined by the {@link #equals(Object)} method. */ public final boolean endsWith(CharSequence suffix) { return toString().endsWith(suffix.toString()); }
/** * Returns a hash code for this string. The hash code for a * <code>String</code> object is computed as <blockquote> * * <pre> * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] * </pre> * * </blockquote> using <code>int</code> arithmetic, where <code>s[i]</code> * is the <i>i</i>th character of the string, <code>n</code> is the length * of the string, and <code>^</code> indicates exponentiation. (The hash * value of the empty string is zero.) * * @return a hash code value for this object. */ @Override public int hashCode() { return toString().hashCode(); }
/** * Tests if this string starts with the specified prefix. * * @param prefix the prefix. * @return <code>true</code> if the character sequence represented by the * argument is a prefix of the character sequence represented by * this string; <code>false</code> otherwise. * Note also that <code>true</code> will be returned if the * argument is an empty string or is equal to this * <code>String</code> object as determined by the * {@link #equals(Object)} method. */ public final boolean startsWith(CharSequence prefix) { return toString().startsWith(prefix.toString()); }
/** * Returns a hash code for this string. The hash code for a * <code>String</code> object is computed as <blockquote> * * <pre> * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] * </pre> * * </blockquote> using <code>int</code> arithmetic, where <code>s[i]</code> * is the <i>i</i>th character of the string, <code>n</code> is the length * of the string, and <code>^</code> indicates exponentiation. (The hash * value of the empty string is zero.) * * @return a hash code value for this object. */ @Override public int hashCode() { return toString().hashCode(); }
/** * Tests if this string ends with the specified suffix. * * @param suffix the suffix. * @return <code>true</code> if the character sequence represented by the * argument is a suffix of the character sequence represented by * this object; <code>false</code> otherwise. Note that the * result will be <code>true</code> if the argument is the * empty string or is equal to this <code>String</code> object * as determined by the {@link #equals(Object)} method. */ public final boolean endsWith(CharSequence suffix) { return toString().endsWith(suffix.toString()); }
/** * Tests if this string starts with the specified prefix. * * @param prefix the prefix. * @return <code>true</code> if the character sequence represented by the * argument is a prefix of the character sequence represented by * this string; <code>false</code> otherwise. * Note also that <code>true</code> will be returned if the * argument is an empty string or is equal to this * <code>String</code> object as determined by the * {@link #equals(Object)} method. */ public final boolean startsWith(CharSequence prefix) { return toString().startsWith(prefix.toString()); }
/** * Returns the index within this string of the first occurrence of the * specified substring, starting at the specified index. The integer * returned is the smallest value <tt>k</tt> for which: * <blockquote><pre> * k >= Math.min(fromIndex, this.length()) && this.startsWith(str, k) * </pre></blockquote> * If no such value of <i>k</i> exists, then -1 is returned. * * @param str the substring for which to search. * @param fromIndex the index from which to start the search. * @return the index within this string of the first occurrence of the * specified substring, starting at the specified index. */ public final int indexOf(CharSequence str, int fromIndex) { return toString().indexOf(str.toString(), fromIndex); }
/** * Returns the index within this string of the last occurrence of the * specified substring, searching backward starting at the specified index. * The integer returned is the largest value <i>k</i> such that: * <blockquote><pre> * k <= Math.min(fromIndex, this.length()) && this.startsWith(str, k) * </pre></blockquote> * If no such value of <i>k</i> exists, then -1 is returned. * * @param str the substring to search for. * @param fromIndex the index to start the search from. * @return the index within this string of the last occurrence of the * specified substring. */ public final int lastIndexOf(CharSequence str, int fromIndex) { return toString().lastIndexOf(str.toString(), fromIndex); }
/** * Returns the index within this string of the first occurrence of the * specified substring, starting at the specified index. The integer * returned is the smallest value <tt>k</tt> for which: * <blockquote><pre> * k >= Math.min(fromIndex, this.length()) && this.startsWith(str, k) * </pre></blockquote> * If no such value of <i>k</i> exists, then -1 is returned. * * @param str the substring for which to search. * @param fromIndex the index from which to start the search. * @return the index within this string of the first occurrence of the * specified substring, starting at the specified index. */ public final int indexOf(CharSequence str, int fromIndex) { return toString().indexOf(str.toString(), fromIndex); }
/** * Returns the index within this string of the last occurrence of the * specified substring, searching backward starting at the specified index. * The integer returned is the largest value <i>k</i> such that: * <blockquote><pre> * k <= Math.min(fromIndex, this.length()) && this.startsWith(str, k) * </pre></blockquote> * If no such value of <i>k</i> exists, then -1 is returned. * * @param str the substring to search for. * @param fromIndex the index to start the search from. * @return the index within this string of the last occurrence of the * specified substring. */ public final int lastIndexOf(CharSequence str, int fromIndex) { return toString().lastIndexOf(str.toString(), fromIndex); }
/** * Returns the index within this string of the first occurrence of the * specified substring. The integer returned is the smallest value * <i>k</i> such that: * <blockquote><pre> * this.startsWith(str, <i>k</i>) * </pre></blockquote> * is <code>true</code>. * * @param str any string. * @return if the string argument occurs as a substring within this * object, then the index of the first character of the first * such substring is returned; if it does not occur as a * substring, <code>-1</code> is returned. */ public final int indexOf(CharSequence str) { return toString().indexOf(str.toString()); }
/** * Returns the index within this string of the rightmost occurrence * of the specified substring. The rightmost empty string "" is * considered to occur at the index value <code>this.length()</code>. * The returned index is the largest value <i>k</i> such that * <blockquote><pre> * this.startsWith(str, k) * </pre></blockquote> * is true. * * @param str the substring to search for. * @return if the string argument occurs one or more times as a substring * within this object, then the index of the first character of * the last such substring is returned. If it does not occur as * a substring, <code>-1</code> is returned. */ public final int lastIndexOf(CharSequence str) { return toString().lastIndexOf(str.toString()); }