本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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());
}
}
示例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;
}
示例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;
}
示例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();
}