1 27 package org.htmlparser.nodes; 28 29 import java.io.Serializable ; 30 31 import org.htmlparser.Node; 32 import org.htmlparser.NodeFilter; 33 import org.htmlparser.lexer.Page; 34 import org.htmlparser.util.NodeList; 35 import org.htmlparser.util.ParserException; 36 import org.htmlparser.visitors.NodeVisitor; 37 38 41 public abstract class AbstractNode implements Node, Serializable 42 { 43 46 protected Page mPage; 47 48 51 protected int nodeBegin; 52 53 56 protected int nodeEnd; 57 58 61 protected Node parent; 62 63 66 protected NodeList children; 67 68 75 public AbstractNode (Page page, int start, int end) 76 { 77 mPage = page; 78 nodeBegin = start; 79 nodeEnd = end; 80 parent = null; 81 children = null; 82 } 83 84 91 public Object clone() throws CloneNotSupportedException 92 { 93 return (super.clone ()); 94 } 95 96 108 public abstract String toPlainTextString(); 109 110 115 public abstract String toHtml(); 116 117 123 public abstract String toString(); 124 125 158 public void collectInto (NodeList list, NodeFilter filter) 159 { 160 if (filter.accept (this)) 161 list.add (this); 162 } 163 164 168 public int elementBegin() 169 { 170 return (getStartPosition ()); 171 } 172 173 177 public int elementEnd() 178 { 179 return (getEndPosition ()); 180 } 181 182 186 public Page getPage () 187 { 188 return (mPage); 189 } 190 191 195 public void setPage (Page page) 196 { 197 mPage = page; 198 } 199 200 204 public int getStartPosition () 205 { 206 return (nodeBegin); 207 } 208 209 213 public void setStartPosition (int position) 214 { 215 nodeBegin = position; 216 } 217 218 222 public int getEndPosition () 223 { 224 return (nodeEnd); 225 } 226 227 231 public void setEndPosition (int position) 232 { 233 nodeEnd = position; 234 } 235 236 public abstract void accept (NodeVisitor visitor); 237 238 241 public final String toHTML() { 242 return toHtml(); 243 } 244 245 252 public Node getParent () 253 { 254 return (parent); 255 } 256 257 261 public void setParent (Node node) 262 { 263 parent = node; 264 } 265 266 270 public NodeList getChildren () 271 { 272 return (children); 273 } 274 275 279 public void setChildren (NodeList children) 280 { 281 this.children = children; 282 } 283 284 287 public String getText() { 288 return null; 289 } 290 291 295 public void setText(String text) { 296 297 } 298 299 303 public void doSemanticAction () throws ParserException 304 { 305 } 306 } 307 | Popular Tags |