本文整理汇总了Java中org.eclipse.emf.common.util.URI.fileExtension方法的典型用法代码示例。如果您正苦于以下问题:Java URI.fileExtension方法的具体用法?Java URI.fileExtension怎么用?Java URI.fileExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.common.util.URI
的用法示例。
在下文中一共展示了URI.fileExtension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureResourceSet
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
private static void configureResourceSet(ResourceSet rs, URI modelURI, HashMap<String, String> nsURIMapping,
SubMonitor subMonitor) {
subMonitor.subTask("Configuring ResourceSet");
subMonitor.newChild(1);
final String fileExtension = modelURI.fileExtension();
// indicates which melange query should be added to the xml uri handler
// for a given extension
// use to resolve cross ref URI during XMI parsing
final XMLURIHandler handler = new XMLURIHandler(modelURI.query(), fileExtension);
handler.setResourceSet(rs);
rs.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, handler);
final MelangeURIConverter converter = new MelangeURIConverter(nsURIMapping);
rs.setURIConverter(converter);
// fix sirius to prevent non intentional model savings
converter.getURIHandlers().add(0, new DebugURIHandler(converter.getURIHandlers()));
}
示例2: resolve
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public URI resolve(URI uri) {
URI resolvedURI = super.resolve(uri);
if (!_queryParameters.isEmpty() && resolvedURI.scheme() != null && !resolvedURI.scheme().equals("melange")
&& resolvedURI.fileExtension() != null && resolvedURI.fileExtension().equals(_fileExtension)) {
String fileExtensionWithPoint = "." + _fileExtension;
int lastIndexOfFileExtension = resolvedURI.toString().lastIndexOf(fileExtensionWithPoint);
String part1 = resolvedURI.toString().substring(0, lastIndexOfFileExtension);
part1 = part1.replaceFirst("platform:/", "melange:/");
String part2 = fileExtensionWithPoint + _queryParameters;
String part3 = resolvedURI.toString()
.substring(lastIndexOfFileExtension + fileExtensionWithPoint.length());
String newURIAsString = part1 + part2 + part3;
return URI.createURI(newURIAsString);
}
return resolvedURI;
}
示例3: doResolveProxy
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
/**
* Invoked from {@link ProxyResolvingEObjectImpl#eResolveProxy(InternalEObject)} whenever an EMF proxy inside an
* N4JSResource is being resolved. The receiving resource is the resource containing the proxy, not necessarily the
* resource the proxy points to.
*
* @param proxy
* the proxy to resolve.
* @param objectContext
* the {@code EObject} contained in this resource that holds the given proxy.
*/
@Override
public EObject doResolveProxy(InternalEObject proxy, EObject objectContext) {
// step 1: trigger post processing of the resource containing 'proxy' iff it is the first proxy being resolved
// (if another proxy has been resolved before, post processing will already be running/completed, and in that
// case the next line will simply do nothing, cf. #performPostProcessing())
this.performPostProcessing();
// step 2: now turn to resolving the proxy at hand
final URI targetUri = proxy.eProxyURI();
final boolean isLazyLinkingProxy = getEncoder().isCrossLinkFragment(this, targetUri.fragment());
if (!isLazyLinkingProxy) {
// we have an ordinary EMF proxy (not one of Xtext's lazy linking proxies) ...
final ResourceSet resSet = getResourceSet();
final URI targetResourceUri = targetUri.trimFragment();
final String targetFileExt = targetResourceUri.fileExtension();
if (N4JSGlobals.N4JS_FILE_EXTENSION.equals(targetFileExt)
|| N4JSGlobals.N4JSD_FILE_EXTENSION.equals(targetFileExt)
|| N4JSGlobals.N4JSX_FILE_EXTENSION.equals(targetFileExt)) {
// proxy is pointing into an .n4js or .n4jsd file ...
// check if we can work with the TModule from the index or if it is mandatory to load from source
final boolean canLoadFromDescription = !targetUri.fragment().startsWith("/0")
&& canLoadFromDescriptionHelper.canLoadFromDescription(targetResourceUri, getResourceSet());
if (canLoadFromDescription) {
final String targetFragment = targetUri.fragment();
final Resource targetResource = resSet.getResource(targetResourceUri, false);
// special handling #1:
// if targetResource is not loaded yet, try to load it from index first
if (targetResource == null) {
if (targetFragment != null
&& (targetFragment.equals("/1") || targetFragment.startsWith("/1/"))) {
// uri points to a TModule element in a resource not yet contained in our resource set
// --> try to load target resource from index
final IResourceDescriptions index = n4jsCore.getXtextIndex(resSet);
final IResourceDescription resDesc = index.getResourceDescription(targetResourceUri);
if (resDesc != null) {
// next line will add the new resource to resSet.resources
n4jsCore.loadModuleFromIndex(resSet, resDesc, false);
}
}
}
}
// standard behavior:
// obtain target EObject from targetResource in the usual way
// (might load targetResource from disk if it wasn't loaded from index above)
final EObject targetObject = resSet.getEObject(targetUri, true);
// special handling #2:
// if targetResource exists, make sure it is post-processed *iff* this resource is post-processed
// (only relevant in case targetResource wasn't loaded from index, because after loading from index it
// is always marked as fullyPostProcessed==true)
if (targetObject != null && (this.isPostProcessing() || this.isFullyProcessed())) {
final Resource targetResource2 = targetObject.eResource();
if (targetResource2 instanceof N4JSResource) {
// no harm done, if already running/completed
((N4JSResource) targetResource2).performPostProcessing();
}
}
// return resolved target object
return targetObject != null ? targetObject : proxy; // important: return proxy itself if unresolvable!
}
}
// we will get here if
// a) we have an Xtext lazy linking proxy or
// b) targetUri points to an n4ts resource or some other, non-N4JS resource
// --> above special handling not required, so just apply EMF's default resolution behavior
return EcoreUtil.resolve(proxy, this);
}
示例4: canHandle
import org.eclipse.emf.common.util.URI; //导入方法依赖的package包/类
@Override
public boolean canHandle(URI uri) {
return uri.fileExtension() == null || !uri.fileExtension().equals("trace");
}