1 16 17 package org.apache.xerces.util; 18 19 import org.apache.xerces.impl.Constants; 20 import org.apache.xerces.xni.XMLAttributes; 21 import org.xml.sax.AttributeList ; 22 import org.xml.sax.ext.Attributes2 ; 23 24 33 public final class AttributesProxy 34 implements AttributeList , Attributes2 { 35 36 40 41 private XMLAttributes fAttributes; 42 43 47 public AttributesProxy(XMLAttributes attributes) { 48 fAttributes = attributes; 49 } 50 51 55 56 public void setAttributes(XMLAttributes attributes) { 57 fAttributes = attributes; 58 } 60 public XMLAttributes getAttributes() { 61 return fAttributes; 62 } 63 64 67 68 public int getLength() { 69 return fAttributes.getLength(); 70 } 71 72 public String getQName(int index) { 73 return fAttributes.getQName(index); 74 } 75 76 public String getURI(int index) { 77 String uri = fAttributes.getURI(index); 80 return uri != null ? uri : XMLSymbols.EMPTY_STRING; 81 } 82 83 public String getLocalName(int index) { 84 return fAttributes.getLocalName(index); 85 } 86 87 public String getType(int i) { 88 return fAttributes.getType(i); 89 } 90 91 public String getType(String name) { 92 return fAttributes.getType(name); 93 } 94 95 public String getType(String uri, String localName) { 96 return uri.equals(XMLSymbols.EMPTY_STRING) ? 97 fAttributes.getType(null, localName) : 98 fAttributes.getType(uri, localName); 99 } 100 101 public String getValue(int i) { 102 return fAttributes.getValue(i); 103 } 104 105 public String getValue(String name) { 106 return fAttributes.getValue(name); 107 } 108 109 public String getValue(String uri, String localName) { 110 return uri.equals(XMLSymbols.EMPTY_STRING) ? 111 fAttributes.getValue(null, localName) : 112 fAttributes.getValue(uri, localName); 113 } 114 115 public int getIndex(String qName) { 116 return fAttributes.getIndex(qName); 117 } 118 119 public int getIndex(String uri, String localPart) { 120 return uri.equals(XMLSymbols.EMPTY_STRING) ? 121 fAttributes.getIndex(null, localPart) : 122 fAttributes.getIndex(uri, localPart); 123 } 124 125 128 129 public boolean isDeclared(int index) { 130 if (index < 0 || index >= fAttributes.getLength()) { 131 throw new ArrayIndexOutOfBoundsException (index); 132 } 133 return Boolean.TRUE.equals( 134 fAttributes.getAugmentations(index).getItem( 135 Constants.ATTRIBUTE_DECLARED)); 136 } 137 138 public boolean isDeclared(String qName) { 139 int index = getIndex(qName); 140 if (index == -1) { 141 throw new IllegalArgumentException (qName); 142 } 143 return Boolean.TRUE.equals( 144 fAttributes.getAugmentations(index).getItem( 145 Constants.ATTRIBUTE_DECLARED)); 146 } 147 148 public boolean isDeclared(String uri, String localName) { 149 int index = getIndex(uri, localName); 150 if (index == -1) { 151 throw new IllegalArgumentException (localName); 152 } 153 return Boolean.TRUE.equals( 154 fAttributes.getAugmentations(index).getItem( 155 Constants.ATTRIBUTE_DECLARED)); 156 } 157 158 public boolean isSpecified(int index) { 159 if (index < 0 || index >= fAttributes.getLength()) { 160 throw new ArrayIndexOutOfBoundsException (index); 161 } 162 return fAttributes.isSpecified(index); 163 } 164 165 public boolean isSpecified(String qName) { 166 int index = getIndex(qName); 167 if (index == -1) { 168 throw new IllegalArgumentException (qName); 169 } 170 return fAttributes.isSpecified(index); 171 } 172 173 public boolean isSpecified(String uri, String localName) { 174 int index = getIndex(uri, localName); 175 if (index == -1) { 176 throw new IllegalArgumentException (localName); 177 } 178 return fAttributes.isSpecified(index); 179 } 180 181 184 185 public String getName(int i) { 186 return fAttributes.getQName(i); 187 } 188 189 } | Popular Tags |