2 * jSite2 - AbstractEntry.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.jsite.project;
24 import net.pterodactylus.util.beans.AbstractBean;
27 * Abstract base implementation of a {@link Entry}.
29 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
31 public abstract class AbstractEntry extends AbstractBean implements Entry {
33 /** The name of the “name” property. */
34 public static final String PROPERTY_NAME = "name";
36 /** The name of the “insert” property. */
37 public static final String PROPERTY_INSERT = "insert";
39 /** The name of the “content type” property. */
40 public static final String PROPERTY_CONTENT_TYPE = "contentType";
42 /** Whether this entry is virtual. */
43 private final boolean virtual;
45 /** The name of the file. */
48 /** The default insert flag for this entry. */
49 private boolean defaultInsert;
51 /** Whether to insert the file. */
52 private boolean insert;
54 /** The content type of the file. */
55 private String contentType;
58 * Creates a new entry.
61 * <code>true</code> if this entry is virtual,
62 * <code>false</code> otherwise
64 protected AbstractEntry(boolean virtual) {
65 this.virtual = virtual;
71 public boolean isVirtual() {
78 public boolean isDefault() {
79 return (insert == defaultInsert) && (contentType == null);
83 * Sets the default insert flag for this entry. The default insert flag is
84 * derived from {@link File#isHidden()}.
86 * @param defaultInsert
87 * <code>true</code> if the default for this entry is to insert
88 * it, <code>false</code> otherwise
90 void setDefaultInsert(boolean defaultInsert) {
91 this.defaultInsert = defaultInsert;
97 public String getName() {
104 public void setName(String name) {
105 String oldName = this.name;
107 fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
113 public boolean isInsert() {
120 public void setInsert(boolean insert) {
121 boolean oldInsert = this.insert;
122 this.insert = insert;
123 fireIfPropertyChanged(PROPERTY_INSERT, oldInsert, insert);
129 public String getContentType() {
136 public void setContentType(String contentType) {
137 String oldContentType = this.contentType;
138 this.contentType = contentType;
139 fireIfPropertyChanged(PROPERTY_CONTENT_TYPE, oldContentType, contentType);