Java Code Examples for org.eclipse.emf.common.util.URI#createHierarchicalURI()
The following examples show how to use
org.eclipse.emf.common.util.URI#createHierarchicalURI() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BuiltInSchemeRegistrar.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Convert the given n4scheme-URI to a classpath-URI. */ private URI toClasspathURI(URI uriWithN4Scheme) { String[] allSegments = new String[uriWithN4Scheme.segmentCount() + 1]; allSegments[0] = "env"; for (int i = 0; i < uriWithN4Scheme.segmentCount(); i++) { allSegments[i + 1] = uriWithN4Scheme.segment(i); } URI classpathURI = URI.createHierarchicalURI( ClasspathUriUtil.CLASSPATH_SCHEME, uriWithN4Scheme.authority(), uriWithN4Scheme.device(), allSegments, uriWithN4Scheme.query(), uriWithN4Scheme.fragment()); return classpathURI; }
Example 2
Source File: EclipseProjectPropertiesEncodingProvider.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected String getFromProperties(URI uri) throws IOException { if (!uri.isHierarchical()) return null; URI projectURI = uri; boolean projectFound = false; do { projectURI = projectURI.trimSegments(1); if (new File(projectURI.path(), ".project").exists()) { projectFound = true; } if (!projectFound && projectURI.segmentCount() == 0) // The resource is not contained in a project return null; } while (!projectFound); Properties properties = loadProperties(projectURI); URI resourceUri = URI.createHierarchicalURI(Arrays.copyOfRange(uri.segments(), projectURI.segmentCount(), uri.segmentCount()), null, null); return getValue(properties, resourceUri, ENCODING_PREFIX); }
Example 3
Source File: N4Scheme.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Create a new URI with fragment. */ private static URI create(String path, String fragment) { List<String> segments = Strings.split(path, '/'); URI result = URI.createHierarchicalURI(SCHEME, null, null, segments.toArray(new String[segments.size()]), null, fragment); return result; }
Example 4
Source File: URIUtils.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Adds empty authority to the given URI. Necessary for windows platform. */ public static URI addEmptyAuthority(URI uri) { if (uri.isFile() && !uri.hasAuthority() && !uri.isRelative()) { uri = URI.createHierarchicalURI(uri.scheme(), "", uri.device(), uri.segments(), uri.query(), uri.fragment()); } return uri; }
Example 5
Source File: FileURI.java From n4js with Eclipse Public License 1.0 | 5 votes |
private static URI toFileURI(File file) { String absolutePath = file.getAbsolutePath(); URI fileURI = URI.createFileURI(absolutePath); if (fileURI.authority() == null) { fileURI = URI.createHierarchicalURI(fileURI.scheme(), "", fileURI.device(), fileURI.segments(), fileURI.query(), fileURI.fragment()); } return fileURI; }
Example 6
Source File: DefaultTraceURIConverter.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private SourceRelativeURI getURIForTrace(URI qualifiedURI) { if (qualifiedURI.isPlatform()) { // create a URI that is relative to the containing project or bundle List<String> segments = qualifiedURI.segmentsList().subList(2, qualifiedURI.segmentCount()); return new SourceRelativeURI(URI.createHierarchicalURI(segments.toArray(new String[segments.size()]), null, null)); } return SourceRelativeURI.fromAbsolute(qualifiedURI); }
Example 7
Source File: UriExtensions.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Converts the file URIs with an absent (null) authority to one with an empty ("") authority */ public URI withEmptyAuthority(URI uri) { if (uri.isFile() && uri.authority() == null) { return URI.createHierarchicalURI(uri.scheme(), "", uri.device(), uri.segments(), uri.query(), uri.fragment()); } return uri; }