Package org.eclipse.emf.ecore

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


   *            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) {
          /**
           * ePackage.getEclassifiers will return an EList ( simple extension of List ).
           *
           * When a Type is generated from XML EMF will create a DocumentRoot type As this is EMF specific it should be removed
           */
          List result = new ArrayList(ePackage.getEClassifiers());
          result.remove(((TypeHelperImpl) scope).getExtendedMetaData().getDocumentRoot(ePackage));
          return result;
      }
      return null;
  }
View Full Code Here


 
  public static Type createType(TypeHelper scope, String uri, String name, boolean isDataType)
  {
    ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData();
   
    EPackage ePackage = extendedMetaData.getPackage(uri);
    if (ePackage == null)
    {
      ePackage = EcoreFactory.eINSTANCE.createEPackage();
      ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl());
      ePackage.setNsURI(uri);
      String packagePrefix = URI.createURI(uri).trimFileExtension().lastSegment();
      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

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

        EPackage ePackage = extendedMetaData.getPackage(schema.getTargetNamespace());
        if (ePackage == null)
        {
          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

*/
@SuppressWarnings("restriction")
public class ProtobufEcorePostProcessor implements IXtext2EcorePostProcessor {

  @Override public void process(GeneratedMetamodel metamodel) {
    EPackage p = metamodel.getEPackage();
    for (EClassifier c : p.getEClassifiers()) {
      if (c instanceof EClass && "Literal".equals(c.getName())) {
        processLiteralClass((EClass) c);
      }
    }
  }
View Full Code Here

  public boolean test(Object receiver, String property, Object[] args,
      Object expectedValue) {
    boolean result = false;
   
    if ("ePackage".equals(property)) { //$NON-NLS-1$
      EPackage actual = ((EObject) receiver).eClass().getEPackage();
     
      // check for null just in case
      result = (actual != null) && actual.getNsURI().equals(expectedValue);
    }
   
    return result;
  }
View Full Code Here

    // e.g., an XML document consisting of
    // <test xmlns="urn:test">
    //   <subTest>subTest1</subTest>
    //   <subTest>2</subTest>
    // </test>
    EPackage testPackage = ExtendedMetaData.INSTANCE.demandPackage("urn:test");
    EClass docEClass = ExtendedMetaData.INSTANCE.getDocumentRoot(testPackage);
    EObject doc = EcoreUtil.create(docEClass);
    resource.getContents().add(doc);
   
    EStructuralFeature docMixedFeature = ExtendedMetaData.INSTANCE.getMixedFeature(docEClass);
View Full Code Here

          EMFExternalClass refExternalClass = getEMFExternalClassFor(root, refDest);
          if (refExternalClass == null) {
            // we need to create one
            refExternalClass = factory.createEMFExternalClass();
            refExternalClass.setName(refDest.getName());
            EPackage pkg = refDest.getEPackage();
            if (pkg != null) {
              refExternalClass.setTargetClass(refDest);
              refExternalClass.setPackageName(pkg.getName());
              refExternalClass.setPackageURI(pkg.getNsURI());
              refExternalClass.setPackagePrefix(pkg.getNsPrefix());
            }
            root.getExternalClasses().add(refExternalClass);
          }
          newRef.setType(refExternalClass);
        }
View Full Code Here

  public boolean identifierMatches(Identifier type, EClass ref) {
    String[] bits = type.getValue().split("::");
   
    if (ref.getName().equals(bits[bits.length - 1])) {
      // same name
      EPackage currentPackage = ref.getEPackage();
      for (int i = bits.length - 2; i >= 0; i--) {
        if (currentPackage == null) {
          // bail
          return false;
        }
        if (!currentPackage.getName().equals(bits[i])) {
          // bail
          return false;
        }
        currentPackage = currentPackage.getESuperPackage();
      }
     
      // we should be at the root of the package heirarchy
      if (currentPackage != null)
        return false;
View Full Code Here

   
    initialise();
   
    // investigate the EPackage of this object, and all contained
    // EPackages
    EPackage pkg = ((EPackage) root);
    evaluatePackage(pkg);
   
    return getResult();
  }
View Full Code Here

      objectLanguageURI = URI.createURI(olS);
    } catch (Exception e){
      throw new ValidationException(ANNOTATION_OBJECT_LANGUAGE + " must be an URI!");
    }

    EPackage oLPackage = (EPackage)EPackage.Registry.INSTANCE.get(objectLanguageURI.toString());
    if(oLPackage==null){
      throw new ValidationException("Object Language " + objectLanguageURI + " hasn't been registered at EPackage-registry!");
    }
    return oLPackage;
   
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.