From: David ‘Bombe’ Roden Date: Fri, 30 May 2008 08:09:55 +0000 (+0200) Subject: rename Override to FileOverride X-Git-Url: https://git.pterodactylus.net/?p=jSite2.git;a=commitdiff_plain;h=43c0171aed0a097a9dc965252e9aaddf4afc16d2 rename Override to FileOverride --- diff --git a/src/net/pterodactylus/jsite/project/FileOverride.java b/src/net/pterodactylus/jsite/project/FileOverride.java new file mode 100644 index 0000000..be11887 --- /dev/null +++ b/src/net/pterodactylus/jsite/project/FileOverride.java @@ -0,0 +1,139 @@ +/* + * jSite2 - Override.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package net.pterodactylus.jsite.project; + +/** + * An override is used to enter other information about a file than the defaults + * would have yielded. It is also used to add redirects to a project. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + * @version $Id$ + */ +public class FileOverride { + + /** The insert override. */ + private Boolean insert; + + /** The override content type. */ + private String contentType; + + /** The redirect target. */ + private String redirectTarget; + + /** + * Returns the insert override. + * + * @return true if the entry should be inserted, + * false if it should not be inserted, + * null if the default should not be overridden + */ + public Boolean isInsert() { + return insert; + } + + /** + * Sets the insert override. + * + * @param insert + * true if the entry should be inserted, + * false if it should not be inserted, + * null if the default should not be overridden + */ + public void setInsert(Boolean insert) { + this.insert = insert; + } + + /** + * Returns the override content type. + * + * @return The override content type, or null to not override + * the default + */ + public String getContentType() { + return contentType; + } + + /** + * Sets the override content type. + * + * @param contentType + * The override content type, or null to not + * override the default + */ + public void setContentType(String contentType) { + this.contentType = contentType; + } + + /** + * Returns the target of a redirect. + * + * @return The target URI of the redirect, or null if no + * redirect should be created + */ + public String getRedirectTarget() { + return redirectTarget; + } + + /** + * Sets the target of a redirect. + * + * @param redirectTarget + * The target URI of the redirect, or null if no + * redirect should be created + */ + public void setRedirectTarget(String redirectTarget) { + this.redirectTarget = redirectTarget; + } + + /** + * @see java.lang.Object#toString() + */ + @java.lang.Override + public String toString() { + return ((insert != null) ? String.valueOf(insert) : "") + "|" + ((contentType != null) ? contentType : "") + "|" + ((redirectTarget != null) ? redirectTarget : ""); + } + + /** + * Converts an override string created by {@link #toString()} back to an + * {@link FileOverride} object. + * + * @param overrideString + * The textual representation of the override + * @return The parsed override, or null if the string could + * not be parsed + */ + public static FileOverride valueOf(String overrideString) { + FileOverride override = new FileOverride(); + String[] parts = overrideString.split("\\|"); + if (parts.length < 3) { + return null; + } + if (parts[0].length() > 0) { + override.insert = Boolean.valueOf(parts[0]); + } + if (parts[1].length() > 0) { + override.contentType = parts[1]; + } + if (parts[2].length() > 0) { + override.redirectTarget = parts[2]; + } + return override; + } + +} diff --git a/src/net/pterodactylus/jsite/project/Override.java b/src/net/pterodactylus/jsite/project/Override.java deleted file mode 100644 index 1f7bc78..0000000 --- a/src/net/pterodactylus/jsite/project/Override.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * jSite2 - Override.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ -package net.pterodactylus.jsite.project; - -/** - * An override is used to enter other information about a file than the defaults - * would have yielded. It is also used to add redirects to a project. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ - */ -public class Override { - - /** The insert override. */ - private Boolean insert; - - /** The override content type. */ - private String contentType; - - /** The redirect target. */ - private String redirectTarget; - - /** - * Returns the insert override. - * - * @return true if the entry should be inserted, - * false if it should not be inserted, - * null if the default should not be overridden - */ - public Boolean isInsert() { - return insert; - } - - /** - * Sets the insert override. - * - * @param insert - * true if the entry should be inserted, - * false if it should not be inserted, - * null if the default should not be overridden - */ - public void setInsert(Boolean insert) { - this.insert = insert; - } - - /** - * Returns the override content type. - * - * @return The override content type, or null to not override - * the default - */ - public String getContentType() { - return contentType; - } - - /** - * Sets the override content type. - * - * @param contentType - * The override content type, or null to not - * override the default - */ - public void setContentType(String contentType) { - this.contentType = contentType; - } - - /** - * Returns the target of a redirect. - * - * @return The target URI of the redirect, or null if no - * redirect should be created - */ - public String getRedirectTarget() { - return redirectTarget; - } - - /** - * Sets the target of a redirect. - * - * @param redirectTarget - * The target URI of the redirect, or null if no - * redirect should be created - */ - public void setRedirectTarget(String redirectTarget) { - this.redirectTarget = redirectTarget; - } - - /** - * @see java.lang.Object#toString() - */ - @java.lang.Override - public String toString() { - return ((insert != null) ? String.valueOf(insert) : "") + "|" + ((contentType != null) ? contentType : "") + "|" + ((redirectTarget != null) ? redirectTarget : ""); - } - - /** - * Converts an override string created by {@link #toString()} back to an - * {@link Override} object. - * - * @param overrideString - * The textual representation of the override - * @return The parsed override, or null if the string could - * not be parsed - */ - public static Override valueOf(String overrideString) { - Override override = new Override(); - String[] parts = overrideString.split("\\|"); - if (parts.length < 3) { - return null; - } - if (parts[0].length() > 0) { - override.insert = Boolean.valueOf(parts[0]); - } - if (parts[1].length() > 0) { - override.contentType = parts[1]; - } - if (parts[2].length() > 0) { - override.redirectTarget = parts[2]; - } - return override; - } - -} diff --git a/src/net/pterodactylus/jsite/project/Project.java b/src/net/pterodactylus/jsite/project/Project.java index 265eeff..7391ebf 100644 --- a/src/net/pterodactylus/jsite/project/Project.java +++ b/src/net/pterodactylus/jsite/project/Project.java @@ -32,7 +32,7 @@ import net.pterodactylus.util.beans.AbstractBean; /** * Container for project information. A Project is capable of notifying * {@link PropertyChangeListener}s if any of the contained properties change. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ public class Project extends AbstractBean { @@ -77,7 +77,7 @@ public class Project extends AbstractBean { private String defaultFile; /** The overrides. */ - private final Map overrides = new HashMap(); + private final Map fileOverrides = new HashMap(); /** * Creates a new project. @@ -88,7 +88,7 @@ public class Project extends AbstractBean { /** * Clones the given project. - * + * * @param project */ Project(Project project) { @@ -101,7 +101,7 @@ public class Project extends AbstractBean { /** * Returns the internal ID. - * + * * @return The internal ID */ String getId() { @@ -110,7 +110,7 @@ public class Project extends AbstractBean { /** * Sets the internal ID. - * + * * @param id * The internal ID */ @@ -120,7 +120,7 @@ public class Project extends AbstractBean { /** * Returns the name of the project. - * + * * @return The name of the project */ public String getName() { @@ -129,7 +129,7 @@ public class Project extends AbstractBean { /** * Sets the name of the project. - * + * * @param name * The name of the project */ @@ -141,7 +141,7 @@ public class Project extends AbstractBean { /** * Returns the description of the project. - * + * * @return The description of the project */ public String getDescription() { @@ -150,7 +150,7 @@ public class Project extends AbstractBean { /** * Sets the description of the project - * + * * @param description * The description of the project */ @@ -162,7 +162,7 @@ public class Project extends AbstractBean { /** * Returns the public key of the project. - * + * * @return The public key of the project */ public String getPublicKey() { @@ -171,7 +171,7 @@ public class Project extends AbstractBean { /** * Sets the public key of the project. - * + * * @param publicKey * The public key of the project */ @@ -183,7 +183,7 @@ public class Project extends AbstractBean { /** * Returns the private key of the project. - * + * * @return The private key of the project */ public String getPrivateKey() { @@ -192,7 +192,7 @@ public class Project extends AbstractBean { /** * Sets the private key of the project. - * + * * @param privateKey * The private key of the project */ @@ -204,7 +204,7 @@ public class Project extends AbstractBean { /** * Returns the base path of the project. - * + * * @return The base path of the project */ public String getBasePath() { @@ -213,7 +213,7 @@ public class Project extends AbstractBean { /** * Sets the base path of the project. - * + * * @param basePath * The base path of the project */ @@ -225,7 +225,7 @@ public class Project extends AbstractBean { /** * Returns the default file. - * + * * @return The default file */ public String getDefaultFile() { @@ -234,7 +234,7 @@ public class Project extends AbstractBean { /** * Sets the default file. - * + * * @param defaultFile * The default file */ @@ -245,34 +245,34 @@ public class Project extends AbstractBean { } /** - * Adds an override for the given file. - * + * Adds a file override for the given file. + * * @param filePath * The file path * @param override * The override for the file */ - public void addOverride(String filePath, Override override) { - overrides.put(filePath, override); + public void addFileOverride(String filePath, FileOverride override) { + fileOverrides.put(filePath, override); } /** - * Removes the override for the given file. - * + * Removes the file override for the given file. + * * @param filePath * The file path for which to remove the override */ - public void removeOverride(String filePath) { - overrides.remove(filePath); + public void removeFileOverride(String filePath) { + fileOverrides.remove(filePath); } /** - * Returns the list of {@link Override}s. - * - * @return All overrides + * Returns the list of {@link FileOverride}s. + * + * @return All file overrides */ - public Map getOverrides() { - return overrides; + public Map getFileOverrides() { + return fileOverrides; } /** @@ -280,7 +280,7 @@ public class Project extends AbstractBean { * 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, or null if the base * path does not denote an existing directory */ @@ -301,7 +301,7 @@ public class Project extends AbstractBean { /** * Scans the given directory and recreates the file and directory structure * in the given project file. - * + * * @param directory * The directory to scan * @param projectFile @@ -323,7 +323,7 @@ public class Project extends AbstractBean { /** * Implementation of a {@link ProjectFile}. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ private static class ProjectFileImpl implements ProjectFile, Comparable { @@ -348,7 +348,7 @@ public class Project extends AbstractBean { /** * Creates a new project fie. - * + * * @param parentProjectFile * The parent of the project file, or null if * the new project file does not have a parent @@ -449,7 +449,7 @@ public class Project extends AbstractBean { /** * Adds a new project file as child to this project file. - * + * * @param name * The name of the file * @param size diff --git a/src/net/pterodactylus/jsite/project/ProjectManager.java b/src/net/pterodactylus/jsite/project/ProjectManager.java index b4f9fe0..8f1cb8a 100644 --- a/src/net/pterodactylus/jsite/project/ProjectManager.java +++ b/src/net/pterodactylus/jsite/project/ProjectManager.java @@ -152,8 +152,8 @@ public class ProjectManager implements PropertyChangeListener { int overrideIndex = 0; while (projectProperties.containsKey(projectPrefix + ".overrides." + overrideIndex)) { String filePath = projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath"); - Override override = Override.valueOf(projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".override")); - project.addOverride(filePath, override); + FileOverride override = FileOverride.valueOf(projectProperties.getProperty(projectPrefix + ".overrides." + overrideIndex + ".override")); + project.addFileOverride(filePath, override); overrideIndex++; } projects.add(project); @@ -187,7 +187,7 @@ public class ProjectManager implements PropertyChangeListener { projectProperties.setProperty(projectPrefix + ".basePath", project.getBasePath()); projectProperties.setProperty(projectPrefix + ".defaultFile", project.getDefaultFile()); int overrideIndex = 0; - for (Entry overrideEntry: project.getOverrides().entrySet()) { + for (Entry overrideEntry: project.getFileOverrides().entrySet()) { projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".filePath", overrideEntry.getKey()); projectProperties.setProperty(projectPrefix + ".overrides." + overrideIndex + ".override", overrideEntry.getValue().toString()); overrideIndex++;