実装 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; package one.nem.lacerta.model;
import java.util.ArrayList;
import java.util.List;
public class PublicPath { public class PublicPath {
/* /*
* ユーザーが扱うパス(内部パスの代替) * ユーザーが扱うパス(内部パスの代替)
*/ */
String[] path; List<String> path = new ArrayList<String>();
public PublicPath() { public PublicPath() {
this.path = new String[0];
} }
public PublicPath load(String[] path) { public PublicPath(List<String> path) {
this.path = 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; return this;
} }
public PublicPath load(String path) { public PublicPath resolve(List<String> path) {
this.path = path.split("/"); for (String p : path) {
resolve(p);
}
return this; return this;
} }
public List<String> getPath() {
return path;
}
public String getStringPath() {
return String.join("/", path);
}
} }