private void readRequirementElement(XMLStreamReader reader, XResourceBuilder<XResource> builder) throws XMLStreamException { String namespace = reader.getAttributeValue(null, Attribute.NAMESPACE.toString()); Map<String, Object> atts = new HashMap<String, Object>(); Map<String, String> dirs = new HashMap<String, String>(); readAttributesAndDirectives(reader, atts, dirs); try { builder.addRequirement(namespace, atts, dirs); } catch (RuntimeException ex) { throw MESSAGES.cannotReadResourceElement(ex, reader.getLocation()); } }
private void readCapabilityElement(XMLStreamReader reader, XResourceBuilder<XResource> builder) throws XMLStreamException { String namespace = reader.getAttributeValue(null, Attribute.NAMESPACE.toString()); Map<String, Object> atts = new HashMap<String, Object>(); Map<String, String> dirs = new HashMap<String, String>(); readAttributesAndDirectives(reader, atts, dirs); try { builder.addCapability(namespace, atts, dirs); } catch (RuntimeException ex) { throw MESSAGES.cannotReadResourceElement(ex, reader.getLocation()); } }
@Override public XResource nextResource() { try { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { Element element = Element.forName(reader.getLocalName()); switch (element) { case RESOURCE: { return readResourceElement(reader); } } } } catch (XMLStreamException ex) { throw MESSAGES.cannotReadResourceElement(ex, reader.getLocation()); } return null; }
private RepositoryXMLReader(InputStream input) { try { reader = XMLInputFactory.newInstance().createXMLStreamReader(input); } catch (Exception ex) { throw MESSAGES.cannotInitializeRepositoryReader(ex); } try { reader.require(START_DOCUMENT, null, null); reader.nextTag(); reader.require(START_ELEMENT, REPOSITORY_NAMESPACE, REPOSITORY.getLocalName()); for (int i = 0; i < reader.getAttributeCount(); i++) { attributes.put(reader.getAttributeLocalName(i), reader.getAttributeValue(i)); } } catch (Exception ex) { throw MESSAGES.cannotReadResourceElement(ex, reader.getLocation()); } }