}
private CategoriesImpl parseCategories(final XMLStreamReader reader) throws XMLStreamException,
EntityProviderException {
reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_APP_2007, FormatXml.APP_CATEGORIES);
CategoriesImpl categories = new CategoriesImpl();
String href = reader.getAttributeValue(null, FormatXml.ATOM_HREF);
String fixed = reader.getAttributeValue(null, FormatXml.APP_CATEGORIES_FIXED);
categories.setScheme(reader.getAttributeValue(null, FormatXml.APP_CATEGORIES_SCHEME));
categories.setHref(href);
if (href == null) {
for (int i = 0; i < Fixed.values().length; i++) {
if (Fixed.values()[i].name().equalsIgnoreCase(fixed)) {
categories.setFixed(Fixed.values()[i]);
}
}
if (categories.getFixed() == null) {
categories.setFixed(Fixed.NO);
}
List<Category> categoriesList = new ArrayList<Category>();
while (reader.hasNext()
&& !(reader.isEndElement() && Edm.NAMESPACE_APP_2007.equals(reader.getNamespaceURI())
&& FormatXml.APP_CATEGORIES.equals(reader.getLocalName()))) {
reader.next();
if (reader.isStartElement()) {
currentHandledStartTagName = reader.getLocalName();
if (FormatXml.ATOM_CATEGORY.equals(currentHandledStartTagName)) {
categoriesList.add(parseCategory(reader));
}
}
}
categories.setCategoryList(categoriesList);
}
if ((href != null && fixed != null && categories.getScheme() != null) ||
(href == null && fixed == null && categories.getScheme() == null)) {
throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE
.addContent("for the element categories"));
}
return categories;
}