* @author Remy Maucherat
*/
public class TaglibMetaDataParser extends MetaDataElementParser {
public static TaglibMetaData parse(XMLStreamReader reader) throws XMLStreamException {
TaglibMetaData taglib = new TaglibMetaData();
// Handle attributes
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i ++) {
final String value = reader.getAttributeValue(i);
if (reader.getAttributeNamespace(i) != null) {
continue;
}
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case ID: {
taglib.setId(value);
break;
}
default: throw unexpectedAttribute(reader, i);
}
}
// Handle elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case TAGLIB_URI:
taglib.setTaglibUri(reader.getElementText());
break;
case TAGLIB_LOCATION:
taglib.setTaglibLocation(reader.getElementText());
break;
default: throw unexpectedElement(reader);
}
}