mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
[trace] moved up a method to make it available for more clients
This commit is contained in:
parent
dccd19723d
commit
398a2a3363
1 changed files with 18 additions and 0 deletions
|
@ -27,4 +27,22 @@ public class DefaultTraceURIConverter implements ITraceURIConverter {
|
|||
return uri.trimFragment().trimQuery();
|
||||
}
|
||||
|
||||
// this method is used by subclasses
|
||||
protected boolean isPrefix(URI prefix, URI uri) {
|
||||
if (prefix.scheme() == null || !prefix.scheme().equals(uri.scheme()))
|
||||
return false;
|
||||
String[] prefixSeg = prefix.segments();
|
||||
String[] uriSeg = uri.segments();
|
||||
if (prefixSeg.length == 0 || uriSeg.length == 0)
|
||||
return false;
|
||||
if (!"".equals(prefixSeg[prefixSeg.length - 1])) // this is true when the URI has a trailing slash ("/").
|
||||
return false;
|
||||
if (uriSeg.length < prefixSeg.length - 1)
|
||||
return false;
|
||||
for (int i = 0; i < prefixSeg.length - 1; i++)
|
||||
if (!uriSeg[i].equals(prefixSeg[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue