org.jboss.forge.addon.resource.Resource.getUnderlyingResourceObject()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.jboss.forge.addon.resource.Resource.getUnderlyingResourceObject方法的一些代码示例,展示了Resource.getUnderlyingResourceObject的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Resource.getUnderlyingResourceObject方法的具体详情如下:
包路径:org.jboss.forge.addon.resource.Resource
类名称:Resource
方法名:getUnderlyingResourceObject

Resource.getUnderlyingResourceObject介绍

[英]Get the underlying object represented by this Resource.
[中]获取此资源表示的基础对象。

代码示例

代码示例来源: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: windup/windup

private Resource<?> getResourceResolved(Resource<?> value)
{
  Resource<?> resource = (Resource<?>) value;
  File file = (File) resource.getUnderlyingResourceObject();
  return new ResourcePathResolver(resourceFactory, resource, file.getPath()).resolve().get(0);
}

代码示例来源:origin: org.bsc/dynjs-addon

project.getRoot(), new ArrayList<Resource<?>>());
final java.io.File root = (java.io.File) project.getRoot().getUnderlyingResourceObject();

代码示例来源:origin: windup/windup

private Object getValueForInput(ConfigurationOption option, InputComponent<?, ?> input)
{
  Object value = input.getValue();
  if (value == null)
  {
    return value;
  }
  if (value instanceof Resource<?>)
  {
    Resource<?> resourceResolved = getResourceResolved((Resource<?>) value);
    return resourceResolved.getUnderlyingResourceObject();
  }
  if (option.getType() == Path.class)
  {
    // these have to be converted
    Set<Path> paths = new LinkedHashSet<>();
    if (value instanceof List)
    {
      for (Object path : (List) value)
      {
        if (path instanceof File)
          path = ((File) path).toPath();
        paths.add((Path) path);
      }
    }
    value = paths;
  }
  return value;
}

代码示例来源:origin: org.jboss.forge.addon/resources-impl

/**
* Using the given type, obtain a reference to the child resource of the given type. If the result is not of the
* requested type and does not exist, return null. If the result is not of the requested type and exists, throw
* {@link ResourceException}
*/
@Override
@SuppressWarnings("unchecked")
public <E, T extends Resource<E>> T getChildOfType(final Class<T> type, final String name) throws ResourceException
{
 T result;
 Resource<?> child = getChild(name);
 if (type.isAssignableFrom(child.getClass()))
 {
   result = (T) child;
 }
 else if (child.exists())
 {
   throw new ResourceException("Requested resource [" + name + "] was not of type [" + type.getName()
       + "], but was instead [" + child.getClass().getName() + "]");
 }
 else
 {
   E underlyingResource = (E) child.getUnderlyingResourceObject();
   result = getResourceFactory().create(type, underlyingResource);
 }
 return result;
}

代码示例来源:origin: org.jboss.forge.addon/shell-impl

private void openResource(UIExecutionContext context, Resource<?> resource) throws IOException
{
 UIDesktop desktop = context.getUIContext().getProvider().getDesktop();
 if (resource instanceof FileResource<?>)
 {
   desktop.open((File) resource.getUnderlyingResourceObject());
 }
 else if (resource instanceof URLResource)
 {
   try
   {
    desktop.browse(((URLResource) resource).getUnderlyingResourceObject().toURI());
   }
   catch (URISyntaxException e)
   {
    throw new RuntimeException("Bad URL syntax: " + e.getInput(), e);
   }
 }
}

代码示例来源:origin: org.jboss.forge.addon/script

Object currentDir = currentResource.getUnderlyingResourceObject();
if (currentDir instanceof File)

相关文章