From f33c078012fd2c8683a5253e7c9cfffb460d7fcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 30 May 2008 01:24:33 +0200 Subject: [PATCH] add method to return complete path of a project file --- src/net/pterodactylus/jsite/project/Project.java | 13 +++++++++++++ src/net/pterodactylus/jsite/project/ProjectFile.java | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/src/net/pterodactylus/jsite/project/Project.java b/src/net/pterodactylus/jsite/project/Project.java index 4d778ab..7a6ee10 100644 --- a/src/net/pterodactylus/jsite/project/Project.java +++ b/src/net/pterodactylus/jsite/project/Project.java @@ -389,6 +389,19 @@ public class Project extends AbstractBean { } /** + * {@inheritDoc} + */ + /* TODO - caching? */ + public String getCompletePath() { + StringBuilder completePath = new StringBuilder(); + ProjectFileImpl currentProjectFile = this; + do { + completePath.insert(0, File.separatorChar).insert(0, this.getName()); + } while ((currentProjectFile = currentProjectFile.parentProjectFile) != null); + return completePath.substring(1); + } + + /** * @see net.pterodactylus.jsite.project.ProjectFile#isFile() */ public boolean isFile() { diff --git a/src/net/pterodactylus/jsite/project/ProjectFile.java b/src/net/pterodactylus/jsite/project/ProjectFile.java index 984dcbe..1a8738a 100644 --- a/src/net/pterodactylus/jsite/project/ProjectFile.java +++ b/src/net/pterodactylus/jsite/project/ProjectFile.java @@ -19,6 +19,7 @@ package net.pterodactylus.jsite.project; +import java.io.File; import java.util.List; import net.pterodactylus.jsite.core.Core; @@ -48,6 +49,14 @@ public interface ProjectFile { public List getParents(); /** + * Returns the complete path of this file, without a leading + * {@link File#separator}. + * + * @return The complete path of this file + */ + public String getCompletePath(); + + /** * Returns whether this file is a directory. * * @return true if this file is a directory, -- 2.7.4