-/*
- * jSite2 - AbstractEntry.java -
- * Copyright © 2008 David Roden
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * 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.io.File;
-
-import net.pterodactylus.util.beans.AbstractBean;
-
-/**
- * Abstract base implementation of a {@link Entry}.
- *
- * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
- */
-public abstract class AbstractEntry extends AbstractBean implements Entry {
-
- /** The name of the “name” property. */
- public static final String PROPERTY_NAME = "name";
-
- /** The name of the “insert” property. */
- public static final String PROPERTY_INSERT = "insert";
-
- /** 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;
-
- /** The default content type of this entry. */
- private String defaultContentType;
-
- /** The content type of the file. */
- 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) && 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;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setName(String name) {
- String oldName = this.name;
- this.name = name;
- fireIfPropertyChanged(PROPERTY_NAME, oldName, name);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isInsert() {
- return insert;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setInsert(boolean insert) {
- boolean oldInsert = this.insert;
- this.insert = insert;
- fireIfPropertyChanged(PROPERTY_INSERT, oldInsert, insert);
- }
-
- /**
- * {@inheritDoc}
- */
- public String getContentType() {
- return contentType;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setContentType(String contentType) {
- String oldContentType = this.contentType;
- this.contentType = contentType;
- 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;
- }
-
-}