当前位置: 首页>>代码示例>>Java>>正文


Java FileObject.getChildren方法代码示例

本文整理汇总了Java中org.apache.commons.vfs2.FileObject.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getChildren方法的具体用法?Java FileObject.getChildren怎么用?Java FileObject.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.vfs2.FileObject的用法示例。


在下文中一共展示了FileObject.getChildren方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findMaxID

import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
 * Recursively searches for the highest ID, which is the greatest slot file
 * name currently used in the store.
 * 
 * @param dir
 *            the directory to search
 * @param depth
 *            the subdirectory depth level of the dir
 * @return the highest slot file name / ID currently stored
 */
private String findMaxID(final FileObject dir, final int depth) throws FileSystemException {
    final FileObject[] children = dir.getChildren();

    if (children.length == 0) {
        return null;
    }

    Arrays.sort(children, new MCRFileObjectComparator());

    if (depth == slotLength.length) {
        return children[children.length - 1].getName().getBaseName();
    }

    for (int i = children.length - 1; i >= 0; i--) {
        final FileObject child = children[i];
        if (!child.getType().hasChildren()) {
            continue;
        }
        final String found = findMaxID(child, depth + 1);
        if (found != null) {
            return found;
        }
    }
    return null;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:36,代码来源:MCRStore.java

示例2: getChildren

import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
 * Returns the children of this node. Directories and container files like
 * zip or tar may have child nodes.
 * 
 * @return a List of child nodes, which may be empty, in undefined order
 */
public List<MCRNode> getChildren() throws IOException {
    List<MCRNode> children = new ArrayList<>();
    FileObject father = getFather();
    if (father != null) {
        FileObject[] childFos = father.getChildren();
        for (FileObject childFo : childFos) {
            String name = childFo.getName().getBaseName();
            MCRNode child = getChild(name);
            if (child != null) {
                children.add(child);
            }
        }
    }
    return children;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:22,代码来源:MCRNode.java

示例3: delete

import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
 * Deletes the data stored in the given file object from the store
 * 
 * @param fo
 *            the file object to be deleted
 */
void delete(FileObject fo) throws IOException {
    FileObject parent = fo.getParent();
    fo.delete(Selectors.SELECT_ALL);

    while (!parent.equals(baseDirectory)) {
        final FileObject[] children = parent.getChildren();
        if (children.length > 0) {
            break;
        }
        fo = parent;
        parent = fo.getParent();
        fo.delete();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:21,代码来源:MCRStore.java

示例4: getNumChildren

import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
 * Returns the number of child nodes of this node.
 * 
 * @return the number of child nodes of this node.
 */
public int getNumChildren() throws IOException {
    FileObject father = getFather();
    if (father == null) {
        return 0;
    } else {
        return father.getChildren().length;
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:14,代码来源:MCRNode.java

示例5: folderMove

import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
/**
 * Move the folder
 *
 * @param destination            New location of the folder
 * @param source                 Location of the folder
 * @param messageContext         The message context that is processed by a handler in the handle method
 * @param includeParentDirectory Boolean type
 * @param manager                Standard file system manager
 */
private void folderMove(String source, String destination, String filePattern, boolean includeParentDirectory,
                        MessageContext messageContext, StandardFileSystemManager manager) throws IOException {
    FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
    FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
    if (StringUtils.isNotEmpty(filePattern)) {
        FileObject[] children = remoteFile.getChildren();
        for (FileObject child : children) {
            if (child.getType() == FileType.FILE) {
                moveFileWithPattern(child, destination, filePattern, manager, messageContext);
            } else if (child.getType() == FileType.FOLDER) {
                String newSource = source + File.separator + child.getName().getBaseName();
                folderMove(newSource, destination, filePattern, includeParentDirectory, messageContext, manager);
            }
        }
    } else if (includeParentDirectory) {
        file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                FileConnectorUtils.init(messageContext));
        file.createFolder();
        remoteFile.moveTo(file);
    } else {
        if (!file.exists()) {
            file.createFolder();
        }
        remoteFile.moveTo(file);
        remoteFile.createFolder();
    }
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:37,代码来源:FileMove.java

示例6: list

import org.apache.commons.vfs2.FileObject; //导入方法依赖的package包/类
@Override
public List<NoteInfo> list() throws IOException {
  FileObject rootDir = getRootDir();

  FileObject[] children = rootDir.getChildren();

  List<NoteInfo> infos = new LinkedList<NoteInfo>();
  for (FileObject f : children) {
    String fileName = f.getName().getBaseName();
    if (f.isHidden()
        || fileName.startsWith(".")
        || fileName.startsWith("#")
        || fileName.startsWith("~")) {
      // skip hidden, temporary files
      continue;
    }

    if (!isDirectory(f)) {
      // currently single note is saved like, [NOTE_ID]/note.json.
      // so it must be a directory
      continue;
    }

    NoteInfo info = null;

    try {
      info = getNoteInfo(f);
      if (info != null) {
        infos.add(info);
      }
    } catch (IOException e) {
      logger.error("Can't read note " + f.getName().toString(), e);
    }
  }

  return infos;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:38,代码来源:VFSNotebookRepo.java


注:本文中的org.apache.commons.vfs2.FileObject.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。