1 7 package javax.swing.text.rtf; 8 9 import java.util.Dictionary ; 10 import java.util.Enumeration ; 11 import javax.swing.text.AttributeSet ; 12 import javax.swing.text.MutableAttributeSet ; 13 14 15 17 class MockAttributeSet 18 implements AttributeSet , MutableAttributeSet 19 { 20 public Dictionary backing; 21 22 public boolean isEmpty() 23 { 24 return backing.isEmpty(); 25 } 26 27 public int getAttributeCount() 28 { 29 return backing.size(); 30 } 31 32 public boolean isDefined(Object name) 33 { 34 return ( backing.get(name) ) != null; 35 } 36 37 public boolean isEqual(AttributeSet attr) 38 { 39 throw new InternalError ("MockAttributeSet: charade revealed!"); 40 } 41 42 public AttributeSet copyAttributes() 43 { 44 throw new InternalError ("MockAttributeSet: charade revealed!"); 45 } 46 47 public Object getAttribute(Object name) 48 { 49 return backing.get(name); 50 } 51 52 public void addAttribute(Object name, Object value) 53 { 54 backing.put(name, value); 55 } 56 57 public void addAttributes(AttributeSet attr) 58 { 59 Enumeration as = attr.getAttributeNames(); 60 while(as.hasMoreElements()) { 61 Object el = as.nextElement(); 62 backing.put(el, attr.getAttribute(el)); 63 } 64 } 65 66 public void removeAttribute(Object name) 67 { 68 backing.remove(name); 69 } 70 71 public void removeAttributes(AttributeSet attr) 72 { 73 throw new InternalError ("MockAttributeSet: charade revealed!"); 74 } 75 76 public void removeAttributes(Enumeration <?> en) 77 { 78 throw new InternalError ("MockAttributeSet: charade revealed!"); 79 } 80 81 public void setResolveParent(AttributeSet pp) 82 { 83 throw new InternalError ("MockAttributeSet: charade revealed!"); 84 } 85 86 87 public Enumeration getAttributeNames() 88 { 89 return backing.keys(); 90 } 91 92 public boolean containsAttribute(Object name, Object value) 93 { 94 throw new InternalError ("MockAttributeSet: charade revealed!"); 95 } 96 97 public boolean containsAttributes(AttributeSet attr) 98 { 99 throw new InternalError ("MockAttributeSet: charade revealed!"); 100 } 101 102 public AttributeSet getResolveParent() 103 { 104 throw new InternalError ("MockAttributeSet: charade revealed!"); 105 } 106 } 107 108 109 | Popular Tags |