1 29 30 package com.caucho.relaxng.program; 31 32 import com.caucho.relaxng.RelaxException; 33 import com.caucho.util.L10N; 34 import com.caucho.xml.QName; 35 36 import java.util.HashSet ; 37 38 41 public class AttributeItem extends Item { 42 protected final static L10N L = new L10N(AttributeItem.class); 43 44 private final NameClassItem _name; 45 46 public AttributeItem(NameClassItem name) 47 { 48 _name = name; 49 } 50 51 public NameClassItem getNameClassItem() 52 { 53 return _name; 54 } 55 56 59 public void firstSet(HashSet <QName> set) 60 { 61 } 62 63 66 public boolean allowEmpty() 67 { 68 return false; 69 } 70 71 74 public void attributeSet(HashSet <QName> set) 75 { 76 _name.firstSet(set); 77 } 78 79 84 public boolean allowAttribute(QName name, String value) 85 throws RelaxException 86 { 87 return _name.matches(name); 88 } 89 90 96 public Item setAttribute(QName name, String value) 97 throws RelaxException 98 { 99 if (_name.matches(name)) 100 return null; 101 else 102 return this; 103 } 104 105 109 public Item attributeEnd() 110 { 111 return null; 112 } 113 114 117 public String toSyntaxDescription(int depth) 118 { 119 return _name.toSyntaxDescription("@"); 120 } 121 122 125 protected boolean isSimpleSyntax() 126 { 127 return true; 128 } 129 130 133 public int hashCode() 134 { 135 return 27 + _name.hashCode(); 136 } 137 138 141 public boolean equals(Object o) 142 { 143 if (this == o) 144 return true; 145 146 if (! (o instanceof AttributeItem)) 147 return false; 148 149 AttributeItem attr = (AttributeItem) o; 150 151 return _name.equals(attr._name); 152 } 153 154 public String toString() 155 { 156 return "AttributeItem[" + _name + "]"; 157 } 158 } 159 160 | Popular Tags |