org.apache.sling.api.resource.Resource.listChildren()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(97)

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

Resource.listChildren介绍

[英]Returns an iterator of the direct children of this resource.

This method is a convenience and returns exactly the same resources as calling getResourceResolver().listChildren(resource).
[中]

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.query

@Override
public Iterator<Resource> listChildren(Resource parent) {
  return parent.listChildren();
}

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.jsp.taglib

/**
 * Method for checking whether or not a resource has child resources.
 * 
 * @param resource
 *            the resource to check for child resources
 * @return true if the resource has child resources, false otherwise
 * @since 2.2.2
 */
public static final boolean hasChildren(Resource resource) {
  return resource != null ? resource.listChildren().hasNext() : false;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

private ResourceDistributionPackageIterator(@NotNull Resource packagesRoot, @NotNull ResourceResolver resourceResolver,
                  @NotNull String type) {
  this.packages = packagesRoot.listChildren();
  this.resourceResolver = resourceResolver;
  this.type = type;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.jsp.taglib

@Override
public int doEndTag() {
  log.trace("doEndTag");
  log.debug("Listing the children of resource: " + resource);
  Iterator<Resource> children = null;
  if (resource != null) {
    children = resource.listChildren();
  }
  log.debug("Saving to variable " + var);
  pageContext.setAttribute(var, children);
  return EVAL_PAGE;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.api

/**
 * Returns the value of calling <code>listChildren</code> on the
 * {@link #getResource() wrapped resource}.
 *
 * @since 2.1.0 (Sling API Bundle 2.1.0)
 */
@Override
public Iterator<Resource> listChildren() {
  return getResource().listChildren();
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

@Override
public boolean hasContents(final Resource resource, final int index) {
  final Resource parResource = resource.getChild(LONG_FORM_TEXT_PAR + index);
  return parResource != null && parResource.listChildren().hasNext();
}

代码示例来源:origin: org.apache.sling/org.apache.sling.servlets.resolver

/**
 * @see org.apache.sling.api.resource.AbstractResource#listChildren()
 */
@Override
public Iterator<Resource> listChildren() {
  return this.getActiveResource().listChildren();
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

@Override
public boolean hasContents(final Resource resource, final int index) {
  final Resource parResource = resource.getChild(LONG_FORM_TEXT_PAR + index);
  return parResource != null && parResource.listChildren().hasNext();
}

代码示例来源:origin: io.wcm/io.wcm.wcm.ui.extjs

/**
 * Lists children using custom page iterator.
 * @param parentResource Parent resource
 * @param pageFilter Page filter
 * @return Page iterator
 */
protected final Iterator<Page> listChildren(Resource parentResource, PageFilter pageFilter) {
 return new PageIterator(parentResource.listChildren(), pageFilter);
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

@Override
public List<Resource> getNotifications(final SlingHttpServletRequest request,
                    final Resource notificationsFolder) {
  final List<Resource> notifications = new ArrayList<Resource>();
  final Iterator<Resource> itr = notificationsFolder.listChildren();
  while (itr.hasNext()) {
    final Resource notification = itr.next();
    if (this.isActiveNotification(request, notification)) {
      notifications.add(notification);
    }
  }
  return notifications;
}

代码示例来源:origin: com.cognifide.cq/cqsm-bundle

@Override
  public List<Entry> resolve(ResourceResolver resolver) {
    List<Entry> result = new LinkedList<>();
    Iterator<Resource> it = resolver.getResource(HistoryImpl.ENTRY_PATH).listChildren();
    while (it.hasNext()) {
      result.add(it.next().adaptTo(Entry.class));
    }
    return result;
  }
}, Collections.<Entry>emptyList());

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

private void search(Resource resource, Set<Page> pages, PageManager pageManager) {
  findReferencesInResource(resource, pages, pageManager);
  for (Iterator<Resource> iter = resource.listChildren(); iter.hasNext();) {
    search(iter.next(), pages, pageManager);
  }
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

private void search(Resource resource, Set<Page> pages, PageManager pageManager) {
  findReferencesInResource(resource, pages, pageManager);
  for (Iterator<Resource> iter = resource.listChildren(); iter.hasNext();) {
    search(iter.next(), pages, pageManager);
  }
}

代码示例来源:origin: Cognifide/APM

@Override
  public List<Entry> resolve(ResourceResolver resolver) {
    List<Entry> result = new LinkedList<>();
    Iterator<Resource> it = resolver.getResource(HistoryImpl.ENTRY_PATH).listChildren();
    while (it.hasNext()) {
      result.add(it.next().adaptTo(Entry.class));
    }
    return result;
  }
}, Collections.<Entry>emptyList());

代码示例来源:origin: org.apache.sling/org.apache.sling.api

/**
 * Visit the given resource and all its descendants.
 * @param res The resource
 */
public void accept(final Resource res) {
  if (res != null) {
    this.visit(res);
    this.traverseChildren(res.listChildren());
  }
}

代码示例来源:origin: com.cognifide.cq/cqsm-bundle

private List<Script> findAll(boolean skipIgnored, ResourceResolver resourceResolver) {
  List<Script> scripts = new LinkedList<>();
  for (String path : getSearchPaths()) {
    Resource root = resourceResolver.getResource(path);
    if (root != null) {
      Iterator<Resource> children = root.listChildren();
      scripts.addAll(getScripts(children, skipIgnored));
    }
  }
  return scripts;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

public ResourceIterator(Resource root, String folderResourceType, boolean includeFolders, boolean includeLeafs) {
  this.folderResourceType = folderResourceType;
  this.includeFolders = includeFolders;
  this.includeLeafs = includeLeafs;
  this.rootPath = root.getPath();
  currentFolder = root;
  currentIterator = currentFolder.listChildren();
  next = seek();
}

代码示例来源:origin: heervisscher/htl-examples

private String getSlingScriptFolder(Resource resource) {
  
  Iterator<Resource> it = resource.getResourceResolver().getResource("/var/layoutswitcher").listChildren();
  
  while ( it.hasNext()) {
    Resource r = it.next();
    String path = r.getValueMap().get("path", String.class);
    if ( resource.getPath().startsWith(path)){
      return r.getValueMap().get(SLING_SCRIPT_FOLDER, String.class);
    }
  }
  return null;
}

代码示例来源:origin: heervisscher/htl-examples

private void processResource(Resource r) {
  if ("weretail/components/structure/product".equals(r.getResourceType())) {
    String productPath = r.getValueMap().get("productData", String.class);
    Resource product = r.getResourceResolver().getResource(productPath);
    log.info("Sling RequestWrapper {}", product.getPath());
    children.add(mf.getModelFromWrappedRequest(request, product, ProductExporter.class));
  }
  processChildren(r.listChildren());
}

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.sightly.testing-content

public void init(Bindings bindings) {
  Resource resource = (Resource)bindings.get(SlingBindings.RESOURCE);
  ValueMap properties = (ValueMap)bindings.get(PROPERTIES);
  if (properties != null) {
    text = properties.get(TEXT, resource.getPath());
    tag = properties.get(TAG, String.class);
    includeChildren = properties.get(INCLUDE_CHIDLREN, false);
    if (includeChildren) {
      children = resource.listChildren();
    }
  }
}

相关文章