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


Java Serializer.serialize方法代码示例

本文整理汇总了Java中org.eclipse.xtext.serializer.impl.Serializer.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java Serializer.serialize方法的具体用法?Java Serializer.serialize怎么用?Java Serializer.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.serializer.impl.Serializer的用法示例。


在下文中一共展示了Serializer.serialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.eclipse.xtext.serializer.impl.Serializer; //导入方法依赖的package包/类
public static void main(String[] args) {
	// Getting the serializer
	GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
	Injector injector = setup.createInjectorAndDoEMFRegistration();
	Serializer serializer = injector.getInstance(Serializer.class);

	// Creating a model
	GexpressionsFactory factory = GexpressionsFactory.eINSTANCE;
	GAdditionExpression exp = factory.createGAdditionExpression();
	GIntegerExpression un = factory.createGIntegerExpression();
	un.setValue(1);
	GStringExpression deux = factory.createGStringExpression();
	deux.setValue("deux");
	exp.setLeftOperand(un);
	exp.setRightOperand(deux);

	// Serializing
	String s = serializer.serialize(exp);
	System.out.println(s);
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:21,代码来源:TestXtextSerializer.java

示例2: loadGexpressionTestFile

import org.eclipse.xtext.serializer.impl.Serializer; //导入方法依赖的package包/类
public static void loadGexpressionTestFile() {
	// Getting the serializer
	GExpressionsStandaloneSetup setup = new GExpressionsStandaloneSetup();
	Injector injector = setup.createInjectorAndDoEMFRegistration();
	GexpressionsPackage.eINSTANCE.eClass();
	Serializer serializer = injector.getInstance(Serializer.class);

	// Load the model
	URI modelURI = URI
			.createFileURI("/home/flatombe/thesis/gemoc/git/gemoc-dev/org/eclipse/gemoc/GEL/org.eclipse.gemoc.gel.gexpressions.test/model/test.gexpressions");
	XtextResourceSet resSet = injector.getInstance(XtextResourceSet.class);
	resSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
	Resource resource = resSet.getResource(modelURI, true);
	GProgram program = (GProgram) resource.getContents().get(0);

	List<GExpression> exps = program.getExpressions();
	for (GExpression exp : exps) {
		// Serializing
		String s = serializer.serialize(exp);
		System.out.println(s);
	}
}
 
开发者ID:eclipse,项目名称:gemoc-studio,代码行数:23,代码来源:TestXtextSerializer2.java

示例3: testBug370426

import org.eclipse.xtext.serializer.impl.Serializer; //导入方法依赖的package包/类
@Test public void testBug370426() throws Exception {
	with(SimpleExpressionsTestLanguageStandaloneSetup.class);
	String model = "a/b\n+c";
	XtextResource resource = getResourceFromString(model);
	assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
	// turn /b into a comment
	resource.update(model.indexOf("/"), 0, "/");
	assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
	Serializer serializer = get(Serializer.class);
	String newModel = serializer.serialize(EcoreUtil.copy(resource.getContents().get(0)));
	assertEquals("a + c", newModel);
	
	// change comment back into /b 		
	resource.update(model.indexOf("/"), 1, "");
	assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
	assertEquals(model, serialize(resource.getContents().get(0)));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:PartialParserTest.java


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