当前位置: 首页>>代码示例>>Java>>正文


Java XMLResourceImpl类代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl的典型用法代码示例。如果您正苦于以下问题:Java XMLResourceImpl类的具体用法?Java XMLResourceImpl怎么用?Java XMLResourceImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLResourceImpl类属于org.eclipse.emf.ecore.xmi.impl包,在下文中一共展示了XMLResourceImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
/** Load model to a resource. */
public static Resource load (String ontoumlPath) throws IOException
{	
	ResourceSet rset = new ResourceSetImpl();			
	rset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("mouml",new XMIResourceFactoryImpl());
	rset.getPackageRegistry().put(OntoumlPackage.eNS_URI,	OntoumlPackage.eINSTANCE);
    File file = new File(ontoumlPath);
	URI fileURI = URI.createFileURI(file.getAbsolutePath());		
	Resource resource = rset.createResource(fileURI);		
	/**Load options that significantly improved the performance of loading EMF Model instances*/
	Map<Object,Object> loadOptions = ((XMLResourceImpl)resource).getDefaultLoadOptions();
	//loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
	//loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
	resource.load(loadOptions);		
	return resource;		
}
 
开发者ID:MenthorTools,项目名称:menthor-xcore,代码行数:17,代码来源:OntoumlResource.java

示例2: serialize

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
private String serialize(EObject eObject) {
	ResourceImpl resource = new XMLResourceImpl();
	resource.getContents().add(eObject);
	
	final ByteArrayOutputStream baos = new ByteArrayOutputStream();
	final Map<Object, Object> options = new HashMap<Object, Object>();
	options.put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);
	options.put(XMLResource.OPTION_DECLARE_XML, Boolean.FALSE);
	try {
		resource.save(baos, options);
		return baos.toString();
	} catch (IOException e) {
		LogUtil.error(e);
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:AbstractPatchTestWithAllFeatureTypes.java

示例3: getEObjectListFromResponse

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
/**
 * converts an response's inputstream to a list of EObjects, for example: List<ProjectInfo>, List<BranchInfo>, ...
 * @param response
 * @return
 */
private <T extends EObject> List<T> getEObjectListFromResponse(
		final Response response) {
	//create XMLResource and read the entity
	ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	final String fileNameURI = "blabla";
	final XMLResourceImpl resource = (XMLResourceImpl) resourceSetImpl.createResource(URI.createURI(fileNameURI));
	
	final InputStream is = response.readEntity(InputStream.class);
	List<T> eObjectList = new ArrayList<T>();
	try {
		//create the List<ProjectInfo> from the input stream
		resource.doLoad(is, null);   
		for(Object o : resource.getContents()) {
			eObjectList.add((T) o);
		}
		
	} catch (final IOException ex) {
		System.err.println(ex.getMessage());
	}
	return eObjectList;
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:27,代码来源:JaxrsConnectionManager.java

示例4: convertEObjectsToXmlIntoStreamingOutput

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
/**
 * @param eObjects
 * @return
 */
protected StreamingOutput convertEObjectsToXmlIntoStreamingOutput(
		final Collection<? extends EObject> eObjects) {
	// convert the list into XML and write it to a StreamingOutput
	ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	final String fileNameURI = "blabla";
	final XMLResourceImpl resource = (XMLResourceImpl) resourceSetImpl
			.createResource(URI.createURI(fileNameURI));
	
	for(EObject e : eObjects) {
		EObject copy = EcoreUtil.copy(e);  //neccessary because add() has side effects!
		resource.getContents().add(copy);
	}

	final StreamingOutput streamingOutput = new StreamingOutput() {

		public void write(OutputStream output) throws IOException,
				WebApplicationException {

			resource.doSave(output, null);

		}
	};
	return streamingOutput;
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:29,代码来源:JaxrsResource.java

示例5: convertEObjectsToXmlIntoStreamingOutput

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
/**
 * @param eObjects
 * @return
 */
public static StreamingOutput convertEObjectsToXmlIntoStreamingOutput(
		final Collection<? extends EObject> eObjects) {
	// convert the list into XML and write it to a StreamingOutput
	ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	final String fileNameURI = "blabla";
	final XMLResourceImpl resource = (XMLResourceImpl) resourceSetImpl
			.createResource(URI.createURI(fileNameURI));
	
	for(EObject e : eObjects) {
		EObject copy = EcoreUtil.copy(e);  //neccessary because add() has side effects!
		resource.getContents().add(copy);
	}

	final StreamingOutput streamingOutput = new StreamingOutput() {

		public void write(OutputStream output) throws IOException,
				WebApplicationException {

			resource.doSave(output, null);

		}
	};
	return streamingOutput;
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:29,代码来源:TransferUtil.java

示例6: getEObjectListFromInputStream

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
/**
 * converts an response's inputstream to a list of EObjects, for example: List<ProjectInfo>, List<BranchInfo>, ...
 * @param 
 * @return
 */
public static <T extends EObject> List<T> getEObjectListFromInputStream(
		final InputStream is) {
	//create XMLResource and read the entity
	ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
	final String fileNameURI = "blabla";
	final XMLResourceImpl resource = (XMLResourceImpl) resourceSetImpl.createResource(URI.createURI(fileNameURI));
	
	List<T> eObjectList = new ArrayList<T>();
	try {
		//create the List<ProjectInfo> from the input stream
		resource.doLoad(is, null);   
		for(Object o : resource.getContents()) {
			eObjectList.add((T) o);
		}
		
	} catch (final IOException ex) {
		System.err.println(ex.getMessage());
	}
	return eObjectList;
}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:26,代码来源:TransferUtil.java

示例7: generateSample

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
public Resource generateSample() {
    final String theGrammarFile = PLATFORM_RESOURCE + theSchema.eResource().getURI().toPlatformString(true);
    final CMDocument cmDocument = createCMDocument(theGrammarFile, new String[2]);
    setGrammarURI(theGrammarFile);
    setCMDocument(cmDocument);
    setRootElementName(root);
    setBuildPolicy(BUILD_OPTIONAL_ELEMENTS | BUILD_FIRST_CHOICE | BUILD_FIRST_SUBSTITUTION | BUILD_TEXT_NODES);
    // setOptionalElementDepthLimit(-1);
    createNamespaceInfoList();
    resolveSchemaLocations();
    try {
        this.createXMLDocument(toFile(xmlURI).getPath());
    } catch (final Exception e) {
        throw new RuntimeException("Failed to create the XML resource.", e);
    }
    return new XMLResourceImpl(xmlURI);
}
 
开发者ID:GRA-UML,项目名称:tool,代码行数:18,代码来源:NewXMLGeneratorExtension.java

示例8: serialize

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
private String serialize(Marketplace rootElement) throws IOException {
	Map<String, Object> saveOptions = new HashMap<String, Object>();
	saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
	// UTF-8 encoding is required per specification
	saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
	XMLResource resource = new XMLResourceImpl();
	resource.getContents().add(rootElement);
	StringWriter stringWriter = new StringWriter();
	resource.save(new URIConverter.WriteableOutputStream(stringWriter, resource.getEncoding()), saveOptions);
	return stringWriter.getBuffer().toString();
}
 
开发者ID:Itema-as,项目名称:dawn-marketplace-server,代码行数:12,代码来源:MarketplaceEndpoint.java

示例9: serialize

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
public static String serialize(Node rootElement) throws IOException {
	Map<String, Object> saveOptions = new HashMap<String, Object>();
	saveOptions.put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
	saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
	XMLResource resource = new XMLResourceImpl();
	resource.getContents().add(rootElement);
	StringWriter stringWriter = new StringWriter();
	resource.save(new URIConverter.WriteableOutputStream(stringWriter, resource.getEncoding()), saveOptions);
	return stringWriter.getBuffer().toString();
}
 
开发者ID:Itema-as,项目名称:dawn-marketplace-server,代码行数:11,代码来源:MarketplaceSerializer.java

示例10: setUp

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	ResourceSet resourceSet = new ResourceSetImpl();
	Resource syntheticResource = new XMLResourceImpl(URI.createURI("http://synthetic.resource"));
	resourceSet.getResources().add(syntheticResource);
	typeProvider = new ClasspathTypeProvider(getClass().getClassLoader(), resourceSet, null, null);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:JvmTypeReferencesTest.java

示例11: setUp

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	resource = new XMLResourceImpl();
	resource.setURI(URI.createURI("foo:/test"));
	nameProvider = new IQualifiedNameProvider.AbstractImpl() {
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			if (obj instanceof ENamedElement)
				return QualifiedName.create(((ENamedElement) obj).getName());
			return null;
		}
	};
	strategy = new DefaultResourceDescriptionStrategy();
	strategy.setQualifiedNameProvider(nameProvider);
	description = new DefaultResourceDescription(resource, strategy);
	EcoreFactory f = EcoreFactory.eINSTANCE;
	pack = f.createEPackage();
	pack.setName("MyPackage");
	eClass = f.createEClass();
	eClass.setName("MyEClass");
	dtype = f.createEDataType();
	dtype.setName("MyDatatype");
	pack.getEClassifiers().add(eClass);
	pack.getEClassifiers().add(dtype);
	resource.getContents().add(pack);

}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:28,代码来源:DefaultResourceDescriptionTest.java

示例12: loadRefModel

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
public static Resource loadRefModel(String refontoumlpath) throws IOException
{
	ResourceSet rset = new ResourceSetImpl();			
	rset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("refontouml",new RefOntoUMLResourceFactoryImpl());
	rset.getPackageRegistry().put(RefOntoUML.RefOntoUMLPackage.eNS_URI,	RefOntoUML.RefOntoUMLPackage.eINSTANCE);		
    File file = new File(refontoumlpath);
	URI fileURI = URI.createFileURI(file.getAbsolutePath());		
	Resource resource = rset.createResource(fileURI);		
	/**Load options that significantly improved the performance of loading EMF Model instances*/
	Map<Object,Object> loadOptions = ((XMLResourceImpl)resource).getDefaultLoadOptions();
	loadOptions.put(XMLResource.OPTION_USE_PARSER_POOL, new XMLParserPoolImpl());
	loadOptions.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, Boolean.TRUE);
	resource.load(loadOptions);		
	return resource;		
}
 
开发者ID:MenthorTools,项目名称:menthor-xcore,代码行数:16,代码来源:TransformerUtil.java

示例13: setup

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
@Before
public void setup() {
	resourceSet = new ResourceSetImpl();
	model = PatchTestFactory.eINSTANCE.createPatchTestModel();
	model.setId("ID");
	ResourceImpl testModelResource = new XMLResourceImpl(URI.createURI("http://model"));
	testModelResource.getContents().add(model);
	resourceSet.getResources().add(testModelResource);
	if (showDebuggingOutput()) {
		System.out.println("TEST: " + name.getMethodName());
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:AbstractPatchTestWithAllFeatureTypes.java

示例14: deserialize

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
private EObject deserialize(String string) {
	ByteArrayInputStream bais = new ByteArrayInputStream(string.getBytes());
	XMLResourceImpl resource = new XMLResourceImpl(URI.createURI("http://patch"));
	resourceSet.getResources().add(resource);
	try {
		resource.load(bais, null);
		return resource.getContents().get(0);
	} catch (IOException e) {
		LogUtil.error(e);
	}
	return null;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:AbstractPatchTestWithAllFeatureTypes.java

示例15: getModelXML

import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; //导入依赖的package包/类
private String getModelXML(EObject toCompare) {
	try {
		ByteArrayOutputStream oStream = new ByteArrayOutputStream();
		Resource res = new XMLResourceImpl(URI.createURI("dummyfile.xml"));
		res.getContents().add(EcoreUtil.copy(toCompare));
		res.save(oStream, null);
		oStream.flush();
		oStream.close();
		String file = new String(oStream.toByteArray());
		return file;
	} catch (IOException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:leondart,项目名称:FRaMED,代码行数:16,代码来源:TransformationTestSuite.java


注:本文中的org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。