1 7 8 package javax.swing.text.html.parser; 9 10 import java.util.Hashtable ; 11 import java.util.BitSet ; 12 import java.io.*; 13 14 25 public final 26 class Element implements DTDConstants , Serializable { 27 public int index; 28 public String name; 29 public boolean oStart; 30 public boolean oEnd; 31 public BitSet inclusions; 32 public BitSet exclusions; 33 public int type = ANY; 34 public ContentModel content; 35 public AttributeList atts; 36 37 static int maxIndex = 0; 38 39 43 public Object data; 44 45 Element() { 46 } 47 48 51 Element(String name, int index) { 52 this.name = name; 53 this.index = index; 54 maxIndex = Math.max(maxIndex, index); 55 } 56 57 60 public String getName() { 61 return name; 62 } 63 64 67 public boolean omitStart() { 68 return oStart; 69 } 70 71 74 public boolean omitEnd() { 75 return oEnd; 76 } 77 78 81 public int getType() { 82 return type; 83 } 84 85 88 public ContentModel getContent() { 89 return content; 90 } 91 92 95 public AttributeList getAttributes() { 96 return atts; 97 } 98 99 102 public int getIndex() { 103 return index; 104 } 105 106 109 public boolean isEmpty() { 110 return type == EMPTY; 111 } 112 113 116 public String toString() { 117 return name; 118 } 119 120 123 public AttributeList getAttribute(String name) { 124 for (AttributeList a = atts ; a != null ; a = a.next) { 125 if (a.name.equals(name)) { 126 return a; 127 } 128 } 129 return null; 130 } 131 132 135 public AttributeList getAttributeByValue(String name) { 136 for (AttributeList a = atts ; a != null ; a = a.next) { 137 if ((a.values != null) && a.values.contains(name)) { 138 return a; 139 } 140 } 141 return null; 142 } 143 144 145 static Hashtable contentTypes = new Hashtable (); 146 147 static { 148 contentTypes.put("CDATA", new Integer (CDATA)); 149 contentTypes.put("RCDATA", new Integer (RCDATA)); 150 contentTypes.put("EMPTY", new Integer (EMPTY)); 151 contentTypes.put("ANY", new Integer (ANY)); 152 } 153 154 public static int name2type(String nm) { 155 Integer val = (Integer )contentTypes.get(nm); 156 return (val != null) ? val.intValue() : 0; 157 } 158 } 159 | Popular Tags |