Package org.eclipse.emf.ecore.resource

Examples of org.eclipse.emf.ecore.resource.Resource.load()


      testResourceSet.getURIConverter().getURIMap().put(URI.createURI("../TargetObject/"), targetObject1.eResource().getURI().trimSegments(1).appendSegment(""));

      Resource libraryXMI = new XMIResourceFactoryImpl().createResource(URI.createURI(temporaryFolder.newFile("model.mongo.xml").getAbsolutePath()));
      testResourceSet.getResources().add(libraryXMI);

      libraryXMI.load(new ByteArrayInputStream(out.toByteArray()), options);
      EChecker.checkObject(primaryObject, libraryXMI.getContents().get(0));
    }
  }

  @Test
View Full Code Here


    ByteArrayOutputStream out = new ByteArrayOutputStream();
    primaryResource2.save(out, options);

    ResourceSet resourceSet3 = createResourceSet();
    Resource primaryResource3 = resourceSet3.createResource(primaryObject.eResource().getURI());
    primaryResource3.load(new ByteArrayInputStream(out.toByteArray()), null);

    // Verify that proxies are created when loading from XML.
    //
    PrimaryObject primaryObject3 = (PrimaryObject) primaryResource3.getContents().get(0);
    assertTrue(((EObject) primaryObject3.eGet(ModelPackage.Literals.PRIMARY_OBJECT__SINGLE_CONTAINMENT_REFERENCE_PROXIES, false)).eIsProxy());
View Full Code Here

    ResourceSet resourceSet = new ResourceSetImpl();
    URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), false);
    Resource resource = resourceSet.getResource(uri, true);
   
    try {
      resource.load(null);
    } catch (IOException e) {
      e.printStackTrace();
    }
   
    EcoreUtil.resolveAll(resourceSet);
View Full Code Here

    URI uri = URI.createFileURI(fileName);
    Resource resource = resourceSet.createResource(uri);

    try {
      // load resource
      resource.load(null);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return null;
    }
View Full Code Here

    resourceSet.getResources().clear();
    Resource resource = resourceSet.createResource(createURI("MyQuery.__query"));
    try {
      Map<String,String> options = newHashMap();
      options.put(XtextResource.OPTION_ENCODING, UTF_8);
      resource.load(new StringInputStream(input, UTF_8), options);
      EcoreUtil.resolveAll(resource);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    return filter(resource.getContents(), Query.class).iterator().next();
View Full Code Here

 
 
  protected Resource resource(String input, String extension)  {
    Resource resource = resourceSet.createResource(createURI(format("TaskTest" + resourceSet.getResources().size() + "." + extension)));
    try {
      resource.load(new StringInputStream(input), null);
      EcoreUtil.resolveAll(resource);
    } catch (IOException e) {
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
View Full Code Here

    // Register the package -- only needed for stand-alone!
    resourceSet.getPackageRegistry().put(UamPackage.eNS_URI, UamPackage.eINSTANCE);
    resourceSet.getPackageRegistry().put(ExpressionPackage.eNS_URI, ExpressionPackage.eINSTANCE);
    resourceSet.getPackageRegistry().put(StdlibPackage.eNS_URI, StdlibPackage.eINSTANCE);
    ByteArrayInputStream bais = new ByteArrayInputStream(modelString.getBytes());
    xmlResource.load(bais, Collections.emptyMap());
    return (SecurityModel) xmlResource.getContents().get(0);
  }

  @Override
  public String getModelAsString() {
View Full Code Here

      } else if (exerciseResource != null && exists) {
        if (exerciseResource.isLoaded()) {
          exerciseResource.unload();
        }
        try {
          exerciseResource.load(null);
        } catch (IOException e) {
          exercises.getResources().remove(exerciseResource);
        }
      }
    }
View Full Code Here

  }

  private XExpression parseScriptIntoXTextEObject(String scriptAsString) throws ScriptParsingException {
    Resource resource = resourceSet.createResource(computeUnusedUri(resourceSet)); // IS-A XtextResource
    try {
      resource.load(new StringInputStream(scriptAsString), resourceSet.getLoadOptions());
    } catch (IOException e) {
      throw new ScriptParsingException("Unexpected IOException; from close() of a String-based ByteArrayInputStream, no real I/O; how is that possible???", scriptAsString, e);
    }
   
    List<Diagnostic> errors = resource.getErrors();
View Full Code Here

          if(resource!=null) {
            logger.info("Loading model '{}'", name);
            try {
              Map<String, String> options = new HashMap<String, String>();
              options.put(XtextResource.OPTION_ENCODING, "UTF-8");
              resource.load(inputStream, options);
              notifyListeners(name, EventType.ADDED);
              return true;
            } catch (IOException e) {
              logger.warn("Configuration model '" + name + "' cannot be parsed correctly!", e);
              resourceSet.getResources().remove(resource);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.