本文整理汇总了Java中org.eclipse.core.runtime.IPath.removeFirstSegments方法的典型用法代码示例。如果您正苦于以下问题:Java IPath.removeFirstSegments方法的具体用法?Java IPath.removeFirstSegments怎么用?Java IPath.removeFirstSegments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.runtime.IPath
的用法示例。
在下文中一共展示了IPath.removeFirstSegments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTemplateURI
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Finds the template in the plug-in. Returns the template plug-in URI.
*
* @param bundleID
* is the plug-in ID
* @param relativePath
* is the relative path of the template in the plug-in
* @return the template URI
* @throws IOException
* @generated
*/
@SuppressWarnings("unchecked")
private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
Bundle bundle = Platform.getBundle(bundleID);
if (bundle == null) {
// no need to go any further
return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
}
URL url = bundle.getEntry(relativePath.toString());
if (url == null && relativePath.segmentCount() > 1) {
Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
if (entries != null) {
String[] segmentsRelativePath = relativePath.segments();
while (url == null && entries.hasMoreElements()) {
URL entry = entries.nextElement();
IPath path = new Path(entry.getPath());
if (path.segmentCount() > relativePath.segmentCount()) {
path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
}
String[] segmentsPath = path.segments();
boolean equals = segmentsPath.length == segmentsRelativePath.length;
for (int i = 0; equals && i < segmentsPath.length; i++) {
equals = segmentsPath[i].equals(segmentsRelativePath[i]);
}
if (equals) {
url = bundle.getEntry(entry.getPath());
}
}
}
}
URI result;
if (url != null) {
result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
} else {
result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
}
return result;
}
示例2: getTemplateURI
import org.eclipse.core.runtime.IPath; //导入方法依赖的package包/类
/**
* Finds the template in the plug-in. Returns the template plug-in URI.
*
* @param bundleID
* is the plug-in ID
* @param relativePath
* is the relative path of the template in the plug-in
* @return the template URI
* @throws IOException
* @generated
*/
@SuppressWarnings ( "unused" )
private URI getTemplateURI ( final String bundleID, final IPath relativePath ) throws IOException
{
final Bundle bundle = Platform.getBundle ( bundleID );
if ( bundle == null )
{
// no need to go any further
return URI.createPlatformResourceURI ( new Path ( bundleID ).append ( relativePath ).toString (), false );
}
URL url = bundle.getEntry ( relativePath.toString () );
if ( url == null && relativePath.segmentCount () > 1 )
{
final Enumeration<URL> entries = bundle.findEntries ( "/", "*.emtl", true );
if ( entries != null )
{
final String[] segmentsRelativePath = relativePath.segments ();
while ( url == null && entries.hasMoreElements () )
{
final URL entry = entries.nextElement ();
IPath path = new Path ( entry.getPath () );
if ( path.segmentCount () > relativePath.segmentCount () )
{
path = path.removeFirstSegments ( path.segmentCount () - relativePath.segmentCount () );
}
final String[] segmentsPath = path.segments ();
boolean equals = segmentsPath.length == segmentsRelativePath.length;
for ( int i = 0; equals && i < segmentsPath.length; i++ )
{
equals = segmentsPath[i].equals ( segmentsRelativePath[i] );
}
if ( equals )
{
url = bundle.getEntry ( entry.getPath () );
}
}
}
}
URI result;
if ( url != null )
{
result = URI.createPlatformPluginURI ( new Path ( bundleID ).append ( new Path ( url.getPath () ) ).toString (), false );
}
else
{
result = URI.createPlatformResourceURI ( new Path ( bundleID ).append ( relativePath ).toString (), false );
}
return result;
}