Package org.eclipse.emf.ecore

Examples of org.eclipse.emf.ecore.EPackage$Registry


            }
          }
        }
        if (namespaceURI != null && !namespaceURI.equals(xsdSchema.getTargetNamespace()))
        {
          EPackage ePackage = extendedMetaData.getPackage(namespaceURI);
          if (ePackage != null)
          {
            XSDSchema schema = loadEPackage(ePackage);
            return schema;
          }
View Full Code Here


    super(registry);
  }

  public EPackage demandPackage(String namespace)
  {
    EPackage ePackage = demandRegistry.getEPackage(namespace);
    if (ePackage == null)
    {
      ePackage = ecoreFactory.createEPackage();
      ePackage.setNsURI(namespace);
      setQualified(ePackage, namespace != null);
      if (namespace != null)
      {
        ePackage.setNsPrefix
          (namespace.equals(ExtendedMetaData.XMLNS_URI) ?
             namespace.equals(ExtendedMetaData.XML_URI) ?
               "xml" :
               "xmlns" :
             computePrefix(namespace));
      }
      demandRegistry.put(namespace, ePackage);

      // demandDocumentRoot(ePackage);

      EClass documentRootEClass = ecoreFactory.createEClass();
      documentRootEClass.getESuperTypes().add(demandMetaData.getXMLTypeDocumentRoot());
      documentRootEClass.setName("DocumentRoot");
      ePackage.getEClassifiers().add(documentRootEClass);
      setDocumentRoot(documentRootEClass);
    }
    return ePackage;
  }
View Full Code Here

    return ePackage;
  }
 
  public EClassifier demandType(String namespace, String name)
  {
    EPackage ePackage = demandPackage(namespace);
    EClassifier eClassifier = getType(ePackage, name);
    if (eClassifier != null)
    {
      return eClassifier;
    }
    else
    {
      EClass eClass = ecoreFactory.createEClass();
      eClass.setName(name);
      eClass.getESuperTypes().add(demandMetaData.getAnyType());
      setContentKind(eClass, MIXED_CONTENT);
      ePackage.getEClassifiers().add(eClass);
      return eClass;
    }
  }
View Full Code Here

    }
  }

  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);
View Full Code Here

            {
              return nsPrefix;
            }
           
            // Demand create a new package
            EPackage ePackage = extendedMetaData.demandPackage(nsURI);

            if (ExtendedMetaData.XSI_URI.equals(nsURI)) {
                ePackage.setNsPrefix(ExtendedMetaData.XSI_PREFIX);
            }
           
            // getPrefix() will make sure all mapping tables are configured correctly
            nsPrefix = getPrefix(ePackage, true);
           
View Full Code Here

        // MetadataFactoryImpl.init(); //FB do we want to preregister this?
    }


    public Type getType(String uri, String typeName) {
        EPackage ePackage = extendedMetaData.getPackage(uri);

        if (ePackage != null) {
            EClassifier eClassifier = ePackage.getEClassifier(typeName);
            if (eClassifier == null) {
                eClassifier = extendedMetaData.getType(ePackage, typeName);
            }
            return (Type)eClassifier;
        }
View Full Code Here

                            typeName = typeQName;
                        eFactory = getFactoryForPrefix(xsiPrefix);
                        if (eFactory != null)
                            type = helper.getType(eFactory, typeName);
                        else if (XMLConstants.DEFAULT_NS_PREFIX.equals(xsiPrefix) && helper.getURI(xsiPrefix) == null) {
                            EPackage ePackage = handleMissingPackage(null);
                            if (ePackage == null) {
                                type = defaultRootType(prefix, name, isElement, peekObject, value);
                                if (type == null)
                                    return;
                                eFactory = type.getEPackage().getEFactoryInstance();
                            } else
                                type = helper.getType(eFactory = ePackage.getEFactoryInstance(), typeName);
                        } else {
                            type = defaultRootType(prefix, name, isElement, peekObject, value);
                            if (type == null)
                                return;
                            eFactory = type.getEPackage().getEFactoryInstance();
View Full Code Here

      EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);

      // Create an EPackage for the generated SDO
      if (packageURI == null)
        packageURI = "http://" + javaPackage;
      EPackage implEPackage = EcoreFactory.eINSTANCE.createEPackage();
      implEPackage.setNsURI(packageURI);
      String shortName = shortName(packageURI);
      implEPackage.setName(shortName);
      implEPackage.setNsPrefix(shortName.toLowerCase());
      packageRegistry.put(packageURI, implEPackage);

      // Create EClasses for all the given Java interfaces
      Map eClasses = new HashMap();
      for (Iterator iter = javaInterfaces.iterator(); iter.hasNext();)
      {
        String interfaceName = (String)iter.next();
        Class instanceClass = Class.forName(interfaceName, true, classLoader);

        EClass implEClass = EcoreFactory.eINSTANCE.createEClass();
        String className = shortName(instanceClass.getName());
        implEClass.setName(className);
        implEClass.setInstanceClass(instanceClass);

        eClasses.put(instanceClass, implEClass);
        implEPackage.getEClassifiers().add(implEClass);
      }

      // Populate the EClasses with EAttributes and EReferences for their properties
      for (Iterator iter = implEPackage.getEClassifiers().iterator(); iter.hasNext();)
      {
        EClass implEClass = (EClass)iter.next();
        Class instanceClass = implEClass.getInstanceClass();
        Method[] methods = instanceClass.getMethods();
        for (int m = 0; m < methods.length; m++)
View Full Code Here

              {
                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;
              }
              // TODO The following 3 lines of code are a temporary work-around for JIRA issue TUSCANY-1862.
              // These lines of code should be removed when TUSCANY-1862 is resolved.
              if ("".equals(uri) && "objectsToAttach".equals(name) && text != null && text.length() == 0)
              {
                text = null;
              }             
              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;
View Full Code Here

    if (resourceSet != null) return EcoreUtil.resolve((EObject)proxy, resourceSet);
     
    URI proxyURI = ((InternalEObject)proxy).eProxyURI();
    if (proxyURI != null)
    {
      EPackage ePackage = HelperContextImpl.getBuiltInModelRegistry().getEPackage(proxyURI.trimFragment().toString());
      if (ePackage != null)
      {
        resource = ePackage.eResource();
        if (resource != null)
        {
          return resource.getEObject(proxyURI.fragment().toString());
        }
      }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.EPackage$Registry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.