1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xalan" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, Lotus
  53. * Development Corporation., http://www.lotus.com. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package org.apache.xml.utils;
  58. import java.util.Locale;
  59. /**
  60. * This class is meant to be an interface to character strings, whether they
  61. * be java Strings or <code>org.apache.xml.utils.FastStringBuffer</code>s, or
  62. * other character data. By using XMLString, character copies can be reduced
  63. * in the XML pipeline.
  64. */
  65. public interface XMLString
  66. {
  67. /**
  68. * Directly call the
  69. * characters method on the passed ContentHandler for the
  70. * string-value. Multiple calls to the
  71. * ContentHandler's characters methods may well occur for a single call to
  72. * this method.
  73. *
  74. * @param ch A non-null reference to a ContentHandler.
  75. *
  76. * @throws org.xml.sax.SAXException
  77. */
  78. public abstract void dispatchCharactersEvents(org.xml.sax.ContentHandler ch)
  79. throws org.xml.sax.SAXException;
  80. /**
  81. * Directly call the
  82. * comment method on the passed LexicalHandler for the
  83. * string-value.
  84. *
  85. * @param lh A non-null reference to a LexicalHandler.
  86. *
  87. * @throws org.xml.sax.SAXException
  88. */
  89. public abstract void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh)
  90. throws org.xml.sax.SAXException;
  91. /**
  92. * Conditionally trim all leading and trailing whitespace in the specified String.
  93. * All strings of white space are
  94. * replaced by a single space character (#x20), except spaces after punctuation which
  95. * receive double spaces if doublePunctuationSpaces is true.
  96. * This function may be useful to a formatter, but to get first class
  97. * results, the formatter should probably do it's own white space handling
  98. * based on the semantics of the formatting object.
  99. *
  100. * @param trimHead Trim leading whitespace?
  101. * @param trimTail Trim trailing whitespace?
  102. * @param doublePunctuationSpaces Use double spaces for punctuation?
  103. * @return The trimmed string.
  104. */
  105. public XMLString fixWhiteSpace(boolean trimHead,
  106. boolean trimTail,
  107. boolean doublePunctuationSpaces);
  108. /**
  109. * Returns the length of this string.
  110. *
  111. * @return the length of the sequence of characters represented by this
  112. * object.
  113. */
  114. public abstract int length();
  115. /**
  116. * Returns the character at the specified index. An index ranges
  117. * from <code>0</code> to <code>length() - 1</code>. The first character
  118. * of the sequence is at index <code>0</code>, the next at index
  119. * <code>1</code>, and so on, as for array indexing.
  120. *
  121. * @param index the index of the character.
  122. * @return the character at the specified index of this string.
  123. * The first character is at index <code>0</code>.
  124. * @exception IndexOutOfBoundsException if the <code>index</code>
  125. * argument is negative or not less than the length of this
  126. * string.
  127. */
  128. public abstract char charAt(int index);
  129. /**
  130. * Copies characters from this string into the destination character
  131. * array.
  132. *
  133. * @param srcBegin index of the first character in the string
  134. * to copy.
  135. * @param srcEnd index after the last character in the string
  136. * to copy.
  137. * @param dst the destination array.
  138. * @param dstBegin the start offset in the destination array.
  139. * @exception IndexOutOfBoundsException If any of the following
  140. * is true:
  141. * <ul><li><code>srcBegin</code> is negative.
  142. * <li><code>srcBegin</code> is greater than <code>srcEnd</code>
  143. * <li><code>srcEnd</code> is greater than the length of this
  144. * string
  145. * <li><code>dstBegin</code> is negative
  146. * <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than
  147. * <code>dst.length</code></ul>
  148. * @exception NullPointerException if <code>dst</code> is <code>null</code>
  149. */
  150. public abstract void getChars(int srcBegin, int srcEnd, char dst[],
  151. int dstBegin);
  152. /**
  153. * Compares this string to the specified object.
  154. * The result is <code>true</code> if and only if the argument is not
  155. * <code>null</code> and is a <code>String</code> object that represents
  156. * the same sequence of characters as this object.
  157. *
  158. * @param anObject the object to compare this <code>String</code>
  159. * against.
  160. * @return <code>true</code> if the <code>String </code>are equal;
  161. * <code>false</code> otherwise.
  162. * @see java.lang.String#compareTo(java.lang.String)
  163. * @see java.lang.String#equalsIgnoreCase(java.lang.String)
  164. */
  165. public abstract boolean equals(XMLString anObject);
  166. /**
  167. * Compares this string to the specified object.
  168. * The result is <code>true</code> if and only if the argument is not
  169. * <code>null</code> and is a <code>String</code> object that represents
  170. * the same sequence of characters as this object.
  171. *
  172. * @param anObject the object to compare this <code>String</code>
  173. * against.
  174. * @return <code>true</code> if the <code>String </code>are equal;
  175. * <code>false</code> otherwise.
  176. * @see java.lang.String#compareTo(java.lang.String)
  177. * @see java.lang.String#equalsIgnoreCase(java.lang.String)
  178. */
  179. public abstract boolean equals(Object anObject);
  180. /**
  181. * Compares this <code>String</code> to another <code>String</code>,
  182. * ignoring case considerations. Two strings are considered equal
  183. * ignoring case if they are of the same length, and corresponding
  184. * characters in the two strings are equal ignoring case.
  185. *
  186. * @param anotherString the <code>String</code> to compare this
  187. * <code>String</code> against.
  188. * @return <code>true</code> if the argument is not <code>null</code>
  189. * and the <code>String</code>s are equal,
  190. * ignoring case; <code>false</code> otherwise.
  191. * @see #equals(Object)
  192. * @see java.lang.Character#toLowerCase(char)
  193. * @see java.lang.Character#toUpperCase(char)
  194. */
  195. public abstract boolean equalsIgnoreCase(String anotherString);
  196. /**
  197. * Compares two strings lexicographically.
  198. *
  199. * @param anotherString the <code>String</code> to be compared.
  200. * @return the value <code>0</code> if the argument string is equal to
  201. * this string; a value less than <code>0</code> if this string
  202. * is lexicographically less than the string argument; and a
  203. * value greater than <code>0</code> if this string is
  204. * lexicographically greater than the string argument.
  205. * @exception java.lang.NullPointerException if <code>anotherString</code>
  206. * is <code>null</code>.
  207. */
  208. public abstract int compareTo(XMLString anotherString);
  209. /**
  210. * Compares two strings lexicographically, ignoring case considerations.
  211. * This method returns an integer whose sign is that of
  212. * <code>this.toUpperCase().toLowerCase().compareTo(
  213. * str.toUpperCase().toLowerCase())</code>.
  214. * <p>
  215. * Note that this method does <em>not</em> take locale into account,
  216. * and will result in an unsatisfactory ordering for certain locales.
  217. * The java.text package provides <em>collators</em> to allow
  218. * locale-sensitive ordering.
  219. *
  220. * @param str the <code>String</code> to be compared.
  221. * @return a negative integer, zero, or a positive integer as the
  222. * the specified String is greater than, equal to, or less
  223. * than this String, ignoring case considerations.
  224. * @see java.text.Collator#compare(String, String)
  225. * @since 1.2
  226. */
  227. public abstract int compareToIgnoreCase(XMLString str);
  228. /**
  229. * Tests if this string starts with the specified prefix beginning
  230. * a specified index.
  231. *
  232. * @param prefix the prefix.
  233. * @param toffset where to begin looking in the string.
  234. * @return <code>true</code> if the character sequence represented by the
  235. * argument is a prefix of the substring of this object starting
  236. * at index <code>toffset</code> <code>false</code> otherwise.
  237. * The result is <code>false</code> if <code>toffset</code> is
  238. * negative or greater than the length of this
  239. * <code>String</code> object; otherwise the result is the same
  240. * as the result of the expression
  241. * <pre>
  242. * this.subString(toffset).startsWith(prefix)
  243. * </pre>
  244. * @exception java.lang.NullPointerException if <code>prefix</code> is
  245. * <code>null</code>.
  246. */
  247. public abstract boolean startsWith(String prefix, int toffset);
  248. /**
  249. * Tests if this string starts with the specified prefix beginning
  250. * a specified index.
  251. *
  252. * @param prefix the prefix.
  253. * @param toffset where to begin looking in the string.
  254. * @return <code>true</code> if the character sequence represented by the
  255. * argument is a prefix of the substring of this object starting
  256. * at index <code>toffset</code> <code>false</code> otherwise.
  257. * The result is <code>false</code> if <code>toffset</code> is
  258. * negative or greater than the length of this
  259. * <code>String</code> object; otherwise the result is the same
  260. * as the result of the expression
  261. * <pre>
  262. * this.subString(toffset).startsWith(prefix)
  263. * </pre>
  264. * @exception java.lang.NullPointerException if <code>prefix</code> is
  265. * <code>null</code>.
  266. */
  267. public abstract boolean startsWith(XMLString prefix, int toffset);
  268. /**
  269. * Tests if this string starts with the specified prefix.
  270. *
  271. * @param prefix the prefix.
  272. * @return <code>true</code> if the character sequence represented by the
  273. * argument is a prefix of the character sequence represented by
  274. * this string; <code>false</code> otherwise.
  275. * Note also that <code>true</code> will be returned if the
  276. * argument is an empty string or is equal to this
  277. * <code>String</code> object as determined by the
  278. * {@link #equals(Object)} method.
  279. * @exception java.lang.NullPointerException if <code>prefix</code> is
  280. * <code>null</code>.
  281. * @since JDK1. 0
  282. */
  283. public abstract boolean startsWith(String prefix);
  284. /**
  285. * Tests if this string starts with the specified prefix.
  286. *
  287. * @param prefix the prefix.
  288. * @return <code>true</code> if the character sequence represented by the
  289. * argument is a prefix of the character sequence represented by
  290. * this string; <code>false</code> otherwise.
  291. * Note also that <code>true</code> will be returned if the
  292. * argument is an empty string or is equal to this
  293. * <code>String</code> object as determined by the
  294. * {@link #equals(Object)} method.
  295. * @exception java.lang.NullPointerException if <code>prefix</code> is
  296. * <code>null</code>.
  297. * @since JDK1. 0
  298. */
  299. public abstract boolean startsWith(XMLString prefix);
  300. /**
  301. * Tests if this string ends with the specified suffix.
  302. *
  303. * @param suffix the suffix.
  304. * @return <code>true</code> if the character sequence represented by the
  305. * argument is a suffix of the character sequence represented by
  306. * this object; <code>false</code> otherwise. Note that the
  307. * result will be <code>true</code> if the argument is the
  308. * empty string or is equal to this <code>String</code> object
  309. * as determined by the {@link #equals(Object)} method.
  310. * @exception java.lang.NullPointerException if <code>suffix</code> is
  311. * <code>null</code>.
  312. */
  313. public abstract boolean endsWith(String suffix);
  314. /**
  315. * Returns a hashcode for this string. The hashcode for a
  316. * <code>String</code> object is computed as
  317. * <blockquote><pre>
  318. * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
  319. * </pre></blockquote>
  320. * using <code>int</code> arithmetic, where <code>s[i]</code> is the
  321. * <i>i</i>th character of the string, <code>n</code> is the length of
  322. * the string, and <code>^</code> indicates exponentiation.
  323. * (The hash value of the empty string is zero.)
  324. *
  325. * @return a hash code value for this object.
  326. */
  327. public abstract int hashCode();
  328. /**
  329. * Returns the index within this string of the first occurrence of the
  330. * specified character. If a character with value <code>ch</code> occurs
  331. * in the character sequence represented by this <code>String</code>
  332. * object, then the index of the first such occurrence is returned --
  333. * that is, the smallest value <i>k</i> such that:
  334. * <blockquote><pre>
  335. * this.charAt(<i>k</i>) == ch
  336. * </pre></blockquote>
  337. * is <code>true</code>. If no such character occurs in this string,
  338. * then <code>-1</code> is returned.
  339. *
  340. * @param ch a character.
  341. * @return the index of the first occurrence of the character in the
  342. * character sequence represented by this object, or
  343. * <code>-1</code> if the character does not occur.
  344. */
  345. public abstract int indexOf(int ch);
  346. /**
  347. * Returns the index within this string of the first occurrence of the
  348. * specified character, starting the search at the specified index.
  349. * <p>
  350. * If a character with value <code>ch</code> occurs in the character
  351. * sequence represented by this <code>String</code> object at an index
  352. * no smaller than <code>fromIndex</code>, then the index of the first
  353. * such occurrence is returned--that is, the smallest value <i>k</i>
  354. * such that:
  355. * <blockquote><pre>
  356. * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex)
  357. * </pre></blockquote>
  358. * is true. If no such character occurs in this string at or after
  359. * position <code>fromIndex</code>, then <code>-1</code> is returned.
  360. * <p>
  361. * There is no restriction on the value of <code>fromIndex</code>. If it
  362. * is negative, it has the same effect as if it were zero: this entire
  363. * string may be searched. If it is greater than the length of this
  364. * string, it has the same effect as if it were equal to the length of
  365. * this string: <code>-1</code> is returned.
  366. *
  367. * @param ch a character.
  368. * @param fromIndex the index to start the search from.
  369. * @return the index of the first occurrence of the character in the
  370. * character sequence represented by this object that is greater
  371. * than or equal to <code>fromIndex</code>, or <code>-1</code>
  372. * if the character does not occur.
  373. */
  374. public abstract int indexOf(int ch, int fromIndex);
  375. /**
  376. * Returns the index within this string of the last occurrence of the
  377. * specified character. That is, the index returned is the largest
  378. * value <i>k</i> such that:
  379. * <blockquote><pre>
  380. * this.charAt(<i>k</i>) == ch
  381. * </pre></blockquote>
  382. * is true.
  383. * The String is searched backwards starting at the last character.
  384. *
  385. * @param ch a character.
  386. * @return the index of the last occurrence of the character in the
  387. * character sequence represented by this object, or
  388. * <code>-1</code> if the character does not occur.
  389. */
  390. public abstract int lastIndexOf(int ch);
  391. /**
  392. * Returns the index within this string of the last occurrence of the
  393. * specified character, searching backward starting at the specified
  394. * index. That is, the index returned is the largest value <i>k</i>
  395. * such that:
  396. * <blockquote><pre>
  397. * this.charAt(k) == ch) && (k <= fromIndex)
  398. * </pre></blockquote>
  399. * is true.
  400. *
  401. * @param ch a character.
  402. * @param fromIndex the index to start the search from. There is no
  403. * restriction on the value of <code>fromIndex</code>. If it is
  404. * greater than or equal to the length of this string, it has
  405. * the same effect as if it were equal to one less than the
  406. * length of this string: this entire string may be searched.
  407. * If it is negative, it has the same effect as if it were -1:
  408. * -1 is returned.
  409. * @return the index of the last occurrence of the character in the
  410. * character sequence represented by this object that is less
  411. * than or equal to <code>fromIndex</code>, or <code>-1</code>
  412. * if the character does not occur before that point.
  413. */
  414. public abstract int lastIndexOf(int ch, int fromIndex);
  415. /**
  416. * Returns the index within this string of the first occurrence of the
  417. * specified substring. The integer returned is the smallest value
  418. * <i>k</i> such that:
  419. * <blockquote><pre>
  420. * this.startsWith(str, <i>k</i>)
  421. * </pre></blockquote>
  422. * is <code>true</code>.
  423. *
  424. * @param str any string.
  425. * @return if the string argument occurs as a substring within this
  426. * object, then the index of the first character of the first
  427. * such substring is returned; if it does not occur as a
  428. * substring, <code>-1</code> is returned.
  429. * @exception java.lang.NullPointerException if <code>str</code> is
  430. * <code>null</code>.
  431. */
  432. public abstract int indexOf(String str);
  433. /**
  434. * Returns the index within this string of the first occurrence of the
  435. * specified substring. The integer returned is the smallest value
  436. * <i>k</i> such that:
  437. * <blockquote><pre>
  438. * this.startsWith(str, <i>k</i>)
  439. * </pre></blockquote>
  440. * is <code>true</code>.
  441. *
  442. * @param str any string.
  443. * @return if the string argument occurs as a substring within this
  444. * object, then the index of the first character of the first
  445. * such substring is returned; if it does not occur as a
  446. * substring, <code>-1</code> is returned.
  447. * @exception java.lang.NullPointerException if <code>str</code> is
  448. * <code>null</code>.
  449. */
  450. public abstract int indexOf(XMLString str);
  451. /**
  452. * Returns the index within this string of the first occurrence of the
  453. * specified substring, starting at the specified index. The integer
  454. * returned is the smallest value <i>k</i> such that:
  455. * <blockquote><pre>
  456. * this.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex)
  457. * </pre></blockquote>
  458. * is <code>true</code>.
  459. * <p>
  460. * There is no restriction on the value of <code>fromIndex</code>. If
  461. * it is negative, it has the same effect as if it were zero: this entire
  462. * string may be searched. If it is greater than the length of this
  463. * string, it has the same effect as if it were equal to the length of
  464. * this string: <code>-1</code> is returned.
  465. *
  466. * @param str the substring to search for.
  467. * @param fromIndex the index to start the search from.
  468. * @return If the string argument occurs as a substring within this
  469. * object at a starting index no smaller than
  470. * <code>fromIndex</code>, then the index of the first character
  471. * of the first such substring is returned. If it does not occur
  472. * as a substring starting at <code>fromIndex</code> or beyond,
  473. * <code>-1</code> is returned.
  474. * @exception java.lang.NullPointerException if <code>str</code> is
  475. * <code>null</code>
  476. */
  477. public abstract int indexOf(String str, int fromIndex);
  478. /**
  479. * Returns the index within this string of the rightmost occurrence
  480. * of the specified substring. The rightmost empty string "" is
  481. * considered to occur at the index value <code>this.length()</code>.
  482. * The returned index is the largest value <i>k</i> such that
  483. * <blockquote><pre>
  484. * this.startsWith(str, k)
  485. * </pre></blockquote>
  486. * is true.
  487. *
  488. * @param str the substring to search for.
  489. * @return if the string argument occurs one or more times as a substring
  490. * within this object, then the index of the first character of
  491. * the last such substring is returned. If it does not occur as
  492. * a substring, <code>-1</code> is returned.
  493. * @exception java.lang.NullPointerException if <code>str</code> is
  494. * <code>null</code>.
  495. */
  496. public abstract int lastIndexOf(String str);
  497. /**
  498. * Returns the index within this string of the last occurrence of
  499. * the specified substring.
  500. *
  501. * @param str the substring to search for.
  502. * @param fromIndex the index to start the search from. There is no
  503. * restriction on the value of fromIndex. If it is greater than
  504. * the length of this string, it has the same effect as if it
  505. * were equal to the length of this string: this entire string
  506. * may be searched. If it is negative, it has the same effect
  507. * as if it were -1: -1 is returned.
  508. * @return If the string argument occurs one or more times as a substring
  509. * within this object at a starting index no greater than
  510. * <code>fromIndex</code>, then the index of the first character of
  511. * the last such substring is returned. If it does not occur as a
  512. * substring starting at <code>fromIndex</code> or earlier,
  513. * <code>-1</code> is returned.
  514. * @exception java.lang.NullPointerException if <code>str</code> is
  515. * <code>null</code>.
  516. */
  517. public abstract int lastIndexOf(String str, int fromIndex);
  518. /**
  519. * Returns a new string that is a substring of this string. The
  520. * substring begins with the character at the specified index and
  521. * extends to the end of this string. <p>
  522. * Examples:
  523. * <blockquote><pre>
  524. * "unhappy".substring(2) returns "happy"
  525. * "Harbison".substring(3) returns "bison"
  526. * "emptiness".substring(9) returns "" (an empty string)
  527. * </pre></blockquote>
  528. *
  529. * @param beginIndex the beginning index, inclusive.
  530. * @return the specified substring.
  531. * @exception IndexOutOfBoundsException if
  532. * <code>beginIndex</code> is negative or larger than the
  533. * length of this <code>String</code> object.
  534. */
  535. public abstract XMLString substring(int beginIndex);
  536. /**
  537. * Returns a new string that is a substring of this string. The
  538. * substring begins at the specified <code>beginIndex</code> and
  539. * extends to the character at index <code>endIndex - 1</code>.
  540. * Thus the length of the substring is <code>endIndex-beginIndex</code>.
  541. *
  542. * @param beginIndex the beginning index, inclusive.
  543. * @param endIndex the ending index, exclusive.
  544. * @return the specified substring.
  545. * @exception IndexOutOfBoundsException if the
  546. * <code>beginIndex</code> is negative, or
  547. * <code>endIndex</code> is larger than the length of
  548. * this <code>String</code> object, or
  549. * <code>beginIndex</code> is larger than
  550. * <code>endIndex</code>.
  551. */
  552. public abstract XMLString substring(int beginIndex, int endIndex);
  553. /**
  554. * Concatenates the specified string to the end of this string.
  555. *
  556. * @param str the <code>String</code> that is concatenated to the end
  557. * of this <code>String</code>.
  558. * @return a string that represents the concatenation of this object's
  559. * characters followed by the string argument's characters.
  560. * @exception java.lang.NullPointerException if <code>str</code> is
  561. * <code>null</code>.
  562. */
  563. public abstract XMLString concat(String str);
  564. /**
  565. * Converts all of the characters in this <code>String</code> to lower
  566. * case using the rules of the given <code>Locale</code>.
  567. *
  568. * @param locale use the case transformation rules for this locale
  569. * @return the String, converted to lowercase.
  570. * @see java.lang.Character#toLowerCase(char)
  571. * @see java.lang.String#toUpperCase(Locale)
  572. */
  573. public abstract XMLString toLowerCase(Locale locale);
  574. /**
  575. * Converts all of the characters in this <code>String</code> to lower
  576. * case using the rules of the default locale, which is returned
  577. * by <code>Locale.getDefault</code>.
  578. * <p>
  579. *
  580. * @return the string, converted to lowercase.
  581. * @see java.lang.Character#toLowerCase(char)
  582. * @see java.lang.String#toLowerCase(Locale)
  583. */
  584. public abstract XMLString toLowerCase();
  585. /**
  586. * Converts all of the characters in this <code>String</code> to upper
  587. * case using the rules of the given locale.
  588. * @param locale use the case transformation rules for this locale
  589. * @return the String, converted to uppercase.
  590. * @see java.lang.Character#toUpperCase(char)
  591. * @see java.lang.String#toLowerCase(Locale)
  592. */
  593. public abstract XMLString toUpperCase(Locale locale);
  594. /**
  595. * Converts all of the characters in this <code>String</code> to upper
  596. * case using the rules of the default locale, which is returned
  597. * by <code>Locale.getDefault</code>.
  598. *
  599. * <p>
  600. * If no character in this string has a different uppercase version,
  601. * based on calling the <code>toUpperCase</code> method defined by
  602. * <code>Character</code>, then the original string is returned.
  603. * <p>
  604. * Otherwise, this method creates a new <code>String</code> object
  605. * representing a character sequence identical in length to the
  606. * character sequence represented by this <code>String</code> object and
  607. * with every character equal to the result of applying the method
  608. * <code>Character.toUpperCase</code> to the corresponding character of
  609. * this <code>String</code> object. <p>
  610. * Examples:
  611. * <blockquote><pre>
  612. * "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN"
  613. * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!"
  614. * </pre></blockquote>
  615. *
  616. * @return the string, converted to uppercase.
  617. * @see java.lang.Character#toUpperCase(char)
  618. * @see java.lang.String#toUpperCase(Locale)
  619. */
  620. public abstract XMLString toUpperCase();
  621. /**
  622. * Removes white space from both ends of this string.
  623. * <p>
  624. * If this <code>String</code> object represents an empty character
  625. * sequence, or the first and last characters of character sequence
  626. * represented by this <code>String</code> object both have codes
  627. * greater than <code>'\u0020'</code> (the space character), then a
  628. * reference to this <code>String</code> object is returned.
  629. * <p>
  630. * Otherwise, if there is no character with a code greater than
  631. * <code>'\u0020'</code> in the string, then a new
  632. * <code>String</code> object representing an empty string is created
  633. * and returned.
  634. * <p>
  635. * Otherwise, let <i>k</i> be the index of the first character in the
  636. * string whose code is greater than <code>'\u0020'</code>, and let
  637. * <i>m</i> be the index of the last character in the string whose code
  638. * is greater than <code>'\u0020'</code>. A new <code>String</code>
  639. * object is created, representing the substring of this string that
  640. * begins with the character at index <i>k</i> and ends with the
  641. * character at index <i>m</i>-that is, the result of
  642. * <code>this.substring(<i>k</i>, <i>m</i>+1)</code>.
  643. * <p>
  644. * This method may be used to trim
  645. * {@link Character#isSpace(char) whitespace} from the beginning and end
  646. * of a string; in fact, it trims all ASCII control characters as well.
  647. *
  648. * @return this string, with white space removed from the front and end.
  649. */
  650. public abstract XMLString trim();
  651. /**
  652. * This object (which is already a string!) is itself returned.
  653. *
  654. * @return the string itself.
  655. */
  656. public abstract String toString();
  657. /**
  658. * Tell if this object contains a java String object.
  659. *
  660. * @return true if this XMLString can return a string without creating one.
  661. */
  662. public abstract boolean hasString();
  663. /**
  664. * Convert a string to a double -- Allowed input is in fixed
  665. * notation ddd.fff.
  666. *
  667. * @return A double value representation of the string, or return Double.NaN
  668. * if the string can not be converted.
  669. */
  670. public double toDouble();
  671. }