Package org.eclipse.emf.ecore.resource

Examples of org.eclipse.emf.ecore.resource.ResourceSet


        }

        final URI fileURI = URI.createFileURI(finalPath);
       
        // create resource set and resource
        ResourceSet resourceSet = new ResourceSetImpl();

        final Resource resource = resourceSet.getResource(fileURI, true);

        new EMFStoreCommand()
        {
            @Override
            protected void doRun()
View Full Code Here


      if (definition != null && definition.getDocumentBaseURI() != null)
      {
        Resource resource = definition.eResource();
        if (resource != null)
        {
          ResourceSet resourceSet = resource.getResourceSet();
          if (resourceSet != null)
          {
            if (namespace == null)
            {
              namespace = definition.getTargetNamespace();
            }

            String resolvedLocation = resolveLocation(definition, namespace, location);

            if (resolvedLocation == null)
            {
              return;
            }
           
            URI uri = URI.createURI(resolvedLocation);
            Resource resolvedResource = resourceSet.getResource(uri, false);
            if (resolvedResource == null)
            {
              try
              {
                InputStream inputStream = resourceSet.getURIConverter().createInputStream(uri);
                resolvedResource = getResource(uri, resourceSet);
                resolvedResource.load(inputStream, resourceSet.getLoadOptions());
              }
              catch (IOException exception)
              {
                // It is generally not an error to fail to resolve.
                // If a resource is actually created,
View Full Code Here

    else
      uri = URI.createFileURI(wsdlURI);

    // Create a resource set, create a wsdl resource, and load the main wsdl file into it.

    ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());

    WSDLResourceImpl wsdlMainResource = (WSDLResourceImpl)resourceSet.createResource(URI.createURI("*.wsdl"));
    wsdlMainResource.setURI(uri);

    try
    {
      InputStream inputStream = resourceSet.getURIConverter().createInputStream(uri);
      wsdlMainResource.load(inputStream, resourceSet.getLoadOptions());
      //wsdlMainResource.load(resourceSet.getLoadOptions());
    }
    catch (IOException e)
    {
      throw new WSDLException(WSDLException.INVALID_WSDL, "WSDL URI: " + wsdlURI, e);
View Full Code Here

   * @return the definition described in the document pointed to
   * by the InputSource.
   */
  public Definition readWSDL(String documentBaseURI, InputSource inputSource) throws WSDLException
  {
    ResourceSet resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
    WSDLResourceImpl wsdlMainResource = (WSDLResourceImpl)resourceSet.createResource(URI.createURI("*.wsdl"));

    try
    {
      if (documentBaseURI != null)
        wsdlMainResource.setURI(createURI(documentBaseURI));
      resourceSet.getLoadOptions().put(WSDLResourceImpl.CONTINUE_ON_LOAD_ERROR, new Boolean(false));
      wsdlMainResource.load(inputSource.getByteStream(), resourceSet.getLoadOptions());
    }
    catch (IOException ioe)
    {
      throw new WSDLException(WSDLException.INVALID_WSDL, "", ioe);
    }
View Full Code Here

    return globalResourceSet;
  }

  public static ResourceSet createResourceSet()
  {
    ResourceSet result = new ResourceSetImpl();
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl()); //$NON-NLS-1$
    return result;
  }
View Full Code Here

        TypeSystemDescription tsDesc = TypeSystemUtil.typeSystem2TypeSystemDescription(aCas
                .getTypeSystem());
        // register default resource factory
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*",
                new XMIResourceFactoryImpl());
        ResourceSet resourceSet = new ResourceSetImpl();
        URI outputURI = URI.createFileURI(new File(mOutputDir, "typesystem.ecore")
                .getAbsolutePath());
        Resource outputResource = resourceSet.createResource(outputURI);
        schemaLocationMap = new HashMap();
        try {
          UimaTypeSystem2Ecore
                  .uimaTypeSystem2Ecore(tsDesc, outputResource, null, schemaLocationMap);
        } catch (InvalidXMLException e) {
View Full Code Here

          @Override
          protected void execute(IProgressMonitor progressMonitor) {
            try {
              // Create a resource set
              //
              ResourceSet resourceSet = new ResourceSetImpl();

              // Get the URI of the model file.
              //
              URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);

              // Create a resource for this file.
              //
              Resource resource = resourceSet.createResource(fileURI);

              // Add the initial model object to the contents.
              //
              EObject rootObject = createInitialModel();
              if (rootObject != null) {
View Full Code Here

   * @generated
   */
  public static void main(String[] args) {
    // Create a resource set to hold the resources.
    //
    ResourceSet resourceSet = new ResourceSetImpl();
   
    // Register the appropriate resource factory to handle all file extensions.
    //
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
      (Resource.Factory.Registry.DEFAULT_EXTENSION,
       new XMIResourceFactoryImpl());

    // Register the package to ensure it is available during loading.
    //
    resourceSet.getPackageRegistry().put
      (TurtlePackage.eNS_URI,
       TurtlePackage.eINSTANCE);
       
    // If there are no arguments, emit an appropriate usage message.
    //
    if (args.length == 0) {
      System.out.println("Enter a list of file paths or URIs that have content like this:");
      try {
        Resource resource = resourceSet.createResource(URI.createURI("http:///My.turtle"));
        Turtle root = TurtleFactory.eINSTANCE.createTurtle();
        resource.getContents().add(root);
        resource.save(System.out, null);
      }
      catch (IOException exception) {
        exception.printStackTrace();
      }
    }
    else {
      // Iterate over all the arguments.
      //
      for (int i = 0; i < args.length; ++i) {
        // Construct the URI for the instance file.
        // The argument is treated as a file path only if it denotes an existing file.
        // Otherwise, it's directly treated as a URL.
        //
        File file = new File(args[i]);
        URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath()): URI.createURI(args[0]);

        try {
          // Demand load resource for this file.
          //
          Resource resource = resourceSet.getResource(uri, true);
          System.out.println("Loaded " + uri);

          // Validate the contents of the loaded resource.
          //
          for (EObject eObject : resource.getContents()) {
View Full Code Here

 
  private String separator = System.getProperty("file.separator");
 
  @Check
  public void checkUnresolvedReferences(TranslationUnit tu) {
    ResourceSet resourceSet = tu.eResource().getResourceSet();
   
        for (Resource resource : resourceSet.getResources())
        {
            TreeIterator<EObject> it = resource.getAllContents();
           
            while (it.hasNext())
            {
View Full Code Here

    Collection<TranslationUnit> loaded = new LinkedList<TranslationUnit>();

    // Tambien es visible lo ya cargado
    Resource resource = trunit.eResource();
    ResourceSet resourceSet = resource.getResourceSet();
    EList<Resource> resources = resourceSet.getResources();
    int index = resources.indexOf(resource);

    for (int i = 0; i < index; i++) {
      loaded.add((TranslationUnit) resources.get(i).getContents().get(0));
    }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.resource.ResourceSet

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.