1 7 8 package javax.swing.text.html.parser; 9 10 import java.util.Hashtable ; 11 import java.io.IOException ; 12 import java.io.InputStream ; 13 import java.io.InputStreamReader ; 14 import java.io.Reader ; 15 import java.io.CharArrayReader ; 16 import java.net.URL ; 17 18 26 public final 27 class Entity implements DTDConstants { 28 public String name; 29 public int type; 30 public char data[]; 31 32 38 public Entity(String name, int type, char data[]) { 39 this.name = name; 40 this.type = type; 41 this.data = data; 42 } 43 44 48 public String getName() { 49 return name; 50 } 51 52 56 public int getType() { 57 return type & 0xFFFF; 58 } 59 60 64 public boolean isParameter() { 65 return (type & PARAMETER) != 0; 66 } 67 68 72 public boolean isGeneral() { 73 return (type & GENERAL) != 0; 74 } 75 76 80 public char getData()[] { 81 return data; 82 } 83 84 88 public String getString() { 89 return new String (data, 0, data.length); 90 } 91 92 93 static Hashtable entityTypes = new Hashtable (); 94 95 static { 96 entityTypes.put("PUBLIC", new Integer (PUBLIC)); 97 entityTypes.put("CDATA", new Integer (CDATA)); 98 entityTypes.put("SDATA", new Integer (SDATA)); 99 entityTypes.put("PI", new Integer (PI)); 100 entityTypes.put("STARTTAG", new Integer (STARTTAG)); 101 entityTypes.put("ENDTAG", new Integer (ENDTAG)); 102 entityTypes.put("MS", new Integer (MS)); 103 entityTypes.put("MD", new Integer (MD)); 104 entityTypes.put("SYSTEM", new Integer (SYSTEM)); 105 } 106 107 118 public static int name2type(String nm) { 119 Integer i = (Integer )entityTypes.get(nm); 120 return (i == null) ? CDATA : i.intValue(); 121 } 122 } 123 124 | Popular Tags |