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

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

源代码1 项目: M2Doc   文件: M2DocNewProjectWizard.java
/**
 * Creates the sample template.
 * 
 * @param templateName
 *            the template name
 * @param variableName
 *            the variable name
 * @param variableValue
 *            the variable value
 * @param monitor
 *            the {@link IProgressMonitor}
 * @param project
 *            the {@link IllegalPropertySetDataException}
 * @return
 * @throws IOException
 *             if the template file can't be saved
 * @throws CoreException
 *             if the template file can't be saved
 * @throws InvalidFormatException
 *             if the sample template can't be read
 * @return the template {@link URI}
 */
private URI createSampleTemplate(final String templateName, final String variableName, final EObject variableValue,
        IProgressMonitor monitor, final IProject project)
        throws IOException, CoreException, InvalidFormatException {
    final URI res;

    final URIConverter uriConverter = new ExtensibleURIConverterImpl();
    final MemoryURIHandler handler = new MemoryURIHandler();
    uriConverter.getURIHandlers().add(0, handler);
    try (XWPFDocument sampleTemplate = M2DocUtils.createSampleTemplate(variableName, variableValue.eClass());) {
        final URI memoryURI = URI
                .createURI(MemoryURIHandler.PROTOCOL + "://resources/temp." + M2DocUtils.DOCX_EXTENSION_FILE);
        POIServices.getInstance().saveFile(uriConverter, sampleTemplate, memoryURI);

        try (InputStream source = uriConverter.createInputStream(memoryURI)) {
            final IFile templateFile = project.getFile(templateName);
            templateFile.create(source, true, monitor);
            res = URI.createPlatformResourceURI(templateFile.getFullPath().toString(), true);
        }
    }

    return res;
}
 
源代码2 项目: txtUML   文件: ModelMapCollector.java
/**
 * Save the mapping to file.
 * 
 * @param directory
 *            Directory to put the file in.
 * @param filename
 *            Name of the file (without extension).
 * @throws FileNotFoundException
 * @throws IOException
 */
public void save(URI directory, String filename) throws ModelMapException {
	URI uri = ModelMapUtils.createMappingURI(directory, filename);
	if (uri == null) {
		throw new ModelMapException(CANNOT_CREATE_URI);
	}
	try {
		OutputStream out = new ExtensibleURIConverterImpl().createOutputStream(uri);
		ObjectOutputStream stream = new ObjectOutputStream(out);
		stream.writeObject(path);
		stream.writeObject(map);
		stream.close();
	} catch (IOException e) {
		throw new ModelMapException(e);
	}
}
 
@Before
public void setUp() throws Exception {
	fileSystem = Maps.newHashMap();
	builderState = builderInjector.getInstance(ClusteringBuilderState.class);
	uriConverter = new ExtensibleURIConverterImpl() {
		@Override
		public InputStream createInputStream(org.eclipse.emf.common.util.URI uri, Map<?, ?> options)
				throws IOException {
			return new StringInputStream(fileSystem.get(uri.toString()));
		}
	};

}
 
@Override
protected synchronized URIConverter getURIConverter() {
	if (this.uriConverter == null) {
		List<ContentHandler> withoutPlatformDelegate = Lists.newArrayList();
		for (ContentHandler contentHandler : ContentHandler.Registry.INSTANCE.contentHandlers()) {
			if (!isTooEager(contentHandler))
				withoutPlatformDelegate.add(contentHandler);
		}
		this.uriConverter = new ExtensibleURIConverterImpl(URIHandler.DEFAULT_HANDLERS, withoutPlatformDelegate);
	}
	return this.uriConverter;
}
 
源代码5 项目: txtUML   文件: URIFragmentMapper.java
public URIFragmentMapper(URI directory, String filename) throws ModelMapException {
	URI mappingURI = ModelMapUtils.createMappingURI(directory, filename);

	try {
		InputStream in = new ExtensibleURIConverterImpl().createInputStream(mappingURI);
		ObjectInputStream stream = new ObjectInputStream(in);
		Object modelPathObject = stream.readObject();
		Object mapObject = stream.readObject();
		if (modelPathObject == null || !(modelPathObject instanceof String) || mapObject == null
				|| !(mapObject instanceof Map<?, ?>)) {
			throw new ModelMapException(INVALID_MAPPING_FILE_CONTENT);
		}
		modelPath = (String) modelPathObject;
		/*
		 * The 'if' above verifies that the map has been successfully
		 * retrieved from the file and it is really a map. However, key and
		 * value types are not verified. It seems unnecessary overhead to
		 * check those as well and to construct a new, type-safe map,
		 * therefore the warning is suppressed. The localMap variable is
		 * only needed to make the scope of the suppression minimal.
		 */
		@SuppressWarnings("unchecked")
		Map<String, String> localMap = (Map<String, String>) mapObject;
		map = localMap;
		stream.close();
	} catch (IOException | ClassNotFoundException e) {
		throw new ModelMapException(e);
	}
}
 
源代码6 项目: xtext-core   文件: ResourceStorageFacade.java
@Override
public boolean hasStorageFor(URI uri) {
	return new ExtensibleURIConverterImpl().exists(getBinaryStorageURI(uri), Collections.emptyMap());
}
 
源代码7 项目: xtext-core   文件: ExternalContentSupportTest.java
@Test public void testConfigureConverter() {
	URIConverter converter = new ExtensibleURIConverterImpl();
	support.configureConverter(converter, this);
	checkConverter(converter);
}
 
 类所在包
 类方法
 同包方法