this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.class);
}
public Definitions read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
QName name = null;
Definitions definitions = null;
String targetNamespace = null;
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT: {
name = reader.getName();
if (DEFINITIONS_QNAME.equals(name)) {
definitions = definitionsFactory.createDefinitions();
targetNamespace = reader.getAttributeValue(null, TARGET_NAMESPACE);
definitions.setTargetNamespace(targetNamespace);
} else {
Object extension = extensionProcessor.read(reader);
if (extension != null) {
if (extension instanceof Intent) {
Intent intent = (Intent)extension;
intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
definitions.getIntents().add(intent);
for (Intent i : intent.getQualifiedIntents()) {
i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
}
} else if (extension instanceof PolicySet) {
PolicySet policySet = (PolicySet)extension;
policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
definitions.getPolicySets().add(policySet);
} else if (extension instanceof Binding) {
Binding binding = (Binding)extension;
definitions.getBindings().add(binding);
} else if (extension instanceof BindingType) {
definitions.getBindingTypes().add((BindingType)extension);
} else if (extension instanceof ImplementationType) {
definitions.getImplementationTypes().add((ImplementationType)extension);
}
}
break;
}
}