1 21 24 package org.lobobrowser.html.domimpl; 25 26 import org.w3c.dom.*; 27 28 public abstract class CharacterDataImpl extends NodeImpl implements 29 CharacterData { 30 protected volatile String text; 31 32 public CharacterDataImpl() { 33 super(); 34 } 35 36 public CharacterDataImpl(String text) { 37 this.text = text; 38 } 39 40 public String getClassName() { 41 return "HTMLCharacterData"; 42 } 43 44 public String getTextContent() throws DOMException { 45 return this.text; 46 } 47 48 public void setTextContent(String textContent) throws DOMException { 49 this.text = textContent; 50 if(!this.notificationsSuspended) { 51 this.informInvalid(); 52 } 53 } 54 55 58 public Node cloneNode(boolean deep) { 59 CharacterDataImpl newNode = (CharacterDataImpl) super.cloneNode(deep); 60 newNode.setData(this.getData()); 61 return newNode; 62 } 63 64 65 public void appendData(String arg) throws DOMException { 66 this.text += arg; 67 if(!this.notificationsSuspended) { 68 this.informInvalid(); 69 } 70 } 71 72 public void deleteData(int offset, int count) 73 throws DOMException { 74 StringBuffer buffer = new StringBuffer (this.text); 75 StringBuffer result = buffer.delete(offset, offset + count); 76 this.text = result.toString(); 77 if(!this.notificationsSuspended) { 78 this.informInvalid(); 79 } 80 } 81 82 public String getData() throws DOMException { 83 return this.text; 84 } 85 86 public int getLength() { 87 return this.text.length(); 88 } 89 90 public void insertData(int offset, String arg) 91 throws DOMException { 92 StringBuffer buffer = new StringBuffer (this.text); 93 StringBuffer result = buffer.insert(offset, arg); 94 this.text = result.toString(); 95 if(!this.notificationsSuspended) { 96 this.informInvalid(); 97 } 98 } 99 100 public void replaceData(int offset, int count, String arg) 101 throws DOMException { 102 StringBuffer buffer = new StringBuffer (this.text); 103 StringBuffer result = buffer.replace(offset, offset + count, arg); 104 this.text = result.toString(); 105 if(!this.notificationsSuspended) { 106 this.informInvalid(); 107 } 108 } 109 110 public void setData(String data) throws DOMException { 111 this.text = data; 112 if(!this.notificationsSuspended) { 113 this.informInvalid(); 114 } 115 } 116 117 public String substringData(int offset, int count) 118 throws DOMException { 119 return this.text.substring(offset, offset + count); 120 } 121 122 public String toString() { 123 String someText = this.text; 124 int length = someText.length(); 125 if(someText != null && someText.length() > 32) { 126 someText = someText.substring(0, 29) + "..."; 127 } 128 return this.getNodeName() + "[length=" + length + ",text=" + someText + "]"; 129 } 130 131 } 132 | Popular Tags |