當前位置: 首頁>>代碼示例>>Java>>正文


Java Node類代碼示例

本文整理匯總了Java中jdk.internal.jimage.ImageReader.Node的典型用法代碼示例。如果您正苦於以下問題:Java Node類的具體用法?Java Node怎麽用?Java Node使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Node類屬於jdk.internal.jimage.ImageReader包,在下文中一共展示了Node類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: iteratorOf

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
/**
 * returns the list of child paths of the given directory "path"
 *
 * @param path name of the directory whose content is listed
 * @return iterator for child paths of the given directory path
 */
Iterator<Path> iteratorOf(JrtPath path, DirectoryStream.Filter<? super Path> filter)
        throws IOException {
    Node node = checkNode(path).resolveLink(true);
    if (!node.isDirectory()) {
        throw new NotDirectoryException(path.getName());
    }
    if (filter == null) {
        return node.getChildren()
                   .stream()
                   .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
                   .iterator();
    }
    return node.getChildren()
               .stream()
               .map(child -> (Path)(path.resolve(new JrtPath(this, child.getNameString()).getFileName())))
               .filter(p ->  { try { return filter.accept(p);
                               } catch (IOException x) {}
                               return false;
                              })
               .iterator();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:JrtFileSystem.java

示例2: lookupSymbolic

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
private Node lookupSymbolic(String path) {
    int i = 1;
    while (i < path.length()) {
        i = path.indexOf('/', i);
        if (i == -1) {
            break;
        }
        String prefix = path.substring(0, i);
        Node node = lookup(prefix);
        if (node == null) {
            break;
        }
        if (node.isLink()) {
            Node link = node.resolveLink(true);
            // resolved symbolic path concatenated to the rest of the path
            String resPath = link.getName() + path.substring(i);
            node = lookup(resPath);
            return node != null ? node : lookupSymbolic(resPath);
        }
        i++;
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:JrtFileSystem.java

示例3: getChildren

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
@Override
public List<Node> getChildren() {
    if (!isDirectory())
        throw new IllegalArgumentException("not a directory: " + getNameString());
    if (children == null) {
        List<Node> list = new ArrayList<>();
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
            for (Path p : stream) {
                p = explodedModulesDir.relativize(p);
                String pName = MODULES + nativeSlashToFrontSlash(p.toString());
                Node node = findNode(pName);
                if (node != null) {  // findNode may choose to hide certain files!
                    list.add(node);
                }
            }
        } catch (IOException x) {
            return null;
        }
        children = list;
    }
    return children;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:ExplodedImage.java

示例4: findModulesNode

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
Node findModulesNode(String str) {
    PathNode node = nodes.get(str);
    if (node != null) {
        return node;
    }
    // lazily created "/modules/xyz/abc/" Node
    // This is mapped to default file system path "<JDK_MODULES_DIR>/xyz/abc"
    Path p = underlyingPath(str);
    if (p != null) {
        try {
            BasicFileAttributes attrs = Files.readAttributes(p, BasicFileAttributes.class);
            if (attrs.isRegularFile()) {
                Path f = p.getFileName();
                if (f.toString().startsWith("_the."))
                    return null;
            }
            node = new PathNode(str, p, attrs);
            nodes.put(str, node);
            return node;
        } catch (IOException x) {
            // does not exists or unable to determine
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:ExplodedImage.java

示例5: open

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
static SystemImage open() throws IOException {
    if (modulesImageExists) {
        // open a .jimage and build directory structure
        final ImageReader image = ImageReader.open(moduleImageFile);
        image.getRootDirectory();
        return new SystemImage() {
            @Override
            Node findNode(String path) throws IOException {
                return image.findNode(path);
            }
            @Override
            byte[] getResource(Node node) throws IOException {
                return image.getResource(node);
            }
            @Override
            void close() throws IOException {
                image.close();
            }
        };
    }
    if (Files.notExists(explodedModulesDir))
        throw new FileSystemNotFoundException(explodedModulesDir.toString());
    return new ExplodedImage(explodedModulesDir);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:SystemImage.java

示例6: findNode

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
private NodeAndImage findNode(byte[] path) throws IOException {
    ImageReader image = bootImage;
    Node node = bootImage.findNode(path);
    if (node == null) {
        image = extImage;
        node = extImage.findNode(path);
    }
    if (node == null) {
        image = appImage;
        node = appImage.findNode(path);
    }
    if (node == null || node.isTopLevelPackageDir()) {
        throw new NoSuchFileException(getString(path));
    }
    return new NodeAndImage(node, image);
}
 
開發者ID:forax,項目名稱:jigsaw-jrtfs,代碼行數:17,代碼來源:JrtFileSystem.java

示例7: resolveLink

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
JrtPath resolveLink(JrtPath path) throws IOException {
    Node node = checkNode(path);
    if (node.isLink()) {
        node = node.resolveLink();
        return new JrtPath(this, node.getName());  // TBD, normalized?
    }
    return path;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:JrtFileSystem.java

示例8: getFileAttributes

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
JrtFileAttributes getFileAttributes(JrtPath path, LinkOption... options)
        throws IOException {
    Node node = checkNode(path);
    if (node.isLink() && followLinks(options)) {
        return new JrtFileAttributes(node.resolveLink(true));
    }
    return new JrtFileAttributes(node);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:JrtFileSystem.java

示例9: getFileContent

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
byte[] getFileContent(JrtPath path) throws IOException {
    Node node = checkNode(path);
    if (node.isDirectory()) {
        throw new FileSystemException(path + " is a directory");
    }
    //assert node.isResource() : "resource node expected here";
    return image.getResource(node);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:JrtFileSystem.java

示例10: isDirectory

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
boolean isDirectory(JrtPath path, boolean resolveLinks)
        throws IOException {
    Node node = checkNode(path);
    return resolveLinks && node.isLink()
            ? node.resolveLink(true).isDirectory()
            : node.isDirectory();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:JrtFileSystem.java

示例11: toRealPath

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
JrtPath toRealPath(JrtPath path, LinkOption... options)
        throws IOException {
    Node node = checkNode(path);
    if (followLinks(options) && node.isLink()) {
        node = node.resolveLink();
    }
    // image node holds the real/absolute path name
    return new JrtPath(this, node.getName(), true);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:JrtFileSystem.java

示例12: lookup

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
private Node lookup(String path) {
    try {
        return image.findNode(path);
    } catch (RuntimeException | IOException ex) {
        throw new InvalidPathException(path, ex.toString());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:8,代碼來源:JrtFileSystem.java

示例13: checkNode

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
Node checkNode(JrtPath path) throws IOException {
    ensureOpen();
    String p = path.getResolvedPath();
    Node node = lookup(p);
    if (node == null) {
        node = lookupSymbolic(p);
        if (node == null) {
            throw new NoSuchFileException(p);
        }
    }
    return node;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:JrtFileSystem.java

示例14: findNode

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
@Override
public synchronized Node findNode(String str) {
    Node node = findModulesNode(str);
    if (node != null) {
        return node;
    }
    // lazily created for paths like /packages/<package>/<module>/xyz
    // For example /packages/java.lang/java.base/java/lang/
    if (str.startsWith(PACKAGES)) {
        // pkgEndIdx marks end of <package> part
        int pkgEndIdx = str.indexOf('/', PACKAGES_LEN);
        if (pkgEndIdx != -1) {
            // modEndIdx marks end of <module> part
            int modEndIdx = str.indexOf('/', pkgEndIdx + 1);
            if (modEndIdx != -1) {
                // make sure we have such module link!
                // ie., /packages/<package>/<module> is valid
                Node linkNode = nodes.get(str.substring(0, modEndIdx));
                if (linkNode == null || !linkNode.isLink()) {
                    return null;
                }
                // map to "/modules/zyz" path and return that node
                // For example, "/modules/java.base/java/lang" for
                // "/packages/java.lang/java.base/java/lang".
                String mod = MODULES + str.substring(pkgEndIdx + 1);
                return findModulesNode(mod);
            }
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:ExplodedImage.java

示例15: nodesToIterator

import jdk.internal.jimage.ImageReader.Node; //導入依賴的package包/類
private Iterator<Path> nodesToIterator(Path path, String childPrefix, List<Node> childNodes) {
    List<Path> childPaths = new ArrayList<>(childNodes.size());
    if (childPrefix == null) {
        childNodes.stream().forEach((child) -> {
            childPaths.add(toJrtPath(child.getNameString()));
        });
    } else {
        childNodes.stream().forEach((child) -> {
            childPaths.add(toJrtPath(childPrefix + child.getNameString().substring(1)));
        });
    }
    return childPaths.iterator();
}
 
開發者ID:forax,項目名稱:jigsaw-jrtfs,代碼行數:14,代碼來源:JrtFileSystem.java


注:本文中的jdk.internal.jimage.ImageReader.Node類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。