{
if (!ePackages.isEmpty())
{
for (Iterator i = ePackages.iterator(); i.hasNext();)
{
EPackage ePackage = (EPackage)i.next();
ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
Resource resource = resourceSet.createResource(URI.createURI("*.ecore"));
resource.getContents().add(ePackage);
if (ePackage.getNsURI() != null)
{
resource.setURI(URI.createURI(ePackage.getNsURI()));
}
if (extendedMetaData != null)
{
extendedMetaData.putPackage(extendedMetaData.getNamespace(ePackage), ePackage);
}
else
{
packageRegistry.put(ePackage.getNsURI(), ePackage);
}
}
handleForwardReferences();
}
isInModels = false;
}
super.endElement(uri, localName, name);
}
protected EPackage getPackageForURI(String uriString)
{
if ("commonj.sdo".equals(uriString))
{
return SDOPackage.eINSTANCE;
}
else
{
return super.getPackageForURI(uriString);
}
}
protected EObject createObjectFromFactory(EFactory factory, String typeName)
{
if (factory == SDOFactory.eINSTANCE)
{
if ("datagraph".equals(typeName))
{
return super.createObjectFromFactory(factory, "DataGraph");
}
}
return super.createObjectFromFactory(factory, typeName);
}
protected EcoreBuilder createEcoreBuilder(Map options, ExtendedMetaData extendedMetaData)
{
return new DefaultEcoreBuilder(extendedMetaData)
{
public Collection generate(Map urisToLocations) throws Exception
{
Collection result = super.generate(urisToLocations);
return updateDynamicFactory(result);
}
public Collection generate(Collection urisToLocations) throws Exception
{
Collection result = super.generate(urisToLocations);
return updateDynamicFactory(result);
}
protected Collection updateDynamicFactory(Collection result)
{
for (Iterator i = result.iterator(); i.hasNext();)
{
Resource resource = (Resource)i.next();
for (Iterator j = EcoreUtil.getObjectsByType(resource.getContents(), EcorePackage.eINSTANCE.getEPackage()).iterator(); j.hasNext();)
{
EPackage ePackage = (EPackage)j.next();
ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
}
}
return result;
}
};
}
protected EPackage handleMissingPackage(String uriString)
{
EPackage result = super.handleMissingPackage(uriString);
if (processAnyXML && objects.size() == 1)
{
result = extendedMetaData.demandPackage(uriString);
}
return result;