类org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectInputStream源码实例Demo

下面列出了怎么用org.eclipse.emf.ecore.resource.impl.BinaryResourceImpl.EObjectInputStream的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xtext-core   文件: QualifiedName.java
/**
 * Internal low level factory method.
 * @noreference This method is not intended to be referenced by clients.
 * @since 2.4
 */
public static QualifiedName createFromStream(EObjectInputStream eObjectInputStream) throws IOException{
	int segmentCount = eObjectInputStream.readCompressedInt();
	if (segmentCount == 0) {
		return QualifiedName.EMPTY;
	}
	// lowercase QN serialize a 'null' value at index 0 and
	String firstSegment = eObjectInputStream.readSegmentedString();
	boolean lowerCase = false;
	if (firstSegment == null) {
		lowerCase = true;
		// first was null, read another string which is the actual first segment
		firstSegment = eObjectInputStream.readSegmentedString();
		if(firstSegment == null){
			throw new IllegalStateException("Read unexpected first segment from object stream");
		}
	}

	String[] segments = readSegmentArray(eObjectInputStream, segmentCount, firstSegment);
	if (lowerCase) {
		return new QualifiedNameLowerCase(segments);
	} else {
		return new QualifiedName(segments);
	}
}
 
源代码2 项目: xtext-core   文件: QualifiedNameTest.java
@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);
}
 
源代码3 项目: xtext-core   文件: QualifiedName.java
private static String[] readSegmentArray(EObjectInputStream from, int count, String first) throws IOException {
	String[] segments = new String[count];
	segments[0] = intern(first);
	for (int i = 1; i < count; i++) {
		String segment = from.readSegmentedString();
		if(segment == null){
			throw new IllegalStateException("Read unexpected segment (#" + i + ") from object stream");
		}
		segments[i] = intern(segment);
	}
	return segments;
}
 
源代码4 项目: xtext-eclipse   文件: BuilderStateFactoryImpl.java
@Override
public QualifiedName read(EObjectInputStream eObjectInputStream) throws IOException {
	return QualifiedName.createFromStream(eObjectInputStream);
}
 
源代码5 项目: xtext-eclipse   文件: BuilderStateFactoryImpl.java
@Override
public URI read(EObjectInputStream eObjectInputStream) throws IOException {
	return eObjectInputStream.readURI();
}
 
 类所在包
 类方法
 同包方法