実装 WIP

This commit is contained in:
r-ca 2024-01-13 15:12:03 +09:00
parent 180428fbb7
commit 04651f3b8e
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -1,23 +1,47 @@
package one.nem.lacerta.model;
import java.util.ArrayList;
import java.util.List;
public class PublicPath {
/*
* ユーザーが扱うパス(内部パスの代替)
*/
String[] path;
List<String> path = new ArrayList<String>();
public PublicPath() {
this.path = new String[0];
}
public PublicPath load(String[] path) {
public PublicPath(List<String> path) {
this.path = path;
}
private void add(String path) {
this.path.add(path);
}
public PublicPath resolve(String path) {
if (path.equals("..")) {
this.path.remove(this.path.size() - 1);
} else {
add(path);
}
return this;
}
public PublicPath load(String path) {
this.path = path.split("/");
public PublicPath resolve(List<String> path) {
for (String p : path) {
resolve(p);
}
return this;
}
public List<String> getPath() {
return path;
}
public String getStringPath() {
return String.join("/", path);
}
}