add default content type notion
[jSite2.git] / src / net / pterodactylus / jsite / project / AbstractEntry.java
index 41449b0..6e0c9d4 100644 (file)
@@ -51,6 +51,9 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
        /** 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;
 
@@ -76,7 +79,14 @@ public abstract class AbstractEntry extends AbstractBean implements Entry {
         * {@inheritDoc}
         */
        public boolean isDefault() {
-               return (insert == defaultInsert) && (contentType == null);
+               return (insert == defaultInsert) && isDefaultContentType();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean isDefaultContentType() {
+               return ((defaultContentType != null) ? defaultContentType.equals(contentType) : (contentType == null));
        }
 
        /**
@@ -139,4 +149,15 @@ 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;
+       }
+
 }