CopyOnWriteFSPath.java
net.minecraft.util.filefix.virtualfilesystem.CopyOnWriteFSPath
信息
- 全限定名:net.minecraft.util.filefix.virtualfilesystem.CopyOnWriteFSPath
- 类型:public class
- 包:net.minecraft.util.filefix.virtualfilesystem
- 源码路径:src/main/java/net/minecraft/util/filefix/virtualfilesystem/CopyOnWriteFSPath.java
- 起始行号:L16
- 实现:Path
- 职责:
TODO
字段/常量
-
path- 类型:
Path - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
fs- 类型:
CopyOnWriteFileSystem - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
-
isAbsolute- 类型:
boolean - 修饰符:
private final - 源码定位:
L19 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private CopyOnWriteFSPath(Path path, CopyOnWriteFileSystem fs, boolean isAbsolute) @ L21
- 构造器名:CopyOnWriteFSPath
- 源码定位:L21
- 修饰符:private
参数:
- path: Path
- fs: CopyOnWriteFileSystem
- isAbsolute: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
protected static CopyOnWriteFSPath of(CopyOnWriteFileSystem fs, String first, String... more) @ L27
- 方法名:of
- 源码定位:L27
- 返回类型:CopyOnWriteFSPath
- 修饰符:protected static
参数:
- fs: CopyOnWriteFileSystem
- first: String
- more: String…
说明:
TODO
public CopyOnWriteFileSystem getFileSystem() @ L38
- 方法名:getFileSystem
- 源码定位:L38
- 返回类型:CopyOnWriteFileSystem
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean isAbsolute() @ L42
- 方法名:isAbsolute
- 源码定位:L42
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public Path getRoot() @ L47
- 方法名:getRoot
- 源码定位:L47
- 返回类型:Path
- 修饰符:public
参数:
- 无
说明:
TODO
public CopyOnWriteFSPath getFileName() @ L52
- 方法名:getFileName
- 源码定位:L52
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- 无
说明:
TODO
public CopyOnWriteFSPath getParent() @ L56
- 方法名:getParent
- 源码定位:L56
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- 无
说明:
TODO
public int getNameCount() @ L69
- 方法名:getNameCount
- 源码定位:L69
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public Path getName(int index) @ L74
- 方法名:getName
- 源码定位:L74
- 返回类型:Path
- 修饰符:public
参数:
- index: int
说明:
TODO
public Path subpath(int beginIndex, int endIndex) @ L83
- 方法名:subpath
- 源码定位:L83
- 返回类型:Path
- 修饰符:public
参数:
- beginIndex: int
- endIndex: int
说明:
TODO
public boolean startsWith(Path other) @ L88
- 方法名:startsWith
- 源码定位:L88
- 返回类型:boolean
- 修饰符:public
参数:
- other: Path
说明:
TODO
public boolean endsWith(Path other) @ L94
- 方法名:endsWith
- 源码定位:L94
- 返回类型:boolean
- 修饰符:public
参数:
- other: Path
说明:
TODO
public CopyOnWriteFSPath normalize() @ L104
- 方法名:normalize
- 源码定位:L104
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- 无
说明:
TODO
public CopyOnWriteFSPath resolve(Path other) @ L111
- 方法名:resolve
- 源码定位:L111
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- other: Path
说明:
TODO
public CopyOnWriteFSPath resolve(String other) @ L121
- 方法名:resolve
- 源码定位:L121
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- other: String
说明:
TODO
public CopyOnWriteFSPath resolve(String first, String... more) @ L125
- 方法名:resolve
- 源码定位:L125
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- first: String
- more: String…
说明:
TODO
public CopyOnWriteFSPath relativize(Path other) @ L135
- 方法名:relativize
- 源码定位:L135
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- other: Path
说明:
TODO
public URI toUri() @ L145
- 方法名:toUri
- 源码定位:L145
- 返回类型:URI
- 修饰符:public
参数:
- 无
说明:
TODO
public CopyOnWriteFSPath toAbsolutePath() @ L150
- 方法名:toAbsolutePath
- 源码定位:L150
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- 无
说明:
TODO
public CopyOnWriteFSPath toRealPath(LinkOption... options) @ L154
- 方法名:toRealPath
- 源码定位:L154
- 返回类型:CopyOnWriteFSPath
- 修饰符:public
参数:
- options: LinkOption…
说明:
TODO
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) @ L158
- 方法名:register
- 源码定位:L158
- 返回类型:WatchKey
- 修饰符:public
参数:
- watcher: WatchService
- events: Kind<?>[]
- modifiers: Modifier…
说明:
TODO
public int compareTo(Path other) @ L163
- 方法名:compareTo
- 源码定位:L163
- 返回类型:int
- 修饰符:public
参数:
- other: Path
说明:
TODO
public String toString() @ L169
- 方法名:toString
- 源码定位:L169
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean equals(Object o) @ L174
- 方法名:equals
- 源码定位:L174
- 返回类型:boolean
- 修饰符:public
参数:
- o: Object
说明:
TODO
public int hashCode() @ L184
- 方法名:hashCode
- 源码定位:L184
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
protected boolean isRoot() @ L189
- 方法名:isRoot
- 源码定位:L189
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
protected static CopyOnWriteFSPath asCow(Path other) @ L193
- 方法名:asCow
- 源码定位:L193
- 返回类型:CopyOnWriteFSPath
- 修饰符:protected static
参数:
- other: Path
说明:
TODO
代码
public class CopyOnWriteFSPath implements Path {
private final Path path;
private final CopyOnWriteFileSystem fs;
private final boolean isAbsolute;
private CopyOnWriteFSPath(Path path, CopyOnWriteFileSystem fs, boolean isAbsolute) {
this.path = path;
this.fs = fs;
this.isAbsolute = isAbsolute;
}
protected static CopyOnWriteFSPath of(CopyOnWriteFileSystem fs, String first, String... more) {
boolean isAbsolute = false;
while (first.startsWith("/")) {
isAbsolute = true;
first = first.substring(1);
}
return new CopyOnWriteFSPath(fs.backingFileSystem().getPath(first, more), fs, isAbsolute);
}
public CopyOnWriteFileSystem getFileSystem() {
return this.fs;
}
@Override
public boolean isAbsolute() {
return this.isAbsolute;
}
@Override
public @Nullable Path getRoot() {
return this.isAbsolute() ? this.fs.rootPath() : null;
}
public @Nullable CopyOnWriteFSPath getFileName() {
return this.isRoot() ? null : new CopyOnWriteFSPath(this.path.getFileName(), this.fs, false);
}
public @Nullable CopyOnWriteFSPath getParent() {
if (this.isRoot()) {
return null;
} else {
Path parent = this.path.getParent();
if (parent == null) {
return this.isAbsolute() ? this.fs.rootPath() : null;
} else {
return new CopyOnWriteFSPath(parent, this.fs, this.isAbsolute());
}
}
}
@Override
public int getNameCount() {
return this.path.toString().isEmpty() && this.isAbsolute ? 0 : this.path.getNameCount();
}
@Override
public Path getName(int index) {
if (this.isRoot()) {
throw new IllegalArgumentException();
} else {
return new CopyOnWriteFSPath(this.path.getName(index), this.fs, false);
}
}
@Override
public Path subpath(int beginIndex, int endIndex) {
return new CopyOnWriteFSPath(this.path.subpath(beginIndex, endIndex), this.fs, false);
}
@Override
public boolean startsWith(Path other) {
CopyOnWriteFSPath otherCow = asCow(other);
return this.isAbsolute() != otherCow.isAbsolute() ? false : this.path.startsWith(otherCow.path);
}
@Override
public boolean endsWith(Path other) {
CopyOnWriteFSPath otherCow = asCow(other);
if (otherCow.isAbsolute()) {
return this.isAbsolute() ? this.equals(otherCow) : false;
} else {
return this.path.endsWith(otherCow.path);
}
}
public CopyOnWriteFSPath normalize() {
Path normalize = this.path.normalize();
return !this.isAbsolute() || !normalize.startsWith(".") && !normalize.startsWith("..")
? new CopyOnWriteFSPath(normalize, this.fs, this.isAbsolute())
: this.fs.rootPath();
}
public CopyOnWriteFSPath resolve(Path other) {
CopyOnWriteFSPath otherCow = asCow(other);
if (other.isAbsolute()) {
return otherCow;
} else {
Path result = this.path.resolve(otherCow.path);
return new CopyOnWriteFSPath(result, this.fs, this.isAbsolute());
}
}
public CopyOnWriteFSPath resolve(String other) {
return this.resolve(this.getFileSystem().getPath(other));
}
public CopyOnWriteFSPath resolve(String first, String... more) {
CopyOnWriteFSPath result = this.resolve(first);
for (String s : more) {
result = result.resolve(s);
}
return result;
}
public CopyOnWriteFSPath relativize(Path other) {
CopyOnWriteFSPath otherCow = asCow(other);
if (this.isAbsolute() != otherCow.isAbsolute()) {
throw new IllegalArgumentException("'other' is different type of Path");
} else {
Path result = this.path.relativize(otherCow.path);
return new CopyOnWriteFSPath(result, this.fs, false);
}
}
@Override
public URI toUri() {
throw new UnsupportedOperationException();
}
public CopyOnWriteFSPath toAbsolutePath() {
return this.isAbsolute() ? this : new CopyOnWriteFSPath(this.path, this.fs, true);
}
public CopyOnWriteFSPath toRealPath(LinkOption... options) throws CowFSNoSuchFileException {
return this.fs.provider().getRealPath(this);
}
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public int compareTo(Path other) {
CopyOnWriteFSPath otherCow = asCow(other);
return this.toString().compareTo(otherCow.toString());
}
@Override
public String toString() {
return this.isAbsolute() ? "/" + this.path : this.path.toString();
}
@Override
public boolean equals(Object o) {
if (o != null && this.getClass() == o.getClass()) {
CopyOnWriteFSPath paths = (CopyOnWriteFSPath)o;
return this.isAbsolute == paths.isAbsolute && Objects.equals(this.path, paths.path) && Objects.equals(this.fs, paths.fs);
} else {
return false;
}
}
@Override
public int hashCode() {
return Objects.hash(this.path, this.fs, this.isAbsolute);
}
protected boolean isRoot() {
return this.getNameCount() == 0;
}
protected static CopyOnWriteFSPath asCow(Path other) {
if (other instanceof CopyOnWriteFSPath copyOnWriteFSPath) {
return copyOnWriteFSPath;
} else {
throw new CowFSIllegalArgumentException("Other path is of mismatching file system");
}
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
CowFSIllegalArgumentException()
- 引用位置: