001: /*
002: JSPWiki - a JSP-based WikiWiki clone.
003:
004: Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006: This program is free software; you can redistribute it and/or modify
007: it under the terms of the GNU Lesser General Public License as published by
008: the Free Software Foundation; either version 2.1 of the License, or
009: (at your option) any later version.
010:
011: This program is distributed in the hope that it will be useful,
012: but WITHOUT ANY WARRANTY; without even the implied warranty of
013: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: GNU Lesser General Public License for more details.
015:
016: You should have received a copy of the GNU Lesser General Public License
017: along with this program; if not, write to the Free Software
018: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020: package com.ecyrd.jspwiki.attachment;
021:
022: import com.ecyrd.jspwiki.WikiEngine;
023: import com.ecyrd.jspwiki.WikiPage;
024:
025: /**
026: * Describes an attachment. Attachments are actually derivatives of
027: * a WikiPage, since they do actually have a WikiName as well.
028: *
029: * @author Erik Bunn
030: * @author Janne Jalkanen
031: */
032: public class Attachment extends WikiPage {
033: private String m_fileName;
034: private String m_parentName;
035: private boolean m_cacheable = true;
036:
037: /**
038: * Creates a new attachment. The final name of the attachment will be
039: * a synthesis of the parent page name and the file name.
040: *
041: * @param engine The WikiEngine which is hosting this attachment.
042: * @param parentPage The page which will contain this attachment.
043: * @param fileName The file name for the attachment.
044: */
045: public Attachment(WikiEngine engine, String parentPage,
046: String fileName) {
047: super (engine, parentPage + "/" + fileName);
048:
049: m_parentName = parentPage;
050: m_fileName = fileName;
051: }
052:
053: /**
054: * Returns a human-readable, only-debugging-suitable description.
055: *
056: * @return A debugging string
057: */
058: public String toString() {
059: return "Attachment [" + getName() + ";mod=" + getLastModified()
060: + "]";
061: }
062:
063: /**
064: * Returns the file name of the attachment.
065: *
066: * @return A String with the file name.
067: */
068: public String getFileName() {
069: return m_fileName;
070: }
071:
072: /**
073: * Sets the file name of this attachment.
074: *
075: * @param name The name of the attachment. Must be a legal file name without
076: * the path.
077: */
078: public void setFileName(String name) {
079: m_fileName = name;
080: }
081:
082: /**
083: * Returns the name of the parent of this Attachment, i.e. the page
084: * which contains this attachment.
085: *
086: * @return String depicting the parent of the attachment.
087: */
088: public String getParentName() {
089: return m_parentName;
090: }
091:
092: /**
093: * Returns true, if this attachment can be cached by the user agent. By default
094: * attachments are cacheable.
095: *
096: * @return False, if the attachment should not be cached by the user agent.
097: * @since 2.5.34
098: */
099: public boolean isCacheable() {
100: return m_cacheable;
101: }
102:
103: /**
104: * Sets this attachment to be cacheable or not. This mostly concerns things
105: * like DynamicAttachments, but it may be useful for certain AttachmentProviders
106: * as well.
107: *
108: * @param value True or false, depending on whether you want this attachment
109: * to be cacheable or not.
110: * @since 2.5.34
111: */
112: public void setCacheable(boolean value) {
113: m_cacheable = value;
114: }
115: }
|