Java 类org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl 实例源码

项目:Tarski    文件:MarkerFactory.java   
/**
 * @param selections
 * @return
 */
public static String getQualifiedName(final ITreeSelection selections) {
  final TreePath[] paths = selections.getPaths();

  // Consider only not empty and single selection
  if (selections.isEmpty() || selections.size() > 1) {
    return null;
  }

  final TreePath path = paths[0];
  IElementComparer comparer = null;
  if (selections instanceof TreeSelection) {
    comparer = ((TreeSelection) selections).getElementComparer();
  }
  System.out.println(path.hashCode(comparer));
  for (int i = 1; i < path.getSegmentCount(); i++) {
    if (path.getSegment(i) instanceof ResourceFactoryImpl) {
      final EcoreResourceFactoryImpl eResourceFactory =
          (EcoreResourceFactoryImpl) path.getSegment(i);
      System.out
          .println(eResourceFactory.getClass().getName() + ": " + eResourceFactory.toString());
    } else if (path.getSegment(i) instanceof ENamedElement) {
      final ENamedElement namedElement = (ENamedElement) path.getSegment(i);
      System.out.println(namedElement.getClass().getName() + ": " + namedElement.getName());
    } else {
      System.out.println("?");
    }
  }
  return null;
}
项目:xtext-core    文件:Bug287988WithEagerLinkingTest.java   
@Override
public void setUp() throws Exception {
    super.setUp();
    factory = new ResourceFactoryImpl(){
        @Override
        public Resource createResource(URI uri) {
            XtextResource resource = new XtextResource();
            injectMembers(resource);
            resource.setLinker(get(Linker.class));
            resource.setURI(uri);
            return resource;
        }
    };
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("bug287988testlanguage", factory);
}
项目:WP3    文件:MarkerFactory.java   
/**
 * @param selections
 * @return
 */
public static String getQualifiedName(final ITreeSelection selections) {
  final TreePath[] paths = selections.getPaths();

  // Consider only not empty and single selection
  if (selections.isEmpty() || selections.size() > 1) {
    return null;
  }

  final TreePath path = paths[0];
  IElementComparer comparer = null;
  if (selections instanceof TreeSelection) {
    comparer = ((TreeSelection) selections).getElementComparer();
  }
  System.out.println(path.hashCode(comparer));
  for (int i = 1; i < path.getSegmentCount(); i++) {
    if (path.getSegment(i) instanceof ResourceFactoryImpl) {
      final EcoreResourceFactoryImpl eResourceFactory =
          (EcoreResourceFactoryImpl) path.getSegment(i);
      System.out
          .println(eResourceFactory.getClass().getName() + ": " + eResourceFactory.toString());
    } else if (path.getSegment(i) instanceof ENamedElement) {
      final ENamedElement namedElement = (ENamedElement) path.getSegment(i);
      System.out.println(namedElement.getClass().getName() + ": " + namedElement.getName());
    } else {
      System.out.println("?");
    }
  }
  return null;
}
项目:textuml    文件:StandaloneUtil.java   
private static void setupResources() {
    EPackage.Registry.INSTANCE.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

    Map<String, Object> extMappings = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
    extMappings.put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
    extMappings.put(null, new ResourceFactoryImpl());
}
项目:reqiftools    文件:ReqIF10Compiler.java   
public String export(String id) throws Exception {
    this.createHeader(id);

    ResourceFactoryImpl resourceFactory = new XMLPersistenceMappingResourceFactoryImpl();
    URI emfURI = URI.createURI("http://kay-muench.de", true);
    XMLResource resource = (XMLResource) resourceFactory
            .createResource(emfURI);

    resource.setEncoding("UTF-8");
    resource.getContents().add(getReqIF());

    OutputStream os = new ByteArrayOutputStream();
    resource.save(os, null);
    return os.toString();
}
项目:emf-fragments    文件:AbstractReflectiveModelTests.java   
protected ResourceFactoryImpl createResourceFactoryImpl() {
    return new XMIResourceFactoryImpl() {
        @Override
        public Resource createResource(URI uri) {
            return new XMIFragmentImpl(uri, null);
        }
    };
}
项目:emf-fragments    文件:EmfSaveLargeChainTest.java   
@Test
public void theTest() throws Exception {
    EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE);
    Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new ResourceFactoryImpl() {
        @Override
        public Resource createResource(URI uri) {           
            return new BinaryResourceImpl(uri);
        }           
    });
    Resource resource = new ResourceSetImpl().createResource(URI.createURI("test.ecore"));
    EPackage thePkg = EcoreFactory.eINSTANCE.createEPackage();
    resource.getContents().add(thePkg);
    thePkg.setName("ThePkg");
    EClass lastClass = null;
    for (int i = 0; i < 10000; i++) {
        EClass newClass = EcoreFactory.eINSTANCE.createEClass();
        newClass.setName("Class" + i);
        thePkg.getEClassifiers().add(newClass);
        if (lastClass != null) {
            EReference ref = EcoreFactory.eINSTANCE.createEReference();
            ref.setName("ref");
            ref.setEType(newClass);
            lastClass.getEStructuralFeatures().add(ref);
        }
        lastClass = newClass;
    }

    resource.save(null);
}
项目:dynemf    文件:ResourceSetWrapper.java   
/**
 * Creates a prepared {@link ResourceSet} with some registered factories.
 * Produced resources by extensions are:
 * <ul>
 * <li>.xmi uses {@link XMIResourceImpl}</li>
 * <li>.bin uses {@link BinaryResourceImpl}</li>
 * <li>.ecore uses {@link XMIResourceImpl}</li>
 * <li>.* uses {@link XMIResourceImpl}</li>
 * </ul>
 * This method can be override in order to change the basic ResourceSet used
 * by this wrapper.
 * 
 * @return a configured ResourceSet
 */
protected static ResourceSet createResourceSet() {
    ResourceSet result = new ResourceSetImpl();
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bin", new ResourceFactoryImpl() {
        @Override
        public Resource createResource(URI uri) {
            return new BinaryResourceImpl(uri);
        }
    });
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
    return result;
}
项目:dynemf    文件:ResourceSetWrapper.java   
/**
 * Creates a prepared {@link ResourceSet} with some registered factories.
 * Produced resources by extensions are:
 * <ul>
 * <li>.xmi uses {@link XMIResourceImpl}</li>
 * <li>.bin uses {@link BinaryResourceImpl}</li>
 * <li>.ecore uses {@link XMIResourceImpl}</li>
 * <li>.* uses {@link XMIResourceImpl}</li>
 * </ul>
 * This method can be override in order to change the basic ResourceSet used
 * by this wrapper.
 * 
 * @return a configured ResourceSet
 */
protected static ResourceSet createResourceSet() {
    ResourceSet result = new ResourceSetImpl();
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bin", new ResourceFactoryImpl() {
        @Override
        public Resource createResource(URI uri) {
            return new BinaryResourceImpl(uri);
        }
    });
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
    return result;
}