mirror of
https://github.com/Maschell/JNUSTool.git
synced 2025-01-09 14:59:22 +01:00
92 lines
1.6 KiB
Java
92 lines
1.6 KiB
Java
|
import java.util.Collection;
|
||
|
import java.util.TreeMap;
|
||
|
|
||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||
|
|
||
|
public class Directory {
|
||
|
String name = "";
|
||
|
TreeMap<String,Directory> folder = new TreeMap<>();
|
||
|
TreeMap<String,FEntry> files = new TreeMap<>();
|
||
|
|
||
|
public Directory get(String s){
|
||
|
return folder.get(s);
|
||
|
}
|
||
|
|
||
|
public Directory(String name){
|
||
|
setName(name);
|
||
|
}
|
||
|
|
||
|
public boolean containsFolder(String s){
|
||
|
return folder.containsKey(s);
|
||
|
}
|
||
|
|
||
|
public Directory getFolder(String s){
|
||
|
return folder.get(s);
|
||
|
}
|
||
|
|
||
|
public Directory addFolder(Directory s){
|
||
|
return folder.put(s.getName(),s);
|
||
|
}
|
||
|
public boolean containsFile(String s){
|
||
|
return files.containsKey(s);
|
||
|
}
|
||
|
|
||
|
public FEntry getFile(String s){
|
||
|
return files.get(s);
|
||
|
}
|
||
|
|
||
|
public FEntry addFile(FEntry s){
|
||
|
return files.put(s.getFileName(),s);
|
||
|
}
|
||
|
|
||
|
public String getName() {
|
||
|
return name;
|
||
|
}
|
||
|
|
||
|
public void setName(String name) {
|
||
|
this.name = name;
|
||
|
}
|
||
|
|
||
|
|
||
|
public Collection<Directory> getFolder() {
|
||
|
return folder.values();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
public Collection<FEntry> getFiles() {
|
||
|
return files.values();
|
||
|
}
|
||
|
|
||
|
public void setFiles(TreeMap<String, FEntry> files) {
|
||
|
this.files = files;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String toString(){
|
||
|
System.out.println(name + ":");
|
||
|
for(Directory d : folder.values()){
|
||
|
System.out.println(d);
|
||
|
}
|
||
|
for(String s : files.keySet()){
|
||
|
System.out.println(s);
|
||
|
}
|
||
|
return "";
|
||
|
}
|
||
|
|
||
|
public DefaultMutableTreeNode getNodes(){
|
||
|
DefaultMutableTreeNode node = new DefaultMutableTreeNode(getName());
|
||
|
|
||
|
for(Directory f: getFolder()){
|
||
|
node.add(f.getNodes());
|
||
|
}
|
||
|
|
||
|
for(FEntry f: getFiles()){
|
||
|
node.add(new DefaultMutableTreeNode(f));
|
||
|
}
|
||
|
return node;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|