286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 1999-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * This class represents an XPath string object, and is capable of 286N/A * converting the string to other types, such as a number. 286N/A /** Empty string XString object */ 286N/A * Construct a XString object. This constructor exists for derived classes. 286N/A * @param val String object this will wrap. 286N/A * Construct a XNodeSet object. 286N/A * @param val String object this will wrap. 286N/A * Tell that this is a CLASS_STRING. 286N/A * @return type CLASS_STRING 286N/A * Given a request type, return the equivalent string. 286N/A * For diagnostic purposes. 286N/A * @return type string "#STRING" 286N/A * Tell if this object contains a java String object. 286N/A * @return true if this XMLString can return a string without creating one. 286N/A * Cast result object to a number. 286N/A * @return 0.0 if this string is null, numeric value of this string 286N/A * Convert a string to a double -- Allowed input is in fixed 286N/A * @return A double value representation of the string, or return Double.NaN 286N/A * if the string can not be converted. 286N/A /* XMLCharacterRecognizer.isWhiteSpace(char c) methods treats the following 286N/A * characters as white space characters. 286N/A * ht - horizontal tab, nl - newline , cr - carriage return and sp - space 286N/A * trim() methods by default also takes care of these white space characters 286N/A * So trim() method is used to remove leading and trailing white spaces. 286N/A if (c !=
'-' && c !=
'.' && ( c <
0X30 || c >
0x39)) {
286N/A // The character is not a '-' or a '.' or a digit 286N/A // then return NaN because something is wrong. 286N/A * Cast result object to a boolean. 286N/A * @return True if the length of this string object is greater 286N/A * Cast result object to a string. 286N/A * @return The string this wraps or the empty string if null 286N/A * Cast result object to a string. 286N/A * @return The string this wraps or the empty string if null 286N/A * Cast result object to a result tree fragment. 286N/A * @param support Xpath context to use for the conversion 286N/A * @return A document fragment with this string as a child node 286N/A * characters method on the passed ContentHandler for the 286N/A * string-value. Multiple calls to the 286N/A * ContentHandler's characters methods may well occur for a single call to 286N/A * @param ch A non-null reference to a ContentHandler. 286N/A * @throws org.xml.sax.SAXException 286N/A * comment method on the passed LexicalHandler for the 286N/A * @param lh A non-null reference to a LexicalHandler. 286N/A * @throws org.xml.sax.SAXException 286N/A * Returns the length of this string. 286N/A * @return the length of the sequence of characters represented by this 286N/A * Returns the character at the specified index. An index ranges 286N/A * from <code>0</code> to <code>length() - 1</code>. The first character 286N/A * of the sequence is at index <code>0</code>, the next at index 286N/A * <code>1</code>, and so on, as for array indexing. 286N/A * @param index the index of the character. 286N/A * @return the character at the specified index of this string. 286N/A * The first character is at index <code>0</code>. 286N/A * @exception IndexOutOfBoundsException if the <code>index</code> 286N/A * argument is negative or not less than the length of this 286N/A * Copies characters from this string into the destination character 286N/A * @param srcBegin index of the first character in the string 286N/A * @param srcEnd index after the last character in the string 286N/A * @param dst the destination array. 286N/A * @param dstBegin the start offset in the destination array. 286N/A * @exception IndexOutOfBoundsException If any of the following 286N/A * <ul><li><code>srcBegin</code> is negative. 286N/A * <li><code>srcBegin</code> is greater than <code>srcEnd</code> 286N/A * <li><code>srcEnd</code> is greater than the length of this 286N/A * <li><code>dstBegin</code> is negative 286N/A * <li><code>dstBegin+(srcEnd-srcBegin)</code> is larger than 286N/A * <code>dst.length</code></ul> 286N/A * @exception NullPointerException if <code>dst</code> is <code>null</code> 286N/A * Tell if two objects are functionally equal. 286N/A * @param obj2 Object to compare this to 286N/A * @return true if the two objects are equal 286N/A * @throws javax.xml.transform.TransformerException 286N/A // In order to handle the 'all' semantics of 286N/A // nodeset comparisons, we always call the 286N/A // If at least one object to be compared is a boolean, then each object 286N/A // to be compared is converted to a boolean as if by applying the 286N/A // Otherwise, if at least one object to be compared is a number, then each object 286N/A // to be compared is converted to a number as if by applying the number function. 286N/A // Otherwise, both objects to be compared are converted to strings as 286N/A // if by applying the string function. 293N/A * Compares this string to the specified <code>String</code>. 293N/A * The result is <code>true</code> if and only if the argument is not 293N/A * <code>null</code> and is a <code>String</code> object that represents 293N/A * the same sequence of characters as this object. 293N/A * @param obj2 the object to compare this <code>String</code> against. 293N/A * @return <code>true</code> if the <code>String</code>s are equal; 293N/A * <code>false</code> otherwise. 293N/A * @see java.lang.String#compareTo(java.lang.String) 293N/A * @see java.lang.String#equalsIgnoreCase(java.lang.String) 286N/A * Compares this string to the specified object. 286N/A * The result is <code>true</code> if and only if the argument is not 286N/A * <code>null</code> and is a <code>String</code> object that represents 286N/A * the same sequence of characters as this object. 286N/A * @param obj2 the object to compare this <code>String</code> 286N/A * @return <code>true</code> if the <code>String </code>are equal; 286N/A * <code>false</code> otherwise. 286N/A * @see java.lang.String#compareTo(java.lang.String) 286N/A * @see java.lang.String#equalsIgnoreCase(java.lang.String) 286N/A * Compares this string to the specified object. 286N/A * The result is <code>true</code> if and only if the argument is not 286N/A * <code>null</code> and is a <code>String</code> object that represents 286N/A * the same sequence of characters as this object. 286N/A * @param obj2 the object to compare this <code>String</code> 286N/A * @return <code>true</code> if the <code>String </code>are equal; 286N/A * <code>false</code> otherwise. 286N/A * @see java.lang.String#compareTo(java.lang.String) 286N/A * @see java.lang.String#equalsIgnoreCase(java.lang.String) 286N/A // In order to handle the 'all' semantics of 286N/A // nodeset comparisons, we always call the 286N/A * Compares this <code>String</code> to another <code>String</code>, 286N/A * ignoring case considerations. Two strings are considered equal 286N/A * ignoring case if they are of the same length, and corresponding 286N/A * characters in the two strings are equal ignoring case. 286N/A * @param anotherString the <code>String</code> to compare this 286N/A * <code>String</code> against. 286N/A * @return <code>true</code> if the argument is not <code>null</code> 286N/A * and the <code>String</code>s are equal, 286N/A * ignoring case; <code>false</code> otherwise. 286N/A * @see java.lang.Character#toLowerCase(char) 286N/A * @see java.lang.Character#toUpperCase(char) 286N/A * Compares two strings lexicographically. 286N/A * @param xstr the <code>String</code> to be compared. 286N/A * @return the value <code>0</code> if the argument string is equal to 286N/A * this string; a value less than <code>0</code> if this string 286N/A * is lexicographically less than the string argument; and a 286N/A * value greater than <code>0</code> if this string is 286N/A * lexicographically greater than the string argument. 286N/A * @exception java.lang.NullPointerException if <code>anotherString</code> 286N/A * is <code>null</code>. 286N/A * Compares two strings lexicographically, ignoring case considerations. 286N/A * This method returns an integer whose sign is that of 286N/A * <code>this.toUpperCase().toLowerCase().compareTo( 286N/A * str.toUpperCase().toLowerCase())</code>. 286N/A * Note that this method does <em>not</em> take locale into account, 286N/A * and will result in an unsatisfactory ordering for certain locales. 286N/A * The java.text package provides <em>collators</em> to allow 286N/A * locale-sensitive ordering. 286N/A * @param str the <code>String</code> to be compared. 286N/A * @return a negative integer, zero, or a positive integer as the 286N/A * the specified String is greater than, equal to, or less 286N/A * than this String, ignoring case considerations. 286N/A * @see java.text.Collator#compare(String, String) 286N/A // %REVIEW% Like it says, @since 1.2. Doesn't exist in earlier 286N/A // versions of Java, hence we can't yet shell out to it. We can implement 286N/A // it as character-by-character compare, but doing so efficiently 286N/A // is likely to be (ahem) interesting. 286N/A // However, since nobody is actually _using_ this method yet: 286N/A // return str().compareToIgnoreCase(str.toString()); 286N/A "Java 1.2 method, not yet implemented"));
286N/A * Tests if this string starts with the specified prefix beginning 286N/A * @param prefix the prefix. 286N/A * @param toffset where to begin looking in the string. 286N/A * @return <code>true</code> if the character sequence represented by the 286N/A * argument is a prefix of the substring of this object starting 286N/A * at index <code>toffset</code>; <code>false</code> otherwise. 286N/A * The result is <code>false</code> if <code>toffset</code> is 286N/A * negative or greater than the length of this 286N/A * <code>String</code> object; otherwise the result is the same 286N/A * as the result of the expression 286N/A * this.subString(toffset).startsWith(prefix) 286N/A * @exception java.lang.NullPointerException if <code>prefix</code> is 286N/A * Tests if this string starts with the specified prefix. 286N/A * @param prefix the prefix. 286N/A * @return <code>true</code> if the character sequence represented by the 286N/A * argument is a prefix of the character sequence represented by 286N/A * this string; <code>false</code> otherwise. 286N/A * Note also that <code>true</code> will be returned if the 286N/A * argument is an empty string or is equal to this 286N/A * <code>String</code> object as determined by the 286N/A * {@link #equals(Object)} method. 286N/A * @exception java.lang.NullPointerException if <code>prefix</code> is 286N/A * Tests if this string starts with the specified prefix beginning 286N/A * @param prefix the prefix. 286N/A * @param toffset where to begin looking in the string. 286N/A * @return <code>true</code> if the character sequence represented by the 286N/A * argument is a prefix of the substring of this object starting 286N/A * at index <code>toffset</code>; <code>false</code> otherwise. 286N/A * The result is <code>false</code> if <code>toffset</code> is 286N/A * negative or greater than the length of this 286N/A * <code>String</code> object; otherwise the result is the same 286N/A * as the result of the expression 286N/A * this.subString(toffset).startsWith(prefix) 286N/A * @exception java.lang.NullPointerException if <code>prefix</code> is 286N/A // Note: toffset might be near -1>>>1. 286N/A * Tests if this string starts with the specified prefix. 286N/A * @param prefix the prefix. 286N/A * @return <code>true</code> if the character sequence represented by the 286N/A * argument is a prefix of the character sequence represented by 286N/A * this string; <code>false</code> otherwise. 286N/A * Note also that <code>true</code> will be returned if the 286N/A * argument is an empty string or is equal to this 286N/A * <code>String</code> object as determined by the 286N/A * {@link #equals(Object)} method. 286N/A * @exception java.lang.NullPointerException if <code>prefix</code> is 286N/A * Tests if this string ends with the specified suffix. 286N/A * @param suffix the suffix. 286N/A * @return <code>true</code> if the character sequence represented by the 286N/A * argument is a suffix of the character sequence represented by 286N/A * this object; <code>false</code> otherwise. Note that the 286N/A * result will be <code>true</code> if the argument is the 286N/A * empty string or is equal to this <code>String</code> object 286N/A * as determined by the {@link #equals(Object)} method. 286N/A * @exception java.lang.NullPointerException if <code>suffix</code> is 286N/A * Returns a hashcode for this string. The hashcode for a 286N/A * <code>String</code> object is computed as 286N/A * s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] 286N/A * using <code>int</code> arithmetic, where <code>s[i]</code> is the 286N/A * <i>i</i>th character of the string, <code>n</code> is the length of 286N/A * the string, and <code>^</code> indicates exponentiation. 286N/A * (The hash value of the empty string is zero.) 286N/A * @return a hash code value for this object. 286N/A * Returns the index within this string of the first occurrence of the 286N/A * specified character. If a character with value <code>ch</code> occurs 286N/A * in the character sequence represented by this <code>String</code> 286N/A * object, then the index of the first such occurrence is returned -- 286N/A * that is, the smallest value <i>k</i> such that: 286N/A * this.charAt(<i>k</i>) == ch 286N/A * is <code>true</code>. If no such character occurs in this string, 286N/A * then <code>-1</code> is returned. 286N/A * @param ch a character. 286N/A * @return the index of the first occurrence of the character in the 286N/A * character sequence represented by this object, or 286N/A * <code>-1</code> if the character does not occur. 286N/A * Returns the index within this string of the first occurrence of the 286N/A * specified character, starting the search at the specified index. 286N/A * If a character with value <code>ch</code> occurs in the character 286N/A * sequence represented by this <code>String</code> object at an index 286N/A * no smaller than <code>fromIndex</code>, then the index of the first 286N/A * such occurrence is returned--that is, the smallest value <i>k</i> 286N/A * (this.charAt(<i>k</i>) == ch) && (<i>k</i> >= fromIndex) 286N/A * is true. If no such character occurs in this string at or after 286N/A * position <code>fromIndex</code>, then <code>-1</code> is returned. 286N/A * There is no restriction on the value of <code>fromIndex</code>. If it 286N/A * is negative, it has the same effect as if it were zero: this entire 286N/A * string may be searched. If it is greater than the length of this 286N/A * string, it has the same effect as if it were equal to the length of 286N/A * this string: <code>-1</code> is returned. 286N/A * @param ch a character. 286N/A * @param fromIndex the index to start the search from. 286N/A * @return the index of the first occurrence of the character in the 286N/A * character sequence represented by this object that is greater 286N/A * than or equal to <code>fromIndex</code>, or <code>-1</code> 286N/A * if the character does not occur. 286N/A * Returns the index within this string of the last occurrence of the 286N/A * specified character. That is, the index returned is the largest 286N/A * value <i>k</i> such that: 286N/A * this.charAt(<i>k</i>) == ch 286N/A * The String is searched backwards starting at the last character. 286N/A * @param ch a character. 286N/A * @return the index of the last occurrence of the character in the 286N/A * character sequence represented by this object, or 286N/A * <code>-1</code> if the character does not occur. 286N/A * Returns the index within this string of the last occurrence of the 286N/A * specified character, searching backward starting at the specified 286N/A * index. That is, the index returned is the largest value <i>k</i> 286N/A * this.charAt(k) == ch) && (k <= fromIndex) 286N/A * @param ch a character. 286N/A * @param fromIndex the index to start the search from. There is no 286N/A * restriction on the value of <code>fromIndex</code>. If it is 286N/A * greater than or equal to the length of this string, it has 286N/A * the same effect as if it were equal to one less than the 286N/A * length of this string: this entire string may be searched. 286N/A * If it is negative, it has the same effect as if it were -1: 286N/A * @return the index of the last occurrence of the character in the 286N/A * character sequence represented by this object that is less 286N/A * than or equal to <code>fromIndex</code>, or <code>-1</code> 286N/A * if the character does not occur before that point. 286N/A * Returns the index within this string of the first occurrence of the 286N/A * specified substring. The integer returned is the smallest value 286N/A * this.startsWith(str, <i>k</i>) 286N/A * is <code>true</code>. 286N/A * @param str any string. 286N/A * @return if the string argument occurs as a substring within this 286N/A * object, then the index of the first character of the first 286N/A * such substring is returned; if it does not occur as a 286N/A * substring, <code>-1</code> is returned. 286N/A * @exception java.lang.NullPointerException if <code>str</code> is 286N/A * Returns the index within this string of the first occurrence of the 286N/A * specified substring. The integer returned is the smallest value 286N/A * this.startsWith(str, <i>k</i>) 286N/A * is <code>true</code>. 286N/A * @param str any string. 286N/A * @return if the string argument occurs as a substring within this 286N/A * object, then the index of the first character of the first 286N/A * such substring is returned; if it does not occur as a 286N/A * substring, <code>-1</code> is returned. 286N/A * @exception java.lang.NullPointerException if <code>str</code> is 286N/A * Returns the index within this string of the first occurrence of the 286N/A * specified substring, starting at the specified index. The integer 286N/A * returned is the smallest value <i>k</i> such that: 286N/A * this.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex) 286N/A * is <code>true</code>. 286N/A * There is no restriction on the value of <code>fromIndex</code>. If 286N/A * it is negative, it has the same effect as if it were zero: this entire 286N/A * string may be searched. If it is greater than the length of this 286N/A * string, it has the same effect as if it were equal to the length of 286N/A * this string: <code>-1</code> is returned. 286N/A * @param str the substring to search for. 286N/A * @param fromIndex the index to start the search from. 286N/A * @return If the string argument occurs as a substring within this 286N/A * object at a starting index no smaller than 286N/A * <code>fromIndex</code>, then the index of the first character 286N/A * of the first such substring is returned. If it does not occur 286N/A * as a substring starting at <code>fromIndex</code> or beyond, 286N/A * <code>-1</code> is returned. 286N/A * @exception java.lang.NullPointerException if <code>str</code> is 286N/A * Returns the index within this string of the rightmost occurrence 286N/A * of the specified substring. The rightmost empty string "" is 286N/A * considered to occur at the index value <code>this.length()</code>. 286N/A * The returned index is the largest value <i>k</i> such that 286N/A * this.startsWith(str, k) 286N/A * @param str the substring to search for. 286N/A * @return if the string argument occurs one or more times as a substring 286N/A * within this object, then the index of the first character of 286N/A * the last such substring is returned. If it does not occur as 286N/A * a substring, <code>-1</code> is returned. 286N/A * @exception java.lang.NullPointerException if <code>str</code> is 286N/A * Returns the index within this string of the last occurrence of 286N/A * the specified substring. 286N/A * @param str the substring to search for. 286N/A * @param fromIndex the index to start the search from. There is no 286N/A * restriction on the value of fromIndex. If it is greater than 286N/A * the length of this string, it has the same effect as if it 286N/A * were equal to the length of this string: this entire string 286N/A * may be searched. If it is negative, it has the same effect 286N/A * as if it were -1: -1 is returned. 286N/A * @return If the string argument occurs one or more times as a substring 286N/A * within this object at a starting index no greater than 286N/A * <code>fromIndex</code>, then the index of the first character of 286N/A * the last such substring is returned. If it does not occur as a 286N/A * substring starting at <code>fromIndex</code> or earlier, 286N/A * <code>-1</code> is returned. 286N/A * @exception java.lang.NullPointerException if <code>str</code> is 286N/A * Returns a new string that is a substring of this string. The 286N/A * substring begins with the character at the specified index and 286N/A * extends to the end of this string. <p> 286N/A * "unhappy".substring(2) returns "happy" 286N/A * "Harbison".substring(3) returns "bison" 286N/A * "emptiness".substring(9) returns "" (an empty string) 286N/A * @param beginIndex the beginning index, inclusive. 286N/A * @return the specified substring. 286N/A * @exception IndexOutOfBoundsException if 286N/A * <code>beginIndex</code> is negative or larger than the 286N/A * length of this <code>String</code> object. 286N/A * Returns a new string that is a substring of this string. The 286N/A * substring begins at the specified <code>beginIndex</code> and 286N/A * extends to the character at index <code>endIndex - 1</code>. 286N/A * Thus the length of the substring is <code>endIndex-beginIndex</code>. 286N/A * @param beginIndex the beginning index, inclusive. 286N/A * @param endIndex the ending index, exclusive. 286N/A * @return the specified substring. 286N/A * @exception IndexOutOfBoundsException if the 286N/A * <code>beginIndex</code> is negative, or 286N/A * <code>endIndex</code> is larger than the length of 286N/A * this <code>String</code> object, or 286N/A * <code>beginIndex</code> is larger than 286N/A * <code>endIndex</code>. 286N/A * Concatenates the specified string to the end of this string. 286N/A * @param str the <code>String</code> that is concatenated to the end 286N/A * of this <code>String</code>. 286N/A * @return a string that represents the concatenation of this object's 286N/A * characters followed by the string argument's characters. 286N/A * @exception java.lang.NullPointerException if <code>str</code> is 286N/A // %REVIEW% Make an FSB here? 286N/A * Converts all of the characters in this <code>String</code> to lower 286N/A * case using the rules of the given <code>Locale</code>. 286N/A * @param locale use the case transformation rules for this locale 286N/A * @return the String, converted to lowercase. 286N/A * @see java.lang.Character#toLowerCase(char) 286N/A * @see java.lang.String#toUpperCase(Locale) 286N/A * Converts all of the characters in this <code>String</code> to lower 286N/A * case using the rules of the default locale, which is returned 286N/A * by <code>Locale.getDefault</code>. 286N/A * @return the string, converted to lowercase. 286N/A * @see java.lang.Character#toLowerCase(char) 286N/A * @see java.lang.String#toLowerCase(Locale) 286N/A * Converts all of the characters in this <code>String</code> to upper 286N/A * case using the rules of the given locale. 286N/A * @param locale use the case transformation rules for this locale 286N/A * @return the String, converted to uppercase. 286N/A * @see java.lang.Character#toUpperCase(char) 286N/A * @see java.lang.String#toLowerCase(Locale) 286N/A * Converts all of the characters in this <code>String</code> to upper 286N/A * case using the rules of the default locale, which is returned 286N/A * by <code>Locale.getDefault</code>. 286N/A * If no character in this string has a different uppercase version, 286N/A * based on calling the <code>toUpperCase</code> method defined by 286N/A * <code>Character</code>, then the original string is returned. 286N/A * Otherwise, this method creates a new <code>String</code> object 286N/A * representing a character sequence identical in length to the 286N/A * character sequence represented by this <code>String</code> object and 286N/A * with every character equal to the result of applying the method 286N/A * <code>Character.toUpperCase</code> to the corresponding character of 286N/A * this <code>String</code> object. <p> 286N/A * "Fahrvergnügen".toUpperCase() returns "FAHRVERGNÜGEN" 286N/A * "Visit Ljubinje!".toUpperCase() returns "VISIT LJUBINJE!" 286N/A * @return the string, converted to uppercase. 286N/A * @see java.lang.Character#toUpperCase(char) 286N/A * @see java.lang.String#toUpperCase(Locale) 286N/A * Removes white space from both ends of this string. 286N/A * @return this string, with white space removed from the front and end. 286N/A * Returns whether the specified <var>ch</var> conforms to the XML 1.0 definition 286N/A * the definition of <CODE>S</CODE></A> for details. 286N/A * @param ch Character to check as XML whitespace. 286N/A * @return =true if <var>ch</var> is XML whitespace; otherwise =false. 286N/A * Conditionally trim all leading and trailing whitespace in the specified String. 286N/A * All strings of white space are 286N/A * replaced by a single space character (#x20), except spaces after punctuation which 286N/A * receive double spaces if doublePunctuationSpaces is true. 286N/A * This function may be useful to a formatter, but to get first class 286N/A * results, the formatter should probably do it's own white space handling 286N/A * based on the semantics of the formatting object. 286N/A * @param trimHead Trim leading whitespace? 286N/A * @param trimTail Trim trailing whitespace? 286N/A * @param doublePunctuationSpaces Use double spaces for punctuation? 286N/A * @return The trimmed string. 286N/A /* replace S to ' '. and ' '+ -> single ' '. */ 286N/A * @see com.sun.org.apache.xpath.internal.XPathVisitable#callVisitors(ExpressionOwner, XPathVisitor)