add method to restore content type
[jSite2.git] / src / net / pterodactylus / jsite / project / AbstractEntry.java
index 4f6e6ed..ff04760 100644 (file)
@@ -19,6 +19,8 @@
 
 package net.pterodactylus.jsite.project;
 
+import java.io.File;
+
 import net.pterodactylus.util.beans.AbstractBean;
 
 /**
@@ -43,9 +45,15 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
        /** 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;
 
+       /** The default content type of this entry. */
+       private String defaultContentType;
+
        /** The content type of the file. */
        private String contentType;
 
@@ -70,6 +78,32 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
        /**
         * {@inheritDoc}
         */
+       public boolean isDefault() {
+               return (insert == defaultInsert) && isDefaultContentType();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean isDefaultContentType() {
+               return ((defaultContentType != null) ? defaultContentType.equals(contentType) : (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() {
                return name;
        }
@@ -115,4 +149,22 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
                fireIfPropertyChanged(PROPERTY_CONTENT_TYPE, oldContentType, contentType);
        }
 
+       /**
+        * Sets the default content type of the entry. The default content type is
+        * derived from its extension.
+        * 
+        * @param defaultContentType
+        *            The default content type
+        */
+       void setDefaultContentType(String defaultContentType) {
+               this.defaultContentType = defaultContentType;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void restoreDefaultContentType() {
+               this.contentType = defaultContentType;
+       }
+
 }