@Override public String path() { return uri.path(); }
@Override public String path() { return internalUri.path(); }
@Override public String path() { return base.path(); }
/** * Helper method. Construct a filename for *this* particular XLIFF translation file.<br> * (Not the fileName of the ZIP to be served later).<br> * Format will be [moduleName]_[targetLangISO].properties.xml */ private static String getXliffFileName(PropertyFileDescriptor sourceDescriptor, PropertyFileDescriptor targetDescriptor) { return targetDescriptor.getLocation().path() + ".xlf"; }
@Override public String apply(Resource from) { return from.getURI().path(); } }));
public IMirror createMirror(URI resourceURI) { if (resourceURI.hasFragment()) throw new IllegalArgumentException("Cannot create mirror for uri '" + resourceURI.toString() + "'"); String name = resourceURI.path(); if (URIHelperConstants.PRIMITIVES.equals(name)) return new PrimitiveMirror(primitiveTypeFactory); if (!name.startsWith(URIHelperConstants.OBJECTS)) throw new IllegalArgumentException("Invalid resource uri '" + resourceURI.toString() + "'"); name = name.substring(URIHelperConstants.OBJECTS.length()); return createMirrorForFQN(name); }
private URI getModuleURI(URI uri) { URI moduleuri = ModuleURIUtil.fullyQualifyURI(proj,getContentTypeDescriber()); IPath requestPath = new Path(moduleuri.path()).append(new Path(uri.path())); URI resourceURI = URI.createURI(PlatformURLModuleConnection.MODULE_PROTOCOL + requestPath.toString()); return resourceURI; }
public IMirror createMirror(URI resourceURI) { if (resourceURI.hasFragment()) throw new IllegalArgumentException("Cannot create mirror for uri '" + resourceURI.toString() + "'"); String name = resourceURI.path(); if (URIHelperConstants.PRIMITIVES.equals(name)) return new PrimitiveMirror(primitiveTypeFactory); if (!name.startsWith(URIHelperConstants.OBJECTS)) throw new IllegalArgumentException("Invalid resource uri '" + resourceURI.toString() + "'"); name = name.substring(URIHelperConstants.OBJECTS.length()); return createMirrorForFQN(name); }
/** * Return the IFile for the <code>uri</code> within the Workspace. This URI is assumed to be * absolute in the following format: platform:/resource/.... */ private IFile getPlatformFile(URI uri) { if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) { String fileString = URI.decode(uri.path()); fileString = fileString.substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1); return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString)); } return null; }
/** * Return the IFile for the <code>uri</code> within the Workspace. This URI is assumed to be * absolute in the following format: platform:/resource/.... */ private IFile getPlatformFile(URI uri) { if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) { String fileString = URI.decode(uri.path()); fileString = fileString.substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1); return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString)); } return null; } public Resource createResource(URI uri, Resource.Factory resourceFactory) {
/** * Return the IFile for the <code>uri</code> within the Workspace. This URI is assumed to be * absolute in the following format: platform:/resource/.... */ private IFile getFile(URI uri) { if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) { String fileString = URI.decode(uri.path()); fileString = fileString.substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1); return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString)); } return null; } }
protected void assertPortableURI(URI uri) { if (uri.isRelative()) { String path = uri.path(); assertFalse(uri.toString() + " is not portable", path.startsWith("..")); } }
@Override public CDOTransferElement getElement(URI uri) { if (CDOURIUtil.PROTOCOL_NAME.equals(uri.scheme())) { return getElement(uri.path()); } return null; }
/** * Return the IFile for the <code>uri</code> within the Workspace. This URI is assumed to be * absolute in the following format: platform:/resource/.... */ private IFile getFile(URI uri) { if (WorkbenchResourceHelperBase.isPlatformResourceURI(uri)) { String fileString = URI.decode(uri.path()); fileString = fileString.substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1); return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString)); } return null; } }
/** * Return the IFile for the <code>uri</code> within the Workspace. This URI is assumed to be * absolute in the following format: platform:/resource/.... */ public static IFile getPlatformFile(URI uri) { if (isPlatformResourceURI(uri)) { String fileString = URI.decode(uri.path()); fileString = fileString.substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1); return getWorkspace().getRoot().getFile(new Path(fileString)); } return null; }
public URI findResourceOnClasspath(ClassLoader classLoader, URI classpathUri) throws URISyntaxException { String pathAsString = classpathUri.path(); if (classpathUri.hasAbsolutePath()) { pathAsString = pathAsString.substring(1); } URL resource = classLoader.getResource(pathAsString); if (resource==null) throw new FileNotFoundOnClasspathException("Couldn't find resource on classpath. URI was '"+classpathUri+"'"); URI fileUri = URI.createURI(resource.toString(),true); return fileUri.appendFragment(classpathUri.fragment()); }
@Override public Iterable<String> getAllModelNamesOfType(final String modelType) { synchronized (resourceSet) { // Make a copy to avoid ConcurrentModificationException List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources()); return resourceListCopy.stream().filter(input -> { return input != null && input.getURI().lastSegment().contains(".") && input.isLoaded() && modelType.equalsIgnoreCase(input.getURI().fileExtension()); }).map(from -> { return from.getURI().path(); }).collect(Collectors.toList()); } }
public static String extractResourcePath(URI uri) throws InvalidURIException { if (!PROTOCOL_NAME.equals(uri.scheme())) { CDOURIData data = new CDOURIData(uri); return data.getResourcePath().toPortableString(); } String path = uri.path(); if (path == null) { return SEGMENT_SEPARATOR; } return path; }
public static URI computeTemplateResourceLocation(Locale locale, URI translationLocation, Locale masterLocale, ProjectVersion version) { PropertyScanner scanner = createScanner(version); URI parentPath = version.absoluteFilePath(); File path = scanner.findTemplate(new File(parentPath.path()+translationLocation.toString()), null); URI location = URI.createFileURI(path.getAbsolutePath()); URI trimmedLocation = URI.createURI(location.segment(parentPath.segmentCount())); for (int i = parentPath.segmentCount()+1; i < location.segmentCount(); i++) { //append the other segments trimmedLocation = trimmedLocation.appendSegment(location.segment(i)); } return trimmedLocation; }
private static IProject getProject(URI uri) { String projectName; if (isPlatformResourceURI(uri)) projectName = uri.segment(1); else if (uri.scheme() == null) { projectName = new Path(uri.path()).segment(0); //assume project name is first in the URI } else return null; IProject project = getWorkspace().getRoot().getProject(URI.decode(projectName)); if (project != null && project.isAccessible()) return project; else return null; }