68 lines
1.1 KiB
Java
68 lines
1.1 KiB
Java
package com.madeorsk.smartnotes.paths;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public class FolderPath implements Path
|
|
{
|
|
private String name;
|
|
private FolderPath parent;
|
|
private List<Path> content = new ArrayList<Path>();
|
|
|
|
public FolderPath(String name, FolderPath parent)
|
|
{
|
|
this.name = name;
|
|
this.parent = parent;
|
|
}
|
|
|
|
public void addPath(Path path)
|
|
{
|
|
this.content.add(path);
|
|
}
|
|
|
|
public FolderPath getFolder(String folderName)
|
|
{
|
|
for (Path path : this.content)
|
|
if (path.isFolder())
|
|
if (((FolderPath) path).getName().equalsIgnoreCase(folderName))
|
|
return (FolderPath) path;
|
|
return null;
|
|
}
|
|
|
|
public boolean containsFolder(String folderName)
|
|
{
|
|
for (Path path : this.content)
|
|
if (path.isFolder())
|
|
if (((FolderPath) path).getName().equalsIgnoreCase(folderName))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
public FolderPath setName(String name)
|
|
{
|
|
this.name = name;
|
|
return this;
|
|
}
|
|
|
|
public String getName()
|
|
{
|
|
return this.name;
|
|
}
|
|
|
|
public FolderPath getParent()
|
|
{
|
|
return this.parent;
|
|
}
|
|
|
|
public List<Path> getContent()
|
|
{
|
|
return this.content;
|
|
}
|
|
|
|
@Override
|
|
public boolean isFolder()
|
|
{
|
|
return true;
|
|
}
|
|
}
|