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

Java BinaryResourceImpl类代码示例

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

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



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

示例1: readContents

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
protected void readContents(final StorageAwareResource resource, final InputStream inputStream) throws IOException {
  Map<Object, Object> _emptyMap = CollectionLiterals.<Object, Object>emptyMap();
  final BinaryResourceImpl.EObjectInputStream in = new BinaryResourceImpl.EObjectInputStream(inputStream, _emptyMap) {
    @Override
    public int readCompressedInt() throws IOException {
      int _xblockexpression = (int) 0;
      {
        this.resourceSet = null;
        _xblockexpression = super.readCompressedInt();
      }
      return _xblockexpression;
    }
    
    @Override
    public InternalEObject loadEObject() throws IOException {
      final InternalEObject result = super.loadEObject();
      ResourceStorageLoadable.this.handleLoadEObject(result, this);
      return result;
    }
  };
  in.loadResource(resource);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:23,代码来源:ResourceStorageLoadable.java


示例2: testDeserializeAsLowerCase

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
@Test public void testDeserializeAsLowerCase() throws IOException {
	QualifiedName upperCase = QualifiedName.create("A", "B");
	QualifiedName lowerCase = upperCase.toLowerCase();
	
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	EObjectOutputStream out = new BinaryResourceImpl.EObjectOutputStream(bos, Collections.emptyMap());
	upperCase.writeToStream(out);
	lowerCase.writeToStream(out);
	out.flush();
	
	EObjectInputStream in = new BinaryResourceImpl.EObjectInputStream(new ByteArrayInputStream(bos.toByteArray()), Collections.emptyMap());
	QualifiedName readUpperCase = QualifiedName.createFromStream(in);
	QualifiedName readLowerCase = QualifiedName.createFromStream(in);
	assertEquals(QualifiedName.class.getName(), readUpperCase.getClass().getName());
	assertEquals(QualifiedName.class.getName() + "$QualifiedNameLowerCase", readLowerCase.getClass().getName());
	assertEquals(upperCase, readUpperCase);
	assertEquals(lowerCase, readLowerCase);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:QualifiedNameTest.java


示例3: beforeSaveEObject

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
@Override
protected Object beforeSaveEObject(final InternalEObject object, final BinaryResourceImpl.EObjectOutputStream writable) throws IOException {
  JvmType _xblockexpression = null;
  {
    super.beforeSaveEObject(object, writable);
    JvmType _xifexpression = null;
    if ((object instanceof XComputedTypeReference)) {
      _xifexpression = ((XComputedTypeReference)object).getType();
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:14,代码来源:BatchLinkableResourceStorageWritable.java


示例4: handleSaveEObject

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
@Override
protected void handleSaveEObject(final InternalEObject object, final BinaryResourceImpl.EObjectOutputStream out) throws IOException {
  super.handleSaveEObject(object, out);
  DocumentationAdapter documentationAdapter = null;
  JvmIdentifiableMetaData metaDataAdapter = null;
  EList<Adapter> _eAdapters = object.eAdapters();
  for (final Adapter adapter : _eAdapters) {
    {
      if ((adapter instanceof DocumentationAdapter)) {
        documentationAdapter = ((DocumentationAdapter)adapter);
      }
      if ((adapter instanceof JvmIdentifiableMetaData)) {
        metaDataAdapter = ((JvmIdentifiableMetaData)adapter);
      }
    }
  }
  if ((documentationAdapter != null)) {
    out.writeBoolean(true);
    out.writeString(documentationAdapter.getDocumentation());
  } else {
    out.writeBoolean(false);
  }
  if ((metaDataAdapter != null)) {
    out.writeBoolean(true);
    out.writeBoolean(metaDataAdapter.isSynthetic());
  } else {
    out.writeBoolean(false);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:30,代码来源:BatchLinkableResourceStorageWritable.java


示例5: generate

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
@Override
public void generate(Grammar grammar, XpandExecutionContext ctx) {
	RuleNames.ensureAdapterInstalled(grammar);
	super.generate(grammar, ctx);

	final ResourceSaveIndicator isSaving = new ResourceSaveIndicator();
	// create a defensive clone
	Grammar copy = deepCopy(grammar, isSaving);
	ResourceSet set = copy.eResource().getResourceSet();

	// save grammar model
	String path;
	if (xmlVersion == null) {
		path = GrammarUtil.getClasspathRelativePathToBinGrammar(copy);
	} else {
		log.warn("'xmlVersion' has been specified for this "
				+ GrammarAccessFragment.class.getSimpleName()
				+ ". Therefore, the grammar is persisted as XMI and not as binary. This can be a performance drawback.");
		path = GrammarUtil.getClasspathRelativePathToXmi(copy);
	}
	URI uri = URI.createURI(ctx.getOutput().getOutlet(Generator.SRC_GEN).getPath() + "/" + path);
	Resource resource = set.createResource(uri, ContentHandler.UNSPECIFIED_CONTENT_TYPE);
	addAllGrammarsToResource(resource, copy, new HashSet<Grammar>());
	isSaving.set(Boolean.TRUE);
	Map<String, Object> saveOptions = Maps.newHashMap();
	if (resource instanceof XMLResource) {
		((XMLResource) resource).setXMLVersion(getXmlVersion());
	} else if (resource instanceof BinaryResourceImpl){
		saveOptions.put(BinaryResourceImpl.OPTION_VERSION, BinaryResourceImpl.BinaryIO.Version.VERSION_1_1);
		saveOptions.put(BinaryResourceImpl.OPTION_STYLE_DATA_CONVERTER, Boolean.TRUE);
	}
	try {
		resource.save(saveOptions);
	} catch (IOException e) {
		log.error(e.getMessage(), e);
	} finally {
		isSaving.set(Boolean.FALSE);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:40,代码来源:GrammarAccessFragment.java


示例6: writeContents

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
protected void writeContents(final StorageAwareResource storageAwareResource, final OutputStream outputStream) throws IOException {
  Map<Object, Object> _emptyMap = CollectionLiterals.<Object, Object>emptyMap();
  final BinaryResourceImpl.EObjectOutputStream out = new BinaryResourceImpl.EObjectOutputStream(outputStream, _emptyMap) {
    @Override
    public void writeURI(final URI uri, final String fragment) throws IOException {
      final URI fullURI = uri.appendFragment(fragment);
      URI _elvis = null;
      URI _portableURI = storageAwareResource.getPortableURIs().toPortableURI(storageAwareResource, fullURI);
      if (_portableURI != null) {
        _elvis = _portableURI;
      } else {
        _elvis = fullURI;
      }
      final URI uriToWrite = _elvis;
      super.writeURI(uriToWrite.trimFragment(), uriToWrite.fragment());
    }
    
    @Override
    public void saveEObject(final InternalEObject internalEObject, final BinaryResourceImpl.EObjectOutputStream.Check check) throws IOException {
      ResourceStorageWritable.this.beforeSaveEObject(internalEObject, this);
      super.saveEObject(internalEObject, check);
      ResourceStorageWritable.this.handleSaveEObject(internalEObject, this);
    }
  };
  try {
    out.saveResource(storageAwareResource);
  } finally {
    out.flush();
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:31,代码来源:ResourceStorageWritable.java


示例7: theTest

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
@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);
}
 
开发者ID:markus1978,项目名称:emf-fragments,代码行数:30,代码来源:EmfSaveLargeChainTest.java


示例8: handleLoadEObject

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
protected Object handleLoadEObject(final InternalEObject loaded, final BinaryResourceImpl.EObjectInputStream input) throws IOException {
  return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:4,代码来源:ResourceStorageLoadable.java


示例9: beforeSaveEObject

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
protected Object beforeSaveEObject(final InternalEObject object, final BinaryResourceImpl.EObjectOutputStream writable) throws IOException {
  return null;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:4,代码来源:ResourceStorageWritable.java


示例10: handleSaveEObject

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
protected void handleSaveEObject(final InternalEObject object, final BinaryResourceImpl.EObjectOutputStream out) throws IOException {
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:3,代码来源:ResourceStorageWritable.java


示例11: writeGrammar

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
protected void writeGrammar() {
  final Wrapper<Boolean> isSaving = Wrapper.<Boolean>wrap(Boolean.valueOf(false));
  final ResourceSet cloneInto = new ResourceSetImpl();
  Map<String, Object> _extensionToFactoryMap = cloneInto.getResourceFactoryRegistry().getExtensionToFactoryMap();
  FragmentFakingEcoreResource.FactoryImpl _factoryImpl = new FragmentFakingEcoreResource.FactoryImpl(isSaving);
  _extensionToFactoryMap.put(
    FragmentFakingEcoreResource.FactoryImpl.ECORE_SUFFIX, _factoryImpl);
  final ResourceSet resourceSet = EcoreUtil2.<ResourceSet>clone(cloneInto, this.getLanguage().getGrammar().eResource().getResourceSet());
  EObject _head = IterableExtensions.<EObject>head(resourceSet.getResource(this.getLanguage().getGrammar().eResource().getURI(), true).getContents());
  final Grammar copy = ((Grammar) _head);
  String _xifexpression = null;
  if ((this.xmlVersion == null)) {
    _xifexpression = GrammarUtil.getClasspathRelativePathToBinGrammar(copy);
  } else {
    String _xblockexpression = null;
    {
      String _simpleName = GrammarAccessFragment2.class.getSimpleName();
      String _plus = ("The property \'xmlVersion\' has been specified for this " + _simpleName);
      String _plus_1 = (_plus + ". Therefore, the grammar is persisted as XMI and not as binary. This can be a performance drawback.");
      GrammarAccessFragment2.LOG.warn(_plus_1);
      _xblockexpression = GrammarUtil.getClasspathRelativePathToXmi(copy);
    }
    _xifexpression = _xblockexpression;
  }
  final String path = _xifexpression;
  final URI uri = this.getProjectConfig().getRuntime().getSrcGen().getURI(path);
  final Resource resource = resourceSet.createResource(uri, ContentHandler.UNSPECIFIED_CONTENT_TYPE);
  HashSet<Grammar> _hashSet = new HashSet<Grammar>();
  this.addAllGrammarsToResource(resource, copy, _hashSet);
  isSaving.set(Boolean.valueOf(true));
  final Map<String, Object> saveOptions = CollectionLiterals.<String, Object>newHashMap();
  if ((resource instanceof XMLResource)) {
    String _elvis = null;
    if (this.xmlVersion != null) {
      _elvis = this.xmlVersion;
    } else {
      _elvis = "1.0";
    }
    ((XMLResource)resource).setXMLVersion(_elvis);
  } else {
    if ((resource instanceof BinaryResourceImpl)) {
      saveOptions.put(BinaryResourceImpl.OPTION_VERSION, BinaryResourceImpl.BinaryIO.Version.VERSION_1_1);
      saveOptions.put(BinaryResourceImpl.OPTION_STYLE_DATA_CONVERTER, Boolean.valueOf(true));
    }
  }
  try {
    resource.save(saveOptions);
  } catch (final Throwable _t) {
    if (_t instanceof IOException) {
      final IOException e = (IOException)_t;
      GrammarAccessFragment2.LOG.error(e.getMessage(), e);
    } else {
      throw Exceptions.sneakyThrow(_t);
    }
  } finally {
    isSaving.set(Boolean.valueOf(false));
  }
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:59,代码来源:GrammarAccessFragment2.java


示例12: createResource

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
@Override
public Resource createResource(URI uri) {
	return new BinaryResourceImpl(uri);
}
 
开发者ID:opencanarias,项目名称:model-repository-benchmark,代码行数:5,代码来源:BenchmarkUtils.java


示例13: create

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
/**
 * @since 2.9
 */
public BinaryResourceImpl.DataConverter<?> create(EDataType eDataType)
{
  return null;
}
 
开发者ID:LangleyStudios,项目名称:eclipse-avro,代码行数:8,代码来源:EFactoryImpl.java


示例14: createResourceSet

import org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:aranega,项目名称:dynemf,代码行数:28,代码来源:ResourceSetWrapper.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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