some work on the project files
[jSite2.git] / src / net / pterodactylus / jsite / project / Project.java
index b80c293..dda7a5c 100644 (file)
@@ -20,7 +20,9 @@
 package net.pterodactylus.jsite.project;
 
 import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import net.pterodactylus.util.beans.AbstractBean;
@@ -48,6 +50,9 @@ public class Project extends AbstractBean {
        /** Name of the “base path” property. */
        public static final String PROPERTY_BASE_PATH = "basePath";
 
+       /** Name of the “default file” property. */
+       public static final String PROPERTY_DEFAULT_FILE = "defaultFile";
+
        /** Internal ID. */
        private String id;
 
@@ -66,6 +71,9 @@ public class Project extends AbstractBean {
        /** The base path of the project. */
        private String basePath;
 
+       /** The default file. */
+       private String defaultFile;
+
        /** The overrides. */
        private final Map<String, Override> overrides = new HashMap<String, Override>();
 
@@ -214,6 +222,27 @@ public class Project extends AbstractBean {
        }
 
        /**
+        * Returns the default file.
+        *
+        * @return The default file
+        */
+       public String getDefaultFile() {
+               return defaultFile;
+       }
+
+       /**
+        * Sets the default file.
+        *
+        * @param defaultFile
+        *            The default file
+        */
+       public void setDefaultFile(String defaultFile) {
+               String oldDefaultFile = this.defaultFile;
+               this.defaultFile = defaultFile;
+               fireIfPropertyChanged(PROPERTY_DEFAULT_FILE, oldDefaultFile, defaultFile);
+       }
+
+       /**
         * Adds an override for the given file.
         *
         * @param filePath
@@ -244,4 +273,106 @@ public class Project extends AbstractBean {
                return overrides;
        }
 
+       /**
+        * Scans the base path for files and returns the {@link ProjectFile} for the
+        * base path. From this file it is possible to reach all files in the base
+        * path.
+        *
+        * This method is disk-intensive and may take some time on larger
+        * directories!
+        *
+        * @return The file for the base path
+        */
+       public ProjectFile getBaseFile() {
+
+       }
+
+       /**
+        * Implementation of a {@link ProjectFile}.
+        *
+        * @author David ‘Bombe’ Roden &lt;bombe@freenetproject.org&gt;
+        */
+       private static class ProjectFileImpl implements ProjectFile {
+
+               private final ProjectFileImpl parentProjectFile;
+               private final String name;
+               private final boolean directory;
+               private final boolean hidden;
+               private List<ProjectFileImpl> childProjectFiles = new ArrayList<ProjectFileImpl>();
+
+
+
+               public ProjectFileImpl(ProjectFileImpl parentProjectFile, String name, boolean isDirectory, boolean isHidden) {
+                       this.parentProjectFile = parentProjectFile;
+                       this.name = name;
+                       this.directory = isDirectory;
+                       this.hidden = isHidden;
+               }
+
+               //
+               // INTERFACE ProjectFile
+               //
+
+               /**
+                * @see net.pterodactylus.jsite.project.ProjectFile#getName()
+                */
+               public String getName() {
+                       return name;
+               }
+
+               /**
+                * @see net.pterodactylus.jsite.project.ProjectFile#getParents()
+                */
+               public List<ProjectFile> getParents() {
+                       List<ProjectFile> parentProjectFiles = new ArrayList<ProjectFile>();
+                       ProjectFileImpl currentProjectFile = this;
+                       do {
+                               parentProjectFiles.add(0, currentProjectFile);
+                       } while ((currentProjectFile = currentProjectFile.parentProjectFile) != null);
+                       return parentProjectFiles;
+               }
+
+               /**
+                * @see net.pterodactylus.jsite.project.ProjectFile#isFile()
+                */
+               public boolean isFile() {
+                       // TODO Auto-generated method stub
+                       return false;
+               }
+
+               /**
+                * @see net.pterodactylus.jsite.project.ProjectFile#isDirectory()
+                */
+               public boolean isDirectory() {
+                       // TODO Auto-generated method stub
+                       return false;
+               }
+
+               /**
+                * @see net.pterodactylus.jsite.project.ProjectFile#isHidden()
+                */
+               public boolean isHidden() {
+                       // TODO Auto-generated method stub
+                       return false;
+               }
+
+               /**
+                * @see net.pterodactylus.jsite.project.ProjectFile#getFiles()
+                */
+               public List<ProjectFile> getFiles() {
+                       // TODO Auto-generated method stub
+                       return null;
+               }
+
+               //
+               // PRIVATE METHODS
+               //
+
+               private ProjectFileImpl getParent() {
+                       return parentProjectFile;
+               }
+
+
+       }
+
 }