X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fproject%2FFileOverride.java;h=f9b44ab9ea377b27a1c0267f5552c7ca7236581d;hb=f15dbb6a29e2d4332399624b4158aa657095b746;hp=be11887b0b34974e9c36637b242e66017b2affa8;hpb=43c0171aed0a097a9dc965252e9aaddf4afc16d2;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/project/FileOverride.java b/src/net/pterodactylus/jsite/project/FileOverride.java index be11887..f9b44ab 100644 --- a/src/net/pterodactylus/jsite/project/FileOverride.java +++ b/src/net/pterodactylus/jsite/project/FileOverride.java @@ -16,17 +16,26 @@ * 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; +import java.util.logging.Level; +import java.util.logging.Logger; + +import net.pterodactylus.util.logging.Logging; + /** * 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 logger. */ + private static final Logger logger = Logging.getLogger(FileOverride.class.getName()); + /** The insert override. */ private Boolean insert; @@ -37,8 +46,18 @@ public class FileOverride { private String redirectTarget; /** + * Checks whether this override has any content. + * + * @return true if this override does not have any effects, + * false otherwise + */ + public boolean isEmpty() { + return (insert == null) && (contentType == null) && (redirectTarget == null); + } + + /** * 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 @@ -49,7 +68,7 @@ public class FileOverride { /** * Sets the insert override. - * + * * @param insert * true if the entry should be inserted, * false if it should not be inserted, @@ -61,7 +80,7 @@ public class FileOverride { /** * Returns the override content type. - * + * * @return The override content type, or null to not override * the default */ @@ -71,7 +90,7 @@ public class FileOverride { /** * Sets the override content type. - * + * * @param contentType * The override content type, or null to not * override the default @@ -82,7 +101,7 @@ public class FileOverride { /** * Returns the target of a redirect. - * + * * @return The target URI of the redirect, or null if no * redirect should be created */ @@ -92,7 +111,7 @@ public class FileOverride { /** * Sets the target of a redirect. - * + * * @param redirectTarget * The target URI of the redirect, or null if no * redirect should be created @@ -112,7 +131,7 @@ public class FileOverride { /** * 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 @@ -121,16 +140,14 @@ public class FileOverride { 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) { + logger.log(Level.FINEST, "parts.length: " + parts.length); + if ((parts.length > 0) && (parts[0].length() > 0)) { override.insert = Boolean.valueOf(parts[0]); } - if (parts[1].length() > 0) { + if ((parts.length > 1) && (parts[1].length() > 0)) { override.contentType = parts[1]; } - if (parts[2].length() > 0) { + if ((parts.length > 2) && (parts[2].length() > 0)) { override.redirectTarget = parts[2]; } return override;