org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream Java Examples

The following examples show how to use org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectOutputStream. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QualifiedNameTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: QualifiedName.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Internal low level serialization of QualifiedNames.
 * @since 2.4
 */
public void writeToStream(EObjectOutputStream eObjectOutputStream) throws IOException {
	int segmentCount = getSegmentCount();
	eObjectOutputStream.writeCompressedInt(segmentCount);
	for (int i = 0; i < segmentCount; ++i) {
		eObjectOutputStream.writeSegmentedString(getSegment(i));
	}
}
 
Example #3
Source File: QualifiedName.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * We serialize a segmentCount + 1 and a dummy null value as the first entry.
 * This is used to retrieve the information about lowercase QN in {@link QualifiedName#createFromStream(EObjectInputStream)}
 */
@Override
public void writeToStream(EObjectOutputStream eObjectOutputStream) throws IOException {
	int segmentCount = getSegmentCount();
	eObjectOutputStream.writeCompressedInt(segmentCount);
	// indicator for lowercase instance
	eObjectOutputStream.writeSegmentedString(null);
	for (int i = 0; i < segmentCount; ++i) {
		eObjectOutputStream.writeSegmentedString(getSegment(i));
	}
}
 
Example #4
Source File: BuilderStateFactoryImpl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void doWrite(EObjectOutputStream eObjectOutputStream, QualifiedName value) throws IOException {
	value.writeToStream(eObjectOutputStream);
}
 
Example #5
Source File: BuilderStateFactoryImpl.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void doWrite(EObjectOutputStream eObjectOutputStream, URI value) throws IOException {
	eObjectOutputStream.writeURI(value);
}