* @author Remy Maucherat
*/
public class IconMetaDataParser extends MetaDataElementParser {
public static IconImpl parse(XMLStreamReader reader) throws XMLStreamException {
IconImpl icon = new IconImpl();
// 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: {
icon.setId(value);
break;
}
case LANG: {
icon.setLanguage(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 SMALL_ICON:
icon.setSmallIcon(reader.getElementText());
break;
case LARGE_ICON:
icon.setLargeIcon(reader.getElementText());
break;
default: throw unexpectedElement(reader);
}
}
return icon;