本文整理了Java中org.jboss.forge.addon.resource.Resource.getParent
方法的一些代码示例,展示了Resource.getParent
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getParent
方法的具体详情如下:
包路径:org.jboss.forge.addon.resource.Resource
类名称:Resource
方法名:getParent
[英]Get the parent of the current resource. Returns null
if the current resource is the filesystem root.
[中]获取当前资源的父级。如果当前资源是文件系统根,则返回null
。
代码示例来源:origin: org.jboss.forge.addon/resources-api
public static DirectoryResource getContextDirectory(final Resource<?> r)
{
Resource<?> temp = r;
do
{
if (temp instanceof DirectoryResource)
{
return (DirectoryResource) temp;
}
}
while ((temp != null) && ((temp = temp.getParent()) != null));
return null;
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
private boolean isParent(Resource<?> parent, Resource<?> child)
{
Resource<?> childDir = child.getParent();
while (childDir != null)
{
if (parent.equals(childDir))
{
return true;
}
childDir = childDir.getParent();
}
return false;
}
代码示例来源:origin: org.jboss.forge.addon/resources-api
public static boolean isChildOf(final Resource<?> parent, final Resource<?> isChild)
{
Resource<?> r = isChild;
while ((r = r.getParent()) != null)
{
if (r.equals(parent))
{
return true;
}
}
return false;
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
/**
* Returns all directories on path starting from given directory up to the root.
*/
private List<Resource<?>> allDirectoriesOnPath(Resource<?> startingDir)
{
List<Resource<?>> result = new ArrayList<>();
while (startingDir != null)
{
result.add(startingDir);
startingDir = startingDir.getParent();
}
return result;
}
代码示例来源:origin: org.jboss.forge.addon/resources-api
public static boolean isParentOf(Resource<?> parent, Resource<?> child)
{
Assert.notNull(parent, "Parent resource must not be null.");
Assert.notNull(child, "Child resource must not be null.");
while (child.getParent() != null)
{
if (parent == child.getParent() || parent.equals(child.getParent()))
return true;
child = child.getParent();
}
return false;
}
}
代码示例来源:origin: org.jboss.forge.addon/resources-api
/**
* A simple utility method to locate the outermost contextual File reference for the specified resource.
*
* @param r resource instance.
* @return outermost relevant file context.
*/
public static File getContextFile(Resource<?> r)
{
do
{
Object o = r.getUnderlyingResourceObject();
if (o instanceof File)
{
return (File) r.getUnderlyingResourceObject();
}
}
while ((r = r.getParent()) != null);
return null;
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
@Override
public boolean containsProject(Resource<?> bound, Resource<?> target, ProjectProvider buildSystem)
{
Assert.notNull(bound, "Boundary should not be null");
Assert.isTrue(bound.equals(target) || isParent(bound, target), "Target should be a child of bound");
boolean found = false;
Resource<?> r = bound;
while (r != null && !found)
{
found = buildSystem.containsProject(r);
if (target.equals(r))
{
break;
}
r = r.getParent();
}
return found;
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
@Override
public boolean containsProject(Resource<?> target, ProjectProvider buildSystem)
{
Assert.notNull(target, "Target resource must not be null.");
Assert.notNull(buildSystem, "Project build system must not be null.");
boolean found = false;
Resource<?> r = target;
while (r != null && !found)
{
found = buildSystem.containsProject(r);
r = r.getParent();
}
return found;
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
while (!(resource instanceof FileResource<?>))
resource = resource.getParent();
代码示例来源:origin: org.jboss.forge.addon/resources-api
Resource<?> parent = r.getParent();
if (parent != null)
代码示例来源:origin: org.jboss.forge.addon/shell-impl
@Override
public void setCurrentResource(final Resource<?> resource)
{
Assert.notNull(resource, "Current resource should not be null");
this.currentResource = resource;
Resource<?> temp = resource;
while (!(temp instanceof DirectoryResource) && temp != null)
{
temp = temp.getParent();
}
if (temp instanceof DirectoryResource)
{
// Workaround to prevent "Current working directory must be a directory" exceptions when running in a
// transaction
File dir = ((DirectoryResource) temp).getUnderlyingResourceObject();
if (dir.exists())
{
console.getAeshContext().setCurrentWorkingDirectory(new org.jboss.aesh.io.FileResource(dir));
}
}
updatePrompt();
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
if (result != null)
Resource<?> parent = result.getRoot().getParent();
if (parent != null)
代码示例来源:origin: org.jboss.forge.addon/shell-impl
currentResource = currentResource.getParent();
代码示例来源:origin: org.jboss.forge.addon/shell-impl
newTargetDir = ((DirectoryResource) targetResource.getParent()).getOrCreateChildDirectory(targetResource
.getName());
内容来源于网络,如有侵权,请联系作者删除!