/*
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.     
 */
package org.apache.wiki.attachment;

import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiPage;

/**
 *  Describes an attachment.  Attachments are actually derivatives of
 *  a WikiPage, since they do actually have a WikiName as well.
 *
 */
public class Attachment
    extends WikiPage
{
    private String m_fileName;
    private String m_parentName;
    private boolean m_cacheable = true;

    /**
     *  Creates a new attachment.  The final name of the attachment will be 
     *  a synthesis of the parent page name and the file name.
     *  
     *  @param engine     The WikiEngine which is hosting this attachment.
     *  @param parentPage The page which will contain this attachment.
     *  @param fileName   The file name for the attachment.
     */
    public Attachment( WikiEngine engine, String parentPage, String fileName )
    {
        super( engine, parentPage+"/"+fileName );

        m_parentName = parentPage;
        m_fileName   = fileName;
    }

    /**
     *  Returns a human-readable, only-debugging-suitable description.
     *  
     *  @return A debugging string
     */
    public String toString()
    {
        return "Attachment ["+getName()+";mod="+getLastModified()+"]";
    }

    /**
     *  Returns the file name of the attachment.
     *  
     *  @return A String with the file name.
     */
    public String getFileName()
    {
        return m_fileName;
    }

    /**
     *  Sets the file name of this attachment. 
     *  
     *  @param name The name of the attachment.  Must be a legal file name without
     *              the path.
     */
    public void setFileName( String name )
    {
        m_fileName = name;
    }

    /**
     *  Returns the name of the parent of this Attachment, i.e. the page
     *  which contains this attachment.
     *  
     *  @return String depicting the parent of the attachment.
     */
    public String getParentName()
    {
        return m_parentName;
    }

    /**
     *  Returns true, if this attachment can be cached by the user agent.  By default
     *  attachments are cacheable.
     *  
     *  @return False, if the attachment should not be cached by the user agent.
     *  @since 2.5.34
     */
    public boolean isCacheable()
    {
        return m_cacheable;
    }

    /**
     *  Sets this attachment to be cacheable or not.  This mostly concerns things
     *  like DynamicAttachments, but it may be useful for certain AttachmentProviders
     *  as well.
     *  
     *  @param value True or false, depending on whether you want this attachment
     *               to be cacheable or not.
     *  @since 2.5.34
     */
    public void setCacheable(boolean value)
    {
        m_cacheable = value;
    }
}

@@ -996,20 +996,16 @@
 tives of
-%0A * 
  a WikiP
@@ -1061,11 +1061,8 @@
 ll.%0A
- *%0A
  */%0A
@@ -1084,20 +1084,16 @@
 tachment
-%0A   
  extends
@@ -1105,10 +1105,11 @@
 Page
+ %7B
 %0A
-%7B
 %0A   
@@ -1603,16 +1603,22 @@
 achment(
+ final
  WikiEng
@@ -1628,16 +1628,22 @@
  engine,
+ final
  String 
@@ -1653,16 +1653,22 @@
 entPage,
+ final
  String 
@@ -1673,28 +1673,24 @@
 g fileName )
-%0A   
  %7B%0A        s
@@ -1717,13 +1717,17 @@
 Page
-+%22/%22+
+ + %22/%22 + 
 file
@@ -1969,20 +1969,16 @@
 String()
-%0A   
  %7B%0A     
@@ -2001,17 +2001,19 @@
 hment %5B%22
-+
+ + 
 getName(
@@ -2017,17 +2017,21 @@
 me()
-+
+ + 
 %22;mod=%22
-+
+ + 
 getL
@@ -2043,17 +2043,19 @@
 dified()
-+
+ + 
 %22%5D%22;%0A   
@@ -2204,28 +2204,24 @@
 etFileName()
-%0A   
  %7B%0A        r
@@ -2392,35 +2392,16 @@
  without
-%0A     *            
   the pa
@@ -2440,16 +2440,22 @@
 ileName(
+ final
  String 
@@ -2581,24 +2581,16 @@
 the page
-%0A     * 
  which c
@@ -2727,20 +2727,16 @@
 ntName()
-%0A   
  %7B%0A     
@@ -2859,24 +2859,16 @@
  default
-%0A     * 
  attachm
@@ -3039,20 +3039,16 @@
 heable()
-%0A   
  %7B%0A     
@@ -3166,24 +3166,16 @@
 s things
-%0A     * 
  like Dy
@@ -3216,16 +3216,24 @@
 eful for
+%0A     * 
  certain
@@ -3252,24 +3252,16 @@
 roviders
-%0A     * 
  as well
@@ -3356,29 +3356,8 @@
 ment
-%0A     *              
  to 
@@ -3436,16 +3436,23 @@
 cheable(
+ final 
 boolean 
@@ -3456,21 +3456,18 @@
 an value
-)%0A  
  
+)
  %7B%0A     
@@ -3496,10 +3496,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

apply format & fixes suggested by intellij