add default insert flag
[jSite2.git] / src / net / pterodactylus / jsite / project / AbstractEntry.java
index 6a726c6..41449b0 100644 (file)
 
 package net.pterodactylus.jsite.project;
 
+import java.io.File;
+
 import net.pterodactylus.util.beans.AbstractBean;
 
 /**
  * Abstract base implementation of a {@link Entry}.
  * 
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- * @version $Id$
  */
 public abstract class AbstractEntry extends AbstractBean implements Entry {
 
@@ -38,9 +39,15 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
        /** The name of the “content type” property. */
        public static final String PROPERTY_CONTENT_TYPE = "contentType";
 
+       /** Whether this entry is virtual. */
+       private final boolean virtual;
+
        /** The name of the file. */
        private String name;
 
+       /** The default insert flag for this entry. */
+       private boolean defaultInsert;
+
        /** Whether to insert the file. */
        private boolean insert;
 
@@ -48,6 +55,43 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
        private String contentType;
 
        /**
+        * Creates a new entry.
+        * 
+        * @param virtual
+        *            <code>true</code> if this entry is virtual,
+        *            <code>false</code> otherwise
+        */
+       protected AbstractEntry(boolean virtual) {
+               this.virtual = virtual;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean isVirtual() {
+               return virtual;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean isDefault() {
+               return (insert == defaultInsert) && (contentType == null);
+       }
+
+       /**
+        * Sets the default insert flag for this entry. The default insert flag is
+        * derived from {@link File#isHidden()}.
+        * 
+        * @param defaultInsert
+        *            <code>true</code> if the default for this entry is to insert
+        *            it, <code>false</code> otherwise
+        */
+       void setDefaultInsert(boolean defaultInsert) {
+               this.defaultInsert = defaultInsert;
+       }
+
+       /**
         * {@inheritDoc}
         */
        public String getName() {