1 16 package com.google.gwt.xml.client.impl; 17 18 import com.google.gwt.core.client.JavaScriptException; 19 import com.google.gwt.core.client.JavaScriptObject; 20 import com.google.gwt.xml.client.DOMException; 21 import com.google.gwt.xml.client.Text; 22 23 26 class TextImpl extends CharacterDataImpl implements Text { 27 28 protected TextImpl(JavaScriptObject o) { 29 super(o); 30 } 31 32 36 public Text splitText(int offset) { 37 try { 38 return (Text) NodeImpl.build(XMLParserImpl.splitText(this.getJsObject(), 39 offset)); 40 } catch (JavaScriptException e) { 41 throw new DOMNodeException(DOMException.INVALID_MODIFICATION_ERR, e, this); 42 } 43 } 44 45 public String toString() { 46 StringBuffer b = new StringBuffer (); 47 String [] x = getData().split("(?=[;&<>\'\"])", -1); 48 for (int i = 0; i < x.length; i++) { 49 if (x[i].startsWith(";")) { 50 b.append(";"); 51 b.append(x[i].substring(1)); 52 } else if (x[i].startsWith("&")) { 53 b.append("&"); 54 b.append(x[i].substring(1)); 55 } else if (x[i].startsWith("\"")) { 56 b.append("""); 57 b.append(x[i].substring(1)); 58 } else if (x[i].startsWith("'")) { 59 b.append("'"); 60 b.append(x[i].substring(1)); 61 } else if (x[i].startsWith("<")) { 62 b.append("<"); 63 b.append(x[i].substring(1)); 64 } else if (x[i].startsWith(">")) { 65 b.append(">"); 66 b.append(x[i].substring(1)); 67 } else { 68 b.append(x[i]); 69 } 70 } 71 return b.toString(); 72 } 73 } 74 | Popular Tags |