From: David ‘Bombe’ Roden Date: Fri, 30 May 2008 10:07:03 +0000 (+0200) Subject: add getParent() X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=178831df2f0ea06252247de88e513b1811179956;p=jSite2.git add getParent() --- diff --git a/src/net/pterodactylus/jsite/project/Project.java b/src/net/pterodactylus/jsite/project/Project.java index 7391ebf..431ce87 100644 --- a/src/net/pterodactylus/jsite/project/Project.java +++ b/src/net/pterodactylus/jsite/project/Project.java @@ -312,7 +312,7 @@ public class Project extends AbstractBean { if (!directory.isDirectory()) { return; } - for (File file: directory.listFiles()) { + for (File file : directory.listFiles()) { ProjectFileImpl projectFileChild = projectFile.addFile(file.getName(), file.length(), file.isDirectory(), file.isHidden()); if (file.isDirectory()) { scanDirectory(file, projectFileChild); @@ -383,6 +383,13 @@ public class Project extends AbstractBean { } /** + * @see net.pterodactylus.jsite.project.ProjectFile#getParent() + */ + public ProjectFile getParent() { + return parentProjectFile; + } + + /** * {@inheritDoc} */ public long getSize() { diff --git a/src/net/pterodactylus/jsite/project/ProjectFile.java b/src/net/pterodactylus/jsite/project/ProjectFile.java index 53a7b5b..7f9cc2d 100644 --- a/src/net/pterodactylus/jsite/project/ProjectFile.java +++ b/src/net/pterodactylus/jsite/project/ProjectFile.java @@ -28,22 +28,30 @@ import net.pterodactylus.jsite.core.Core; * Abstraction for a that exists on the machine {@link Core} is being run on. * This abstraction layer exists to make it possible to run jSite as a daemon * and only connect to it via network. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public interface ProjectFile { /** * Returns the name of the file. - * + * * @return The name of the file */ public String getName(); /** + * Returns the parent of this project file. + * + * @return The parent of this project file, or null if this + * project file does not have a parent + */ + public ProjectFile getParent(); + + /** * Returns all parent files of this file. This file is the last file in the * returned list. - * + * * @return A list of all parents of this file and this file itself */ public List getParents(); @@ -51,7 +59,7 @@ public interface ProjectFile { /** * Returns the complete path of this file, without a leading * {@link File#separator}. - * + * * @return The complete path of this file */ public String getCompletePath(); @@ -59,7 +67,7 @@ public interface ProjectFile { /** * Returns the size of the file. If this file is a directory, the returned * value is unspecified. - * + * * @see File#length() * @return The size of the file */ @@ -67,7 +75,7 @@ public interface ProjectFile { /** * Returns whether this file is a directory. - * + * * @return true if this file is a directory, * false otherwise */ @@ -75,7 +83,7 @@ public interface ProjectFile { /** * Returns whether this file is a file (as opposed to being a directory). - * + * * @return true if this file is a file, false * otherwise */ @@ -83,14 +91,14 @@ public interface ProjectFile { /** * Returns whether this file is hidden. - * + * * @return true if this file is hidden */ public boolean isHidden(); /** * If this file is a directory, returns all files in this directory. - * + * * @see #isDirectory() * @return All files in this directory if this file is a directory, or * null if this file is not a directory