本文整理汇总了Java中org.eclipse.emf.ecore.resource.URIConverter类的典型用法代码示例。如果您正苦于以下问题:Java URIConverter类的具体用法?Java URIConverter怎么用?Java URIConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URIConverter类属于org.eclipse.emf.ecore.resource包,在下文中一共展示了URIConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMissingVariables
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Test
public void getMissingVariables() throws IOException, InvalidFormatException {
try (XWPFDocument document = POIServices.getInstance().getXWPFDocument(URIConverter.INSTANCE,
URI.createFileURI("resources/document/properties/missingVariables.docx"));) {
final TemplateCustomProperties properties = new TemplateCustomProperties(document);
final List<String> missingVariables = properties.getMissingVariables();
assertEquals(16, missingVariables.size());
assertEquals("linkNamelinkText", missingVariables.get(0));
assertEquals("bookmarkName", missingVariables.get(1));
assertEquals("queryInBookmark", missingVariables.get(2));
assertEquals("ifCondition", missingVariables.get(3));
assertEquals("queryInIf", missingVariables.get(4));
assertEquals("elseIfCondition", missingVariables.get(5));
assertEquals("queryInElseIf", missingVariables.get(6));
assertEquals("queryInElse", missingVariables.get(7));
assertEquals("letExpression", missingVariables.get(8));
assertEquals("queryInLet", missingVariables.get(9));
assertEquals("forExpression", missingVariables.get(10));
assertEquals("queryInFor", missingVariables.get(11));
assertEquals("queryExpression", missingVariables.get(12));
assertEquals("aqlInSelect", missingVariables.get(13));
assertEquals("aqlLetExpression", missingVariables.get(14));
assertEquals("aqlLetBody", missingVariables.get(15));
}
}
示例2: getTextContent
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
/**
* Gets the textual element of the .docx at the given {@link URI}.
*
* @param uriConverter
* the {@link URIConverter}
* @param uri
* the .docx {@link URI}
* @return the textual element of the .docx at the given {@link URI}
*/
public static String getTextContent(URIConverter uriConverter, URI uri) {
String result = "";
try (InputStream is = uriConverter.createInputStream(uri);
OPCPackage oPackage = OPCPackage.open(is);
XWPFDocument document = new XWPFDocument(oPackage);
XWPFWordExtractor ex = new XWPFWordExtractor(document);) {
result += "===== Document Text ====\n";
result += ex.getText();
// CHECKSTYLE:OFF
} catch (Throwable e) {
// CHECKSTYLE:ON
/*
* if for some reason we can't use POI to get the text content then move along, we'll still get the XML and hashs
*/
}
return result;
}
示例3: provides
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Override
public boolean provides(ResourceSet set) {
final boolean res;
if (set != null && set.getURIConverter() != null) {
URIConverter converter = set.getURIConverter();
if (converter.getURIHandlers().size() > 0) {
res = converter.getURIHandlers().get(0) instanceof DebugURIHandler;
} else {
res = false;
}
} else {
res = false;
}
return res;
}
示例4: api
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Ignore
@Test
public void api() {
final File apiFile = new File("/Users/mkoester/Development/commercetools-api-reference/api.raml");
assumeTrue(apiFile.exists());
final URI apiUri = URI.createURI(apiFile.toURI().toString());
final URIConverter uriConverter = new RamlResourceSet().getURIConverter();
final RAMLCustomLexer lexer = new RAMLCustomLexer(apiUri, uriConverter);
final TokenStream tokenStream = new CommonTokenStream(lexer);
final RAMLParser parser = new RAMLParser(tokenStream);
final Resource resource = new RamlResourceSet().createResource(apiUri);
final Scope scope = Scope.of(resource);
final TypeDeclarationResolver resolver = new TypeDeclarationResolver();
resolver.resolve(parser.api(), scope);
assertThat(resource.getErrors()).isEmpty();
}
示例5: updateTemplateCustomProperties
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
/**
* Updates {@link TemplateCustomProperties}.
*
* @param uri
* the template {@link URI}
*/
private void updateTemplateCustomProperties(URI uri) {
final URI absoluteURI = uri.resolve(getGenconfResource().getURI());
if (URIConverter.INSTANCE.exists(absoluteURI, null)) {
try {
templateCustomProperties = POIServices.getInstance().getTemplateCustomProperties(absoluteURI);
final Generation generation = getGeneration();
final List<Definition> newDefinitions = GenconfUtils.getNewDefinitions(generation,
templateCustomProperties);
editingDomain.getCommandStack().execute(AddCommand.create(editingDomain, generation,
GenconfPackage.GENERATION__DEFINITIONS, newDefinitions));
// CHECKSTYLE:OFF
} catch (Exception e) {
// CHECKSTYLE:ON
templateCustomProperties = null;
}
}
}
示例6: MImageImpl
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
/**
* Constructor with enforced image type.
*
* @param uriConverter
* the {@link URIConverter uri converter} to use.
* @param uri
* the {@link URI}
* @param type
* the picture {@link PictureType type}.
*/
public MImageImpl(URIConverter uriConverter, URI uri, PictureType type) {
this.uriConverter = uriConverter;
this.uri = uri;
this.type = type;
try {
final BufferedImage image = ImageIO.read(getInputStream());
if (image != null) {
width = image.getWidth();
height = image.getHeight();
conserveRatio = true;
ratio = ((double) width) / ((double) height);
} else {
conserveRatio = false;
ratio = -1;
}
} catch (IOException e) {
// will continue with out ratio and width x height preset
ratio = -1;
}
}
示例7: prepareEnvironmentServices
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
/**
* Prepares the given {@link IQueryEnvironment} for M2Doc services.
*
* @param queryEnvironment
* the {@link IQueryEnvironment}
* @param uriConverter
* the {@link URIConverter uri converter} to use.
* @param templateURI
* the template {@link URI}
* @param options
* the {@link Map} of options
*/
public static void prepareEnvironmentServices(IQueryEnvironment queryEnvironment, URIConverter uriConverter,
URI templateURI, Map<String, String> options) {
Set<IService> services = ServiceUtils.getServices(queryEnvironment, BooleanServices.class);
ServiceUtils.registerServices(queryEnvironment, services);
services = ServiceUtils.getServices(queryEnvironment, LinkServices.class);
ServiceUtils.registerServices(queryEnvironment, services);
services = ServiceUtils.getServices(queryEnvironment, PaginationServices.class);
ServiceUtils.registerServices(queryEnvironment, services);
services = ServiceUtils.getServices(queryEnvironment, new ImageServices(uriConverter, templateURI));
ServiceUtils.registerServices(queryEnvironment, services);
services = ServiceUtils.getServices(queryEnvironment, new ExcelServices(uriConverter, templateURI));
ServiceUtils.registerServices(queryEnvironment, services);
for (IServicesConfigurator configurator : getConfigurators()) {
ServiceUtils.registerServices(queryEnvironment, configurator.getServices(queryEnvironment, options));
}
}
示例8: getSessionString
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
/**
* Gets the {@link Session} option from the generation URI string.
*
* @param genConfURIStr
* the generation URI string
* @return the {@link Session} option from the generation URI string
*/
protected String getSessionString(final String genConfURIStr) {
final String res;
if (genConfURIStr != null) {
final URI genConfURI = URI.createURI(genConfURIStr, false);
if (URIConverter.INSTANCE.exists(genConfURI, Collections.emptyMap()) && genConfURI.isPlatformResource()) {
res = getSessionFromPlatformResource(genConfURI);
} else {
res = null;
}
} else {
res = null;
}
return res;
}
示例9: getServices
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Override
public Set<IService> getServices(IReadOnlyQueryEnvironment queryEnvironment, Map<String, String> options) {
final Set<IService> res = new LinkedHashSet<>();
final String sessionURIStr = options.get(M2DocSiriusUtils.SIRIUS_SESSION_OPTION);
if (sessionURIStr != null) {
URI sessionURI = URI.createURI(sessionURIStr, false);
final String genconfURIStr = options.get(GenconfUtils.GENCONF_URI_OPTION);
if (genconfURIStr != null) {
sessionURI = sessionURI.resolve(URI.createURI(genconfURIStr));
}
if (URIConverter.INSTANCE.exists(sessionURI, Collections.emptyMap())) {
final Session session = SessionManager.INSTANCE.getSession(sessionURI, new NullProgressMonitor());
final M2DocSiriusServices serviceInstance = new M2DocSiriusServices(session);
res.addAll(ServiceUtils.getServices(queryEnvironment, serviceInstance));
services.put(queryEnvironment, serviceInstance);
}
}
return res;
}
示例10: validate
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Override
public Map<String, List<Diagnostic>> validate(IReadOnlyQueryEnvironment queryEnvironment,
Map<String, String> options) {
final Map<String, List<Diagnostic>> res = new HashMap<>();
final String sessionURIStr = options.get(M2DocSiriusUtils.SIRIUS_SESSION_OPTION);
if (sessionURIStr != null) {
URI sessionURI = URI.createURI(sessionURIStr, false);
final String genconfURIStr = options.get(GenconfUtils.GENCONF_URI_OPTION);
if (genconfURIStr != null) {
sessionURI = sessionURI.resolve(URI.createURI(genconfURIStr, false));
}
if (!URIConverter.INSTANCE.exists(sessionURI, Collections.emptyMap())) {
final List<Diagnostic> diagnostics = new ArrayList<>();
res.put(M2DocSiriusUtils.SIRIUS_SESSION_OPTION, diagnostics);
diagnostics.add(new BasicDiagnostic(Diagnostic.ERROR, M2DocSiriusUtils.PLUGIN_ID, 0,
"The Sirius session doesn't exist: " + sessionURI.toString(), new Object[] {sessionURI}));
}
}
return res;
}
示例11: getCompleteContent
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
public static String getCompleteContent(XtextResource xr) throws IOException, UnsupportedEncodingException {
XtextResourceSet resourceSet = (XtextResourceSet) xr.getResourceSet();
URIConverter uriConverter = resourceSet.getURIConverter();
URI uri = xr.getURI();
String encoding = xr.getEncoding();
InputStream inputStream = null;
try {
inputStream = uriConverter.createInputStream(uri);
return getCompleteContent(encoding, inputStream);
} finally {
tryClose(inputStream, null);
}
}
示例12: getContainedURIs
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Override
public Collection<URI> getContainedURIs(String containerHandle) {
if (!HANDLE.equals(containerHandle))
return Collections.emptySet();
if (resourceSet instanceof XtextResourceSet) {
ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet);
if (descriptionsData != null) {
return descriptionsData.getAllURIs();
}
return newArrayList(((XtextResourceSet) resourceSet).getNormalizationMap().values());
}
List<URI> uris = Lists.newArrayListWithCapacity(resourceSet.getResources().size());
URIConverter uriConverter = resourceSet.getURIConverter();
for (Resource r : resourceSet.getResources())
uris.add(uriConverter.normalize(r.getURI()));
return uris;
}
示例13: containsURI
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
@Override
public boolean containsURI(String containerHandle, URI candidateURI) {
if (!HANDLE.equals(containerHandle))
return false;
if (resourceSet instanceof XtextResourceSet) {
ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet);
if (descriptionsData != null) {
return descriptionsData.getResourceDescription(candidateURI) != null;
}
Collection<URI> allUris = ((XtextResourceSet) resourceSet).getNormalizationMap().values();
for (URI uri : allUris) {
if (uri.equals(candidateURI)) {
return true;
}
}
return false;
}
URIConverter uriConverter = resourceSet.getURIConverter();
for (Resource r : resourceSet.getResources()) {
URI normalized = uriConverter.normalize(r.getURI());
if (normalized.equals(candidateURI)) {
return true;
}
}
return false;
}
示例14: getNormalizedURI
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
protected URI getNormalizedURI(Resource resource) {
URI uri = resource.getURI();
URIConverter uriConverter = resource.getResourceSet()!=null?resource.getResourceSet().getURIConverter():null;
if (uri != null && uriConverter != null) {
if (!uri.isPlatform()) {
return uriConverter.normalize(uri);
}
// This is a fix for resources which have been loaded using a platform:/plugin URI
// This happens when one resource has absolute references using a platform:/plugin uri and the corresponding
// ResourceDescriptionManager resolves references in the first phase, i.e. during EObjectDecription computation.
// EMF's GenModelResourceDescriptionStrategy does so as it needs to call GenModel.reconcile() eagerly.
if (uri.isPlatformPlugin()) {
URI resourceURI = uri.replacePrefix(URI.createURI("platform:/plugin/"), URI.createURI("platform:/resource/"));
if (uriConverter.normalize(uri).equals(uriConverter.normalize(resourceURI)))
return resourceURI;
}
}
return uri;
}
示例15: isValidUri
import org.eclipse.emf.ecore.resource.URIConverter; //导入依赖的package包/类
/**
* checks whether the given URI can be loaded given the context. I.e. there's a resource set with a corresponding
* resource factory and the physical resource exists.
*/
public static boolean isValidUri(Resource resource, URI uri) {
if (uri == null || uri.isEmpty()) {
return false;
}
URI newURI = getResolvedImportUri(resource, uri);
try {
ResourceSet resourceSet = resource.getResourceSet();
if (resourceSet.getResource(uri, false) != null)
return true;
URIConverter uriConverter = resourceSet.getURIConverter();
URI normalized = uriConverter.normalize(newURI);
if (normalized != null)
// fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=326760
if("platform".equals(normalized.scheme()) && !normalized.isPlatform())
return false;
return uriConverter.exists(normalized, Collections.emptyMap());
} catch (RuntimeException e) { // thrown by org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean)
log.trace("Cannot load resource: " + newURI, e);
}
return false;
}