// Read until the first start element
while (reader.hasNext() && reader.next() != START_ELEMENT) {
// checkstyle
}
WebFragmentMetaData wmd = new WebFragment30MetaData();
// 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: {
wmd.setId(value);
break;
}
case VERSION: {
wmd.setVersion(value);
break;
}
case METADATA_COMPLETE: {
if (Boolean.TRUE.equals(Boolean.valueOf(value))) {
wmd.setMetadataComplete(true);
}
break;
}
default: throw unexpectedAttribute(reader, i);
}
}
DescriptionGroupMetaData descriptionGroup = new DescriptionGroupMetaData();
EnvironmentRefsGroupMetaData env = new EnvironmentRefsGroupMetaData();
// Handle elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
if (WebCommonMetaDataParser.parse(reader, wmd)) {
continue;
}
if (EnvironmentRefsGroupMetaDataParser.parse(reader, env)) {
if (wmd.getJndiEnvironmentRefsGroup() == null) {
wmd.setJndiEnvironmentRefsGroup(env);
}
continue;
}
if (DescriptionGroupMetaDataParser.parse(reader, descriptionGroup)) {
if (wmd.getDescriptionGroup() == null) {
wmd.setDescriptionGroup(descriptionGroup);
}
continue;
}
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case NAME:
wmd.setName(reader.getElementText());
break;
case ORDERING:
wmd.setOrdering(OrderingMetaDataParser.parse(reader));
break;
default: throw unexpectedElement(reader);
}
}