1 38 39 40 package com.sun.xml.fastinfoset.stax.events ; 41 42 import javax.xml.stream.events.Characters; 43 import javax.xml.stream.XMLStreamConstants; 44 import com.sun.xml.fastinfoset.util.XMLChar; 45 import com.sun.xml.fastinfoset.util.Util; 46 47 public class CharactersEvent extends EventBase implements Characters { 48 private String _text; 49 private boolean isCData=false; 50 private boolean isSpace=false; 51 private boolean isIgnorable=false; 52 private boolean needtoCheck = true; 53 54 public CharactersEvent() { 55 super(CHARACTERS); 56 } 57 61 public CharactersEvent(String data) { 62 super(CHARACTERS); 63 _text = data; 64 } 65 66 71 public CharactersEvent(String data, boolean isCData) { 72 super(CHARACTERS); 73 _text = data; 74 this.isCData = isCData; 75 } 76 77 80 public String getData() { 81 return _text; 82 } 83 84 public void setData(String data){ 85 _text = data; 86 } 87 88 92 public boolean isCData() { 93 return isCData; 94 } 95 96 100 public String toString() { 101 if(isCData) 102 return "<![CDATA[" + _text + "]]>"; 103 else 104 return _text; 105 } 106 107 113 public boolean isIgnorableWhiteSpace() { 114 return isIgnorable; 115 } 116 117 123 public boolean isWhiteSpace() { 124 if(needtoCheck){ 126 checkWhiteSpace(); 127 needtoCheck = false; 128 } 129 return isSpace; 130 } 131 132 public void setSpace(boolean isSpace) { 133 this.isSpace = isSpace; 134 needtoCheck = false; 135 } 136 public void setIgnorable(boolean isIgnorable){ 137 this.isIgnorable = isIgnorable; 138 setEventType(SPACE); 139 } 140 private void checkWhiteSpace(){ 141 if(!Util.isEmptyString(_text)){ 143 isSpace = true; 144 for(int i=0;i<_text.length();i++){ 145 if(!XMLChar.isSpace(_text.charAt(i))){ 146 isSpace = false; 147 break; 148 } 149 } 150 } 151 } 152 } 153 | Popular Tags |