Package org.eclipse.emf.ecore

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


    resolveNameConflicts();

    for (Iterator i = xsdSchemas.iterator(); i.hasNext(); )
    {
      XSDSchema generatedXSDSchema = (XSDSchema)i.next();
      EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(generatedXSDSchema.getTargetNamespace());
      if (ePackage != null)
      {
        String packageName= getEcoreAttribute(generatedXSDSchema, "package");
        if (packageName != null)
        {
          ePackage.setName(packageName);
        }
        String packageNsPrefix= getEcoreAttribute(generatedXSDSchema, "nsPrefix");
        if (packageNsPrefix != null)
        {
          ePackage.setNsPrefix(packageNsPrefix);
        }
      }
    }

    for (Iterator i = eReferenceToOppositeNameMap.entrySet().iterator(); i.hasNext(); )
View Full Code Here


    {
      if (builtInModelRegistry == null) {
        builtInModelRegistry = new EPackageRegistryImpl();
        for (Iterator iter = TypeHelperImpl.getBuiltInModels().iterator(); iter.hasNext(); )
        {
          EPackage ePackage = (EPackage)iter.next();
          builtInModelRegistry.put(ePackage.getNsURI(), ePackage);
        }
      }
      return builtInModelRegistry;
    }
View Full Code Here

    }

    ResourceSet resourceSet = ((DataGraphImpl)dataGraph).getResourceSet();

    for (Iterator iterator = packages.iterator(); iterator.hasNext(); ) {
      EPackage typePackage = (EPackage)iterator.next();
      Resource resource = typePackage.eResource();
      if (resource == null) {
        resource = resourceSet.createResource(URI.createURI(".ecore"));
        resource.setURI(URI.createURI(typePackage.getNsURI()));
        resource.getContents().add(typePackage);
      }
      else if (resource.getResourceSet() != resourceSet)
        resourceSet.getResources().add(resource);
    }
View Full Code Here

   *            Uri of the Types
   * @return List. List containing instances of Type, null if uri is not found.
   */
  public static List getTypes(TypeHelper scope, String uri) {

      EPackage ePackage = ((TypeHelperImpl) scope).getExtendedMetaData().getPackage(uri);
      if (ePackage != null) {
        return new ArrayList(ePackage.getEClassifiers());
      }
      return null;
  }
View Full Code Here

  public static Type createType(TypeHelper scope, String uri, String name, boolean isDataType)
  {
    ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData();
    if ("".equals(uri)) uri = null; //FB
   
    EPackage ePackage = extendedMetaData.getPackage(uri);
    if (ePackage == null)
    {
      ePackage = EcoreFactory.eINSTANCE.createEPackage();
      ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
      ePackage.setNsURI(uri);
      String packagePrefix = uri != null ? URI.createURI(uri).trimFileExtension().lastSegment() : ""; //FB
      ePackage.setName(packagePrefix);
      ePackage.setNsPrefix(packagePrefix);
      extendedMetaData.putPackage(uri, ePackage);
    }

    EClassifier eClassifier = ePackage.getEClassifier(name);
    if (eClassifier != null) // already defined?
    {
      //throw new IllegalArgumentException();
      return null;
    }
   
    if (name != null)
    {
      eClassifier = isDataType ? (EClassifier)SDOFactory.eINSTANCE.createDataType() : (EClassifier)SDOFactory.eINSTANCE.createClass();
      eClassifier.setName(name);
    }
    else
    {
      eClassifier = DataObjectUtil.createDocumentRoot();
    }
   
    ePackage.getEClassifiers().add(eClassifier);

    return (Type)eClassifier;
  }
View Full Code Here

  public static Property createGlobalProperty(TypeHelper scope, String uri, String name, Type type)
  {
    ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData();

    // get/create document root
    EPackage ePackage = extendedMetaData.getPackage(uri);
    Type documentRoot = ePackage != null ? (Type)extendedMetaData.getType(ePackage, "") : null;
    if (documentRoot == null)
    {
      documentRoot = SDOUtil.createType(scope, uri, null, false);
    }
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

  }

  public EPackage getPackage(String namespace)
  {
    if ("".equals(namespace)) namespace = null; //FB
    EPackage result = registry.getEPackage(namespace);
    return result == null ? super.getPackage(namespace) : result;
  }
View Full Code Here

    this.extensibleNamespaces = extensibleNamespaces;
    ecoreBuilder = new SDOXSDEcoreBuilder(extendedMetaData, extensibleNamespaces);
   
    // Add the built-in models to the targetNamespaceToEPackageMap so they can't be (re)defined/overridden
    for (Iterator iter = TypeHelperImpl.getBuiltInModels().iterator(); iter.hasNext(); ) {
      EPackage ePackage = (EPackage)iter.next();
      ecoreBuilder.getTargetNamespaceToEPackageMap().put(ePackage.getNsURI(), ePackage);
    }
   
    if (redefineBuiltIn != null) { // Redefining/regenerating this built-in model
      ecoreBuilder.getTargetNamespaceToEPackageMap().remove(redefineBuiltIn);
    }
View Full Code Here

      List newTypes = new ArrayList();
      for (Iterator schemaIter = model.getContents().iterator(); schemaIter.hasNext(); )
      {
        XSDSchema schema = (XSDSchema)schemaIter.next();   

        EPackage ePackage = extendedMetaData.getPackage(schema.getTargetNamespace());
        if (extensibleNamespaces || ePackage == null || TypeHelperImpl.getBuiltInModels().contains(ePackage))
        {
          Collection originalEPackages = new HashSet(ecoreBuilder.getTargetNamespaceToEPackageMap().values());
          ecoreBuilder.generate(schema);
          Collection newEPackages = ecoreBuilder.getTargetNamespaceToEPackageMap().values();
     
          for (Iterator iter = newEPackages.iterator(); iter.hasNext();)
          {
            EPackage currentPackage = (EPackage)iter.next();
            if (!originalEPackages.contains(currentPackage))
            {
              currentPackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
              EcoreUtil.freeze(currentPackage);
              newTypes.addAll(currentPackage.getEClassifiers());
            }
          }
        }
      }
     
View Full Code Here

TOP

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

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.