1 package bplatt.spider; 2 3 22 23 import java.io.*; 24 25 public class SimpleHTMLToken { 26 public static final int TAG = 0; 27 public static final int ENDTAG = 1; 28 public static final int CONTENT = 2; 29 private static final int UNDEFINED = -1; 30 31 private int type; 32 private String content; 33 34 37 public SimpleHTMLToken() { 38 type = UNDEFINED; 39 content = null; 40 } 41 42 45 public SimpleHTMLToken(int type, String content) { 46 this.type = type; 47 this.content = content; 48 } 49 50 54 public String getContent() { 55 return content; 56 } 57 58 62 public int getType() { 63 return type; 64 } 65 66 70 public void setContent(String content) { 71 this.content = content; 72 } 73 74 78 public void setType(int type) { 79 this.type = type; 80 } 81 82 85 public void dump(PrintStream out) 86 { 87 switch(type) { 88 case UNDEFINED: out.println("Error!"); 89 break; 90 case TAG: out.println("<" + content + ">"); 91 break; 92 case ENDTAG: out.println("</"+ content + ">"); 93 break; 94 case CONTENT: out.println("\"" + content + "\""); 95 break; 96 default: out.println("Error!"); 97 break; 98 } 99 100 } 101 } 102 | Popular Tags |