19f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
29f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
39f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * or more contributor license agreements. See the NOTICE file
49f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed with this work for additional information
59f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * regarding copyright ownership. The ASF licenses this file
69f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
79f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * you may not use this file except in compliance with the License.
89f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * You may obtain a copy of the License at
99f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson *
129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * Unless required by applicable law or agreed to in writing, software
139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * See the License for the specific language governing permissions and
169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * limitations under the License.
179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/*
199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * $Id: XMLStringDefault.java 570109 2007-08-27 13:31:35Z zongaro $
209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpackage org.apache.xml.utils;
229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonimport java.util.Locale;
249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson/**
269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * The default implementation of the XMLString interface,
279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson * which is just a simple wrapper of a String object.
289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson */
299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilsonpublic class XMLStringDefault implements XMLString
309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson{
319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  private String m_str;
339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Create a XMLStringDefault object from a String
369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLStringDefault(String str)
389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    m_str = str;
409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Directly call the
449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * characters method on the passed ContentHandler for the
459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string-value. Multiple calls to the
469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * ContentHandler's characters methods may well occur for a single call to
479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this method.
489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param ch A non-null reference to a ContentHandler.
509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws org.xml.sax.SAXException
529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    throws org.xml.sax.SAXException
559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Directly call the
609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * comment method on the passed LexicalHandler for the
619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string-value.
629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param lh A non-null reference to a LexicalHandler.
649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @throws org.xml.sax.SAXException
669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    throws org.xml.sax.SAXException
699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Conditionally trim all leading and trailing whitespace in the specified String.
749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * All strings of white space are
759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * replaced by a single space character (#x20), except spaces after punctuation which
769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * receive double spaces if doublePunctuationSpaces is true.
779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This function may be useful to a formatter, but to get first class
789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * results, the formatter should probably do it's own white space handling
799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * based on the semantics of the formatting object.
809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   trimHead    Trim leading whitespace?
829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   trimTail    Trim trailing whitespace?
839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   doublePunctuationSpaces    Use double spaces for punctuation?
849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return              The trimmed string.
859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString fixWhiteSpace(boolean trimHead,
879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                 boolean trimTail,
889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                 boolean doublePunctuationSpaces)
899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.trim());
919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the length of this string.
959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the length of the sequence of characters represented by this
979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          object.
989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int length()
1009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.length();
1029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the character at the specified index. An index ranges
1069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * from <code>0</code> to <code>length() - 1</code>. The first character
1079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * of the sequence is at index <code>0</code>, the next at index
1089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>1</code>, and so on, as for array indexing.
1099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      index   the index of the character.
1119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return     the character at the specified index of this string.
1129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             The first character is at index <code>0</code>.
1139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception  IndexOutOfBoundsException  if the <code>index</code>
1149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             argument is negative or not less than the length of this
1159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             string.
1169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public char charAt(int index)
1189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.charAt(index);
1209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Copies characters from this string into the destination character
1249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * array.
1259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      srcBegin   index of the first character in the string
1279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                        to copy.
1289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      srcEnd     index after the last character in the string
1299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                        to copy.
1309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      dst        the destination array.
1319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      dstBegin   the start offset in the destination array.
1329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception IndexOutOfBoundsException If any of the following
1339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            is true:
1349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            <ul><li><code>srcBegin</code> is negative.
1359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            <li><code>srcBegin</code> is greater than <code>srcEnd</code>
1369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            <li><code>srcEnd</code> is greater than the length of this
1379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                string
1389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            <li><code>dstBegin</code> is negative
1399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *            <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
1409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                <code>dst.length</code></ul>
1419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception NullPointerException if <code>dst</code> is <code>null</code>
1429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public void getChars(int srcBegin, int srcEnd, char dst[],
1449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson                                int dstBegin)
1459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    int destIndex = dstBegin;
1479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    for (int i = srcBegin; i < srcEnd; i++)
1489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
1499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      dst[destIndex++] = m_str.charAt(i);
1509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
1519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Compares this string to the specified <code>String</code>.
1559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The result is <code>true</code> if and only if the argument is not
1569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>null</code> and is a <code>String</code> object that represents
1579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the same sequence of characters as this object.
1589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   obj2   the object to compare this <code>String</code> against.
1609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the <code>String</code>s are equal;
1619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>false</code> otherwise.
1629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#compareTo(java.lang.String)
1639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
1649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean equals(String obj2) {
1669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return m_str.equals(obj2);
1679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Compares this string to the specified object.
1719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The result is <code>true</code> if and only if the argument is not
1729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>null</code> and is a <code>String</code> object that represents
1739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the same sequence of characters as this object.
1749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   anObject   the object to compare this <code>String</code>
1769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                     against.
1779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the <code>String </code>are equal;
1789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>false</code> otherwise.
1799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#compareTo(java.lang.String)
1809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
1819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
1829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean equals(XMLString anObject)
1839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
1849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.equals(anObject.toString());
1859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
1869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
1889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
1899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Compares this string to the specified object.
1909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The result is <code>true</code> if and only if the argument is not
1919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>null</code> and is a <code>String</code> object that represents
1929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the same sequence of characters as this object.
1939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
1949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   anObject   the object to compare this <code>String</code>
1959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                     against.
1969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the <code>String </code>are equal;
1979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>false</code> otherwise.
1989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#compareTo(java.lang.String)
1999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#equalsIgnoreCase(java.lang.String)
2009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean equals(Object anObject)
2029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.equals(anObject);
2049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Compares this <code>String</code> to another <code>String</code>,
2089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * ignoring case considerations.  Two strings are considered equal
2099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * ignoring case if they are of the same length, and corresponding
2109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * characters in the two strings are equal ignoring case.
2119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   anotherString   the <code>String</code> to compare this
2139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                          <code>String</code> against.
2149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the argument is not <code>null</code>
2159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          and the <code>String</code>s are equal,
2169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          ignoring case; <code>false</code> otherwise.
2179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     #equals(Object)
2189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.Character#toLowerCase(char)
2199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see java.lang.Character#toUpperCase(char)
2209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean equalsIgnoreCase(String anotherString)
2229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.equalsIgnoreCase(anotherString);
2249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Compares two strings lexicographically.
2289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   anotherString   the <code>String</code> to be compared.
2309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the value <code>0</code> if the argument string is equal to
2319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          this string; a value less than <code>0</code> if this string
2329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          is lexicographically less than the string argument; and a
2339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          value greater than <code>0</code> if this string is
2349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          lexicographically greater than the string argument.
2359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>anotherString</code>
2369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          is <code>null</code>.
2379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int compareTo(XMLString anotherString)
2399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.compareTo(anotherString.toString());
2419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Compares two strings lexicographically, ignoring case considerations.
2459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This method returns an integer whose sign is that of
2469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>this.toUpperCase().toLowerCase().compareTo(
2479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * str.toUpperCase().toLowerCase())</code>.
2489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
2499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Note that this method does <em>not</em> take locale into account,
2509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * and will result in an unsatisfactory ordering for certain locales.
2519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The java.text package provides <em>collators</em> to allow
2529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * locale-sensitive ordering.
2539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str   the <code>String</code> to be compared.
2559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  a negative integer, zero, or a positive integer as the
2569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the specified String is greater than, equal to, or less
2579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          than this String, ignoring case considerations.
2589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.text.Collator#compare(String, String)
2599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @since   1.2
2609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int compareToIgnoreCase(XMLString str)
2629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.compareToIgnoreCase(str.toString());
2649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tests if this string starts with the specified prefix beginning
2689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * a specified index.
2699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   prefix    the prefix.
2719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   toffset   where to begin looking in the string.
2729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the character sequence represented by the
2739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is a prefix of the substring of this object starting
2749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          at index <code>toffset</code>; <code>false</code> otherwise.
2759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          The result is <code>false</code> if <code>toffset</code> is
2769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          negative or greater than the length of this
2779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>String</code> object; otherwise the result is the same
2789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          as the result of the expression
2799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <pre>
2809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          this.subString(toffset).startsWith(prefix)
2819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          </pre>
2829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>prefix</code> is
2839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
2849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
2859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean startsWith(String prefix, int toffset)
2869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
2879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.startsWith(prefix, toffset);
2889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
2899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
2909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
2919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tests if this string starts with the specified prefix beginning
2929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * a specified index.
2939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
2949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   prefix    the prefix.
2959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   toffset   where to begin looking in the string.
2969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the character sequence represented by the
2979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is a prefix of the substring of this object starting
2989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          at index <code>toffset</code>; <code>false</code> otherwise.
2999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          The result is <code>false</code> if <code>toffset</code> is
3009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          negative or greater than the length of this
3019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>String</code> object; otherwise the result is the same
3029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          as the result of the expression
3039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <pre>
3049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          this.subString(toffset).startsWith(prefix)
3059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          </pre>
3069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>prefix</code> is
3079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
3089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean startsWith(XMLString prefix, int toffset)
3109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.startsWith(prefix.toString(), toffset);
3129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tests if this string starts with the specified prefix.
3169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   prefix   the prefix.
3189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the character sequence represented by the
3199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is a prefix of the character sequence represented by
3209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          this string; <code>false</code> otherwise.
3219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          Note also that <code>true</code> will be returned if the
3229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is an empty string or is equal to this
3239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>String</code> object as determined by the
3249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          {@link #equals(Object)} method.
3259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>prefix</code> is
3269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
3279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @since   JDK1. 0
3289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean startsWith(String prefix)
3309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.startsWith(prefix);
3329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tests if this string starts with the specified prefix.
3369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   prefix   the prefix.
3389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the character sequence represented by the
3399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is a prefix of the character sequence represented by
3409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          this string; <code>false</code> otherwise.
3419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          Note also that <code>true</code> will be returned if the
3429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is an empty string or is equal to this
3439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>String</code> object as determined by the
3449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          {@link #equals(Object)} method.
3459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>prefix</code> is
3469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
3479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @since   JDK1. 0
3489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean startsWith(XMLString prefix)
3509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.startsWith(prefix.toString());
3529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tests if this string ends with the specified suffix.
3569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   suffix   the suffix.
3589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  <code>true</code> if the character sequence represented by the
3599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          argument is a suffix of the character sequence represented by
3609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          this object; <code>false</code> otherwise. Note that the
3619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          result will be <code>true</code> if the argument is the
3629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          empty string or is equal to this <code>String</code> object
3639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          as determined by the {@link #equals(Object)} method.
3649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>suffix</code> is
3659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
3669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean endsWith(String suffix)
3689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.endsWith(suffix);
3709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns a hashcode for this string. The hashcode for a
3749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>String</code> object is computed as
3759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
3769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
3779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
3789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * using <code>int</code> arithmetic, where <code>s[i]</code> is the
3799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <i>i</i>th character of the string, <code>n</code> is the length of
3809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the string, and <code>^</code> indicates exponentiation.
3819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * (The hash value of the empty string is zero.)
3829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
3839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  a hash code value for this object.
3849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
3859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int hashCode()
3869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
3879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.hashCode();
3889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
3899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
3909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
3919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the first occurrence of the
3929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified character. If a character with value <code>ch</code> occurs
3939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * in the character sequence represented by this <code>String</code>
3949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * object, then the index of the first such occurrence is returned --
3959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * that is, the smallest value <i>k</i> such that:
3969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
3979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.charAt(<i>k</i>) == ch
3989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
3999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is <code>true</code>. If no such character occurs in this string,
4009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * then <code>-1</code> is returned.
4019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
4029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   ch   a character.
4039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the index of the first occurrence of the character in the
4049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          character sequence represented by this object, or
4059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>-1</code> if the character does not occur.
4069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
4079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int indexOf(int ch)
4089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.indexOf(ch);
4109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
4139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the first occurrence of the
4149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified character, starting the search at the specified index.
4159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
4169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * If a character with value <code>ch</code> occurs in the character
4179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sequence represented by this <code>String</code> object at an index
4189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * no smaller than <code>fromIndex</code>, then the index of the first
4199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * such occurrence is returned--that is, the smallest value <i>k</i>
4209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * such that:
4219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
4229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
4239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
4249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is true. If no such character occurs in this string at or after
4259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * position <code>fromIndex</code>, then <code>-1</code> is returned.
4269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
4279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * There is no restriction on the value of <code>fromIndex</code>. If it
4289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is negative, it has the same effect as if it were zero: this entire
4299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string may be searched. If it is greater than the length of this
4309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string, it has the same effect as if it were equal to the length of
4319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this string: <code>-1</code> is returned.
4329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
4339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   ch          a character.
4349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   fromIndex   the index to start the search from.
4359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the index of the first occurrence of the character in the
4369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          character sequence represented by this object that is greater
4379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
4389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          if the character does not occur.
4399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
4409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int indexOf(int ch, int fromIndex)
4419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.indexOf(ch, fromIndex);
4439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
4469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the last occurrence of the
4479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified character. That is, the index returned is the largest
4489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * value <i>k</i> such that:
4499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
4509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.charAt(<i>k</i>) == ch
4519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
4529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is true.
4539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The String is searched backwards starting at the last character.
4549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
4559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   ch   a character.
4569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the index of the last occurrence of the character in the
4579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          character sequence represented by this object, or
4589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>-1</code> if the character does not occur.
4599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
4609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int lastIndexOf(int ch)
4619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.lastIndexOf(ch);
4639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
4669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the last occurrence of the
4679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified character, searching backward starting at the specified
4689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * index. That is, the index returned is the largest value <i>k</i>
4699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * such that:
4709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
4719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.charAt(k) == ch) && (k <= fromIndex)
4729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
4739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is true.
4749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
4759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   ch          a character.
4769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   fromIndex   the index to start the search from. There is no
4779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          restriction on the value of <code>fromIndex</code>. If it is
4789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          greater than or equal to the length of this string, it has
4799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the same effect as if it were equal to one less than the
4809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          length of this string: this entire string may be searched.
4819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          If it is negative, it has the same effect as if it were -1:
4829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          -1 is returned.
4839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the index of the last occurrence of the character in the
4849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          character sequence represented by this object that is less
4859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          than or equal to <code>fromIndex</code>, or <code>-1</code>
4869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          if the character does not occur before that point.
4879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
4889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int lastIndexOf(int ch, int fromIndex)
4899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
4909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.lastIndexOf(ch, fromIndex);
4919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
4929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
4939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
4949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the first occurrence of the
4959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified substring. The integer returned is the smallest value
4969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <i>k</i> such that:
4979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
4989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.startsWith(str, <i>k</i>)
4999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
5009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is <code>true</code>.
5019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
5029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str   any string.
5039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  if the string argument occurs as a substring within this
5049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          object, then the index of the first character of the first
5059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          such substring is returned; if it does not occur as a
5069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          substring, <code>-1</code> is returned.
5079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>str</code> is
5089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
5099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
5109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int indexOf(String str)
5119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.indexOf(str);
5139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
5169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the first occurrence of the
5179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified substring. The integer returned is the smallest value
5189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <i>k</i> such that:
5199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
5209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.startsWith(str, <i>k</i>)
5219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
5229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is <code>true</code>.
5239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
5249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str   any string.
5259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  if the string argument occurs as a substring within this
5269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          object, then the index of the first character of the first
5279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          such substring is returned; if it does not occur as a
5289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          substring, <code>-1</code> is returned.
5299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>str</code> is
5309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
5319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
5329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int indexOf(XMLString str)
5339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.indexOf(str.toString());
5359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
5389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the first occurrence of the
5399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * specified substring, starting at the specified index. The integer
5409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * returned is the smallest value <i>k</i> such that:
5419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
5429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex)
5439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
5449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is <code>true</code>.
5459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
5469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * There is no restriction on the value of <code>fromIndex</code>. If
5479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * it is negative, it has the same effect as if it were zero: this entire
5489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string may be searched. If it is greater than the length of this
5499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string, it has the same effect as if it were equal to the length of
5509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this string: <code>-1</code> is returned.
5519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
5529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str         the substring to search for.
5539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   fromIndex   the index to start the search from.
5549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  If the string argument occurs as a substring within this
5559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          object at a starting index no smaller than
5569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>fromIndex</code>, then the index of the first character
5579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          of the first such substring is returned. If it does not occur
5589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          as a substring starting at <code>fromIndex</code> or beyond,
5599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>-1</code> is returned.
5609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>str</code> is
5619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>
5629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
5639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int indexOf(String str, int fromIndex)
5649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.indexOf(str, fromIndex);
5669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
5699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the rightmost occurrence
5709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * of the specified substring.  The rightmost empty string "" is
5719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * considered to occur at the index value <code>this.length()</code>.
5729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * The returned index is the largest value <i>k</i> such that
5739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
5749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this.startsWith(str, k)
5759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
5769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is true.
5779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
5789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str   the substring to search for.
5799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  if the string argument occurs one or more times as a substring
5809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          within this object, then the index of the first character of
5819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the last such substring is returned. If it does not occur as
5829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          a substring, <code>-1</code> is returned.
5839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException  if <code>str</code> is
5849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
5859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
5869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int lastIndexOf(String str)
5879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
5889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.lastIndexOf(str);
5899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
5909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
5919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
5929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns the index within this string of the last occurrence of
5939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * the specified substring.
5949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
5959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str         the substring to search for.
5969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   fromIndex   the index to start the search from. There is no
5979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          restriction on the value of fromIndex. If it is greater than
5989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the length of this string, it has the same effect as if it
5999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          were equal to the length of this string: this entire string
6009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          may be searched. If it is negative, it has the same effect
6019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          as if it were -1: -1 is returned.
6029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  If the string argument occurs one or more times as a substring
6039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          within this object at a starting index no greater than
6049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>fromIndex</code>, then the index of the first character of
6059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          the last such substring is returned. If it does not occur as a
6069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          substring starting at <code>fromIndex</code> or earlier,
6079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>-1</code> is returned.
6089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>str</code> is
6099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
6109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
6119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public int lastIndexOf(String str, int fromIndex)
6129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str.lastIndexOf(str, fromIndex);
6149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
6179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns a new string that is a substring of this string. The
6189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * substring begins with the character at the specified index and
6199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * extends to the end of this string. <p>
6209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Examples:
6219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
6229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "unhappy".substring(2) returns "happy"
6239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "Harbison".substring(3) returns "bison"
6249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "emptiness".substring(9) returns "" (an empty string)
6259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
6269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
6279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      beginIndex   the beginning index, inclusive.
6289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return     the specified substring.
6299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception  IndexOutOfBoundsException  if
6309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             <code>beginIndex</code> is negative or larger than the
6319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             length of this <code>String</code> object.
6329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
6339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString substring(int beginIndex)
6349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.substring(beginIndex));
6369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
6399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Returns a new string that is a substring of this string. The
6409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * substring begins at the specified <code>beginIndex</code> and
6419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * extends to the character at index <code>endIndex - 1</code>.
6429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Thus the length of the substring is <code>endIndex-beginIndex</code>.
6439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
6449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      beginIndex   the beginning index, inclusive.
6459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param      endIndex     the ending index, exclusive.
6469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return     the specified substring.
6479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception  IndexOutOfBoundsException  if the
6489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             <code>beginIndex</code> is negative, or
6499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             <code>endIndex</code> is larger than the length of
6509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             this <code>String</code> object, or
6519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             <code>beginIndex</code> is larger than
6529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *             <code>endIndex</code>.
6539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
6549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString substring(int beginIndex, int endIndex)
6559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.substring(beginIndex, endIndex));
6579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
6609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Concatenates the specified string to the end of this string.
6619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
6629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param   str   the <code>String</code> that is concatenated to the end
6639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *                of this <code>String</code>.
6649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  a string that represents the concatenation of this object's
6659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          characters followed by the string argument's characters.
6669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @exception java.lang.NullPointerException if <code>str</code> is
6679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *          <code>null</code>.
6689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
6699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString concat(String str)
6709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.concat(str));
6729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
6759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Converts all of the characters in this <code>String</code> to lower
6769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case using the rules of the given <code>Locale</code>.
6779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
6789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param locale use the case transformation rules for this locale
6799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return the String, converted to lowercase.
6809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.Character#toLowerCase(char)
6819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#toUpperCase(Locale)
6829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
6839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString toLowerCase(Locale locale)
6849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
6859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.toLowerCase(locale));
6869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
6879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
6889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
6899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Converts all of the characters in this <code>String</code> to lower
6909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case using the rules of the default locale, which is returned
6919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * by <code>Locale.getDefault</code>.
6929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
6939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
6949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the string, converted to lowercase.
6959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.Character#toLowerCase(char)
6969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#toLowerCase(Locale)
6979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
6989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString toLowerCase()
6999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
7009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.toLowerCase());
7019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
7029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
7049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Converts all of the characters in this <code>String</code> to upper
7059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case using the rules of the given locale.
7069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @param locale use the case transformation rules for this locale
7079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return the String, converted to uppercase.
7089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.Character#toUpperCase(char)
7099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#toLowerCase(Locale)
7109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
7119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString toUpperCase(Locale locale)
7129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
7139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.toUpperCase(locale));
7149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
7159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
7179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Converts all of the characters in this <code>String</code> to upper
7189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * case using the rules of the default locale, which is returned
7199f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * by <code>Locale.getDefault</code>.
7209f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
7219f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
7229f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * If no character in this string has a different uppercase version,
7239f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * based on calling the <code>toUpperCase</code> method defined by
7249f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>Character</code>, then the original string is returned.
7259f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
7269f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Otherwise, this method creates a new <code>String</code> object
7279f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * representing a character sequence identical in length to the
7289f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * character sequence represented by this <code>String</code> object and
7299f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * with every character equal to the result of applying the method
7309f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>Character.toUpperCase</code> to the corresponding character of
7319f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * this <code>String</code> object. <p>
7329f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Examples:
7339f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <blockquote><pre>
7349f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "Fahrvergn&uuml;gen".toUpperCase() returns "FAHRVERGN&Uuml;GEN"
7359f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
7369f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * </pre></blockquote>
7379f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
7389f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the string, converted to uppercase.
7399f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.Character#toUpperCase(char)
7409f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @see     java.lang.String#toUpperCase(Locale)
7419f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
7429f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString toUpperCase()
7439f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
7449f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.toUpperCase());
7459f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
7469f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7479f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
7489f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Removes white space from both ends of this string.
7499f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
7509f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * If this <code>String</code> object represents an empty character
7519f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * sequence, or the first and last characters of character sequence
7529f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * represented by this <code>String</code> object both have codes
7539f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * greater than <code>'&#92;u0020'</code> (the space character), then a
7549f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * reference to this <code>String</code> object is returned.
7559f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
7569f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Otherwise, if there is no character with a code greater than
7579f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>'&#92;u0020'</code> in the string, then a new
7589f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>String</code> object representing an empty string is created
7599f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * and returned.
7609f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
7619f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Otherwise, let <i>k</i> be the index of the first character in the
7629f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * string whose code is greater than <code>'&#92;u0020'</code>, and let
7639f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <i>m</i> be the index of the last character in the string whose code
7649f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * is greater than <code>'&#92;u0020'</code>. A new <code>String</code>
7659f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * object is created, representing the substring of this string that
7669f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * begins with the character at index <i>k</i> and ends with the
7679f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * character at index <i>m</i>-that is, the result of
7689f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <code>this.substring(<i>k</i>,&nbsp;<i>m</i>+1)</code>.
7699f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * <p>
7709f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This method may be used to trim
7719f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * {@link Character#isSpace(char) whitespace} from the beginning and end
7729f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * of a string; in fact, it trims all ASCII control characters as well.
7739f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
7749f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  this string, with white space removed from the front and end.
7759f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
7769f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public XMLString trim()
7779f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
7789f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return new XMLStringDefault(m_str.trim());
7799f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
7809f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7819f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
7829f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * This object (which is already a string!) is itself returned.
7839f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
7849f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return  the string itself.
7859f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
7869f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public String toString()
7879f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
7889f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return m_str;
7899f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
7909f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
7919f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
7929f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Tell if this object contains a java String object.
7939f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
7949f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return true if this XMLString can return a string without creating one.
7959f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
7969f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public boolean hasString()
7979f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
7989f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    return true;
7999f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
8009f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson
8019f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  /**
8029f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * Convert a string to a double -- Allowed input is in fixed
8039f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * notation ddd.fff.
8049f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   *
8059f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * @return A double value representation of the string, or return Double.NaN
8069f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   * if the string can not be converted.
8079f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson   */
8089f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  public double toDouble()
8099f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  {
8109f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    try {
8119f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return Double.valueOf(m_str).doubleValue();
8129f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
8139f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    catch (NumberFormatException nfe)
8149f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    {
8159f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson      return Double.NaN;
8169f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson    }
8179f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson  }
8189f8118474e9513f7a5b7d2a05e4a0fb15d1a6569Jesse Wilson}
819