1 16 19 package org.apache.xml.utils; 20 21 import java.util.Locale ; 22 23 27 public class XMLStringDefault implements XMLString 28 { 29 30 private String m_str; 31 32 35 public XMLStringDefault(String str) 36 { 37 m_str = str; 38 } 39 40 51 public void dispatchCharactersEvents(org.xml.sax.ContentHandler ch) 52 throws org.xml.sax.SAXException 53 { 54 } 55 56 65 public void dispatchAsComment(org.xml.sax.ext.LexicalHandler lh) 66 throws org.xml.sax.SAXException 67 { 68 } 69 70 84 public XMLString fixWhiteSpace(boolean trimHead, 85 boolean trimTail, 86 boolean doublePunctuationSpaces) 87 { 88 return new XMLStringDefault(m_str.trim()); 89 } 90 91 97 public int length() 98 { 99 return m_str.length(); 100 } 101 102 115 public char charAt(int index) 116 { 117 return m_str.charAt(index); 118 } 119 120 141 public void getChars(int srcBegin, int srcEnd, char dst[], 142 int dstBegin) 143 { 144 int destIndex = dstBegin; 145 for (int i = srcBegin; i < srcEnd; i++) 146 { 147 dst[destIndex++] = m_str.charAt(i); 148 } 149 } 150 151 164 public boolean equals(XMLString anObject) 165 { 166 return m_str.equals(anObject.toString()); 167 } 168 169 170 183 public boolean equals(Object anObject) 184 { 185 return m_str.equals(anObject); 186 } 187 188 203 public boolean equalsIgnoreCase(String anotherString) 204 { 205 return m_str.equalsIgnoreCase(anotherString); 206 } 207 208 220 public int compareTo(XMLString anotherString) 221 { 222 return m_str.compareTo(anotherString.toString()); 223 } 224 225 243 public int compareToIgnoreCase(XMLString str) 244 { 245 return m_str.compareToIgnoreCase(str.toString()); 246 } 247 248 267 public boolean startsWith(String prefix, int toffset) 268 { 269 return m_str.startsWith(prefix, toffset); 270 } 271 272 291 public boolean startsWith(XMLString prefix, int toffset) 292 { 293 return m_str.startsWith(prefix.toString(), toffset); 294 } 295 296 311 public boolean startsWith(String prefix) 312 { 313 return m_str.startsWith(prefix); 314 } 315 316 331 public boolean startsWith(XMLString prefix) 332 { 333 return m_str.startsWith(prefix.toString()); 334 } 335 336 349 public boolean endsWith(String suffix) 350 { 351 return m_str.endsWith(suffix); 352 } 353 354 367 public int hashCode() 368 { 369 return m_str.hashCode(); 370 } 371 372 389 public int indexOf(int ch) 390 { 391 return m_str.indexOf(ch); 392 } 393 394 422 public int indexOf(int ch, int fromIndex) 423 { 424 return m_str.indexOf(ch, fromIndex); 425 } 426 427 442 public int lastIndexOf(int ch) 443 { 444 return m_str.lastIndexOf(ch); 445 } 446 447 470 public int lastIndexOf(int ch, int fromIndex) 471 { 472 return m_str.lastIndexOf(ch, fromIndex); 473 } 474 475 492 public int indexOf(String str) 493 { 494 return m_str.indexOf(str); 495 } 496 497 514 public int indexOf(XMLString str) 515 { 516 return m_str.indexOf(str.toString()); 517 } 518 519 545 public int indexOf(String str, int fromIndex) 546 { 547 return m_str.indexOf(str, fromIndex); 548 } 549 550 568 public int lastIndexOf(String str) 569 { 570 return m_str.lastIndexOf(str); 571 } 572 573 593 public int lastIndexOf(String str, int fromIndex) 594 { 595 return m_str.lastIndexOf(str, fromIndex); 596 } 597 598 615 public XMLString substring(int beginIndex) 616 { 617 return new XMLStringDefault(m_str.substring(beginIndex)); 618 } 619 620 636 public XMLString substring(int beginIndex, int endIndex) 637 { 638 return new XMLStringDefault(m_str.substring(beginIndex, endIndex)); 639 } 640 641 651 public XMLString concat(String str) 652 { 653 return new XMLStringDefault(m_str.concat(str)); 654 } 655 656 665 public XMLString toLowerCase(Locale locale) 666 { 667 return new XMLStringDefault(m_str.toLowerCase(locale)); 668 } 669 670 680 public XMLString toLowerCase() 681 { 682 return new XMLStringDefault(m_str.toLowerCase()); 683 } 684 685 693 public XMLString toUpperCase(Locale locale) 694 { 695 return new XMLStringDefault(m_str.toUpperCase(locale)); 696 } 697 698 724 public XMLString toUpperCase() 725 { 726 return new XMLStringDefault(m_str.toUpperCase()); 727 } 728 729 758 public XMLString trim() 759 { 760 return new XMLStringDefault(m_str.trim()); 761 } 762 763 768 public String toString() 769 { 770 return m_str; 771 } 772 773 778 public boolean hasString() 779 { 780 return true; 781 } 782 783 790 public double toDouble() 791 { 792 try { 793 return Double.valueOf(m_str).doubleValue(); 794 } 795 catch (NumberFormatException nfe) 796 { 797 return Double.NaN; 798 } 799 } 800 } 801 | Popular Tags |