}
public EStructuralFeature demandFeature(String namespace, String name, boolean isElement, boolean isReference)
{
EPackage ePackage = demandPackage(namespace);
EClass documentRootEClass = getDocumentRoot(ePackage);
EStructuralFeature eStructuralFeature =
isElement ?
getLocalElement(documentRootEClass, namespace, name) :
getLocalAttribute(documentRootEClass, namespace, name);
if (eStructuralFeature != null)
{
return eStructuralFeature;
}
else
{
if (isReference)
{
EReference eReference = ecoreFactory.createEReference();
eReference.setContainment(isElement);
eReference.setEType(demandMetaData.getEObject());
eReference.setName(name);
eReference.setDerived(true);
eReference.setTransient(true);
eReference.setVolatile(true);
documentRootEClass.getEStructuralFeatures().add(eReference);
setFeatureKind(eReference, isElement ? ELEMENT_FEATURE : ATTRIBUTE_FEATURE);
setNamespace(eReference, namespace);
// Mark the bound as unspecified so that it won't be considered many
// but can nevertheless be recognized as being unspecified and perhaps still be treat as many.
//
if (isElement)
{
eReference.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY);
}
return eReference;
}
else
{
EAttribute eAttribute = ecoreFactory.createEAttribute();
eAttribute.setName(name);
eAttribute.setEType(demandMetaData.getAnySimpleType());
eAttribute.setDerived(true);
eAttribute.setTransient(true);
eAttribute.setVolatile(true);
documentRootEClass.getEStructuralFeatures().add(eAttribute);
setFeatureKind(eAttribute, isElement ? ELEMENT_FEATURE : ATTRIBUTE_FEATURE);
setNamespace(eAttribute, namespace);
// Mark the bound as unspecified so that it won't be considered many