• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ISerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getSerializer

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
private static ISerializer getSerializer(final String delimiter) {
	ISerializer result = xtextSerializerByLineDelimiter.get(delimiter);
	if (result != null) {
		return result;
	}
	final ILineSeparatorInformation lineSeparatorInformation = new ILineSeparatorInformation() {
		@Override
		public String getLineSeparator() {
			return delimiter;
		}
	};
	Injector injector = Guice.createInjector(new LineSeparatorModule(lineSeparatorInformation));
	result = injector.getInstance(ISerializer.class);
	xtextSerializerByLineDelimiter.put(delimiter, result);
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:GrammarAccessUtil.java


示例2: testSerialize_01

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
@Test public void testSerialize_01() throws Exception {
	Resource resource = newResource("'foo' as String");
	XCastedExpression casted = (XCastedExpression) resource.getContents().get(0);
	
	XbaseFactory factory = XbaseFactory.eINSTANCE;
	XClosure closure = factory.createXClosure();
	XStringLiteral stringLiteral = factory.createXStringLiteral();
	stringLiteral.setValue("value");
	XBlockExpression blockExpression = factory.createXBlockExpression();
	blockExpression.getExpressions().add(stringLiteral);
	closure.setExpression(blockExpression);
	closure.setExplicitSyntax(true);
	XInstanceOfExpression instanceOfExpression = factory.createXInstanceOfExpression();
	instanceOfExpression.setExpression(closure);
	instanceOfExpression.setType(EcoreUtil.copy(casted.getType()));
	resource.getContents().clear();
	resource.getContents().add(instanceOfExpression);
	ISerializer serializer = get(ISerializer.class);
	String string = serializer.serialize(instanceOfExpression);
	assertEquals("[|\"value\"] instanceof String", string);
	
	XInstanceOfExpression parsedExpression = parseHelper.parse(string);
	assertTrue(EcoreUtil.equals(instanceOfExpression, parsedExpression));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:25,代码来源:SerializerTest.java


示例3: grammarFragmentToString

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
/**
 * @noreference
 */
public static String grammarFragmentToString(final ISerializer serializer, final EObject object, final String prefix) {
  String s = null;
  try {
    final SaveOptions options = SaveOptions.newBuilder().format().getOptions();
    s = serializer.serialize(object, options);
  } catch (final Throwable _t) {
    if (_t instanceof Exception) {
      final Exception e = (Exception)_t;
      s = e.toString();
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  }
  String _replace = s.trim().replaceAll("(\\r?\\n)", ("$1" + prefix)).replace("\\u", "\\\\u");
  String _plus = (prefix + _replace);
  s = _plus;
  return s;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:22,代码来源:GrammarAccessExtensions.java


示例4: testSerializeAndReparse

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
@Test public void testSerializeAndReparse() throws Exception {
	int intValue=34786482;
	double doubleValue=2.32E-17;
	Date dateValue = new SimpleDateFormat("YYYY-MM-DD").parse("2010-05-25");
	Model model = EcoreTerminalsTestLanguageFactory.eINSTANCE.createModel();
	model.getIntValues().add(intValue);
	model.getDoubleValues().add(doubleValue);
	model.getDateValues().add(dateValue);
	ISerializer serializer = get(ISerializer.class);
	String modelAsString = serializer.serialize(model);
	
	Model reparsedModel = (Model) getModel(modelAsString);
	assertEquals(intValue, (int) reparsedModel.getIntValues().get(0));
	assertEquals(doubleValue, reparsedModel.getDoubleValues().get(0), 0.00001);
	assertEquals(dateValue, reparsedModel.getDateValues().get(0));
	
	try {
		model.getDoubleValues().add(-doubleValue);
		modelAsString = serializer.serialize(model);
		fail("Serialization should fail");
	} catch (Exception exc) {
		// normal case
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:DefaultTerminalConverterTest.java


示例5: getGuiceBindingsRt

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
@Override
public Set<Binding> getGuiceBindingsRt(final Grammar grammar) {
  final BindFactory bf = new BindFactory();
  bf.addTypeToType(ISemanticSequencer.class.getName(), this.names.getSemanticSequencer().getQualifiedName());
  bf.addTypeToType(ISyntacticSequencer.class.getName(), this.names.getSyntacticSequencer().getQualifiedName());
  bf.addTypeToType(ISerializer.class.getName(), Serializer.class.getName());
  return bf.getBindings();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:SerializerFragment.java


示例6: testSerialize_ExtrasIssue164

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
@Test public void testSerialize_ExtrasIssue164() throws Exception {
	DerivedStateAwareResource resource = (DerivedStateAwareResource) newResource("org.eclipse.xtext.xbase.tests.serializer.SerializerTest.Demo.demo");
	XMemberFeatureCall call = (XMemberFeatureCall) resource.getContents().get(0);
	ISerializer serializer = get(ISerializer.class);
	call.eAdapters().clear();
	String string = serializer.serialize(call);
	assertEquals("org.eclipse.xtext.xbase.tests.serializer.SerializerTest.Demo.demo", string);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:SerializerTest.java


示例7: testSerialize_ExtrasIssue164_02

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
@Test public void testSerialize_ExtrasIssue164_02() throws Exception {
	DerivedStateAwareResource resource = (DerivedStateAwareResource) newResource("org.eclipse.xtext.xbase.tests.serializer.SerializerTest.Demo.getDemo2(1)");
	XMemberFeatureCall call = (XMemberFeatureCall) resource.getContents().get(0);
	ISerializer serializer = get(ISerializer.class);
	call.eAdapters().clear();
	String string = serializer.serialize(call);
	assertEquals("org.eclipse.xtext.xbase.tests.serializer.SerializerTest.Demo.getDemo2(1)", string);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:SerializerTest.java


示例8: getSerializer

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
private ISerializer getSerializer() {
  final String delimiter = this.codeConfig.getLineDelimiter();
  ISerializer result = this.xtextSerializerByLineDelimiter.get(delimiter);
  if ((result != null)) {
    return result;
  }
  final ILineSeparatorInformation _function = () -> {
    return delimiter;
  };
  GrammarAccessExtensions.LineSeparatorModule _lineSeparatorModule = new GrammarAccessExtensions.LineSeparatorModule(_function);
  final Injector injector = Guice.createInjector(_lineSeparatorModule);
  result = injector.<ISerializer>getInstance(ISerializer.class);
  this.xtextSerializerByLineDelimiter.put(delimiter, result);
  return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:16,代码来源:GrammarAccessExtensions.java


示例9: bindISerializer

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
public Class<? extends ISerializer> bindISerializer() {
	return Serializer.class;
}
 
开发者ID:rehne93,项目名称:pokemon-tcgo-deck-generator,代码行数:4,代码来源:AbstractPkmntcgoRuntimeModule.java


示例10: bindISerializer

import org.eclipse.xtext.serializer.ISerializer; //导入依赖的package包/类
/**
 * A custom serializer class that allows to access otherwise protected methods.
 */
@Override
public Class<? extends ISerializer> bindISerializer() {
	return AccessibleSerializer.class;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:8,代码来源:N4JSRuntimeModule.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Step类代码示例发布时间:2022-05-21
下一篇:
Java SelectRequest类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap