net.sourceforge.blogentis.slide
Class SlideMemoryFile

java.lang.Object
  extended bynet.sourceforge.blogentis.slide.SlideMemoryFile
All Implemented Interfaces:
AbstractFileResource

public class SlideMemoryFile
extends java.lang.Object
implements AbstractFileResource

A memory-based AbstractFileResource. It is mainly used for saving to the slide store.

Author:
abas

Field Summary
(package private)  java.util.Map properties
           
 
Constructor Summary
SlideMemoryFile(Blog blog, java.lang.String path)
           
 
Method Summary
 boolean exists()
          Check whether the file exists.
 Blog getBlog()
           
 java.io.InputStream getFileAsInputStream()
           
 java.lang.String getFileAsString()
          Get the contents of the file as a string.
 java.util.Date getLastModified()
          Get the last modification time of the file.
 java.lang.String getMimeType()
          Get the stored mime-type of the file or compute it.
 java.lang.String getPath()
          Get the the path that this file has.
 java.lang.String getProperty(java.lang.String propertyName)
          Retrieve a property of the file.
 int getSize()
          Get the size of the file.
 boolean isDirectory()
          Determine if this is a directory.
 boolean isOriginal()
          Check whether this file has not been modified by the user.
 void setContents(byte[] contents)
           
 void setContents(java.io.InputStream contents)
           
 void setLastModified(java.util.Date lastModified)
           
 void setMimeType(java.lang.String mimeType)
           
 void setProperty(java.lang.String propertyName, java.lang.String propertyContents)
          Set a property on a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

java.util.Map properties
Constructor Detail

SlideMemoryFile

public SlideMemoryFile(Blog blog,
                       java.lang.String path)
Method Detail

setContents

public void setContents(byte[] contents)

setContents

public void setContents(java.io.InputStream contents)

getPath

public java.lang.String getPath()
Description copied from interface: AbstractFileResource
Get the the path that this file has.

Specified by:
getPath in interface AbstractFileResource
Returns:
the path of the file.

exists

public boolean exists()
Description copied from interface: AbstractFileResource
Check whether the file exists.

Specified by:
exists in interface AbstractFileResource
Returns:
true if the file exists and is a file, false otherwise.

getSize

public int getSize()
Description copied from interface: AbstractFileResource
Get the size of the file.

Specified by:
getSize in interface AbstractFileResource
Returns:
the size of the file in bytes.

getLastModified

public java.util.Date getLastModified()
Description copied from interface: AbstractFileResource
Get the last modification time of the file.

Specified by:
getLastModified in interface AbstractFileResource
Returns:
the last modification time of the file.

getMimeType

public java.lang.String getMimeType()
Description copied from interface: AbstractFileResource
Get the stored mime-type of the file or compute it.

Specified by:
getMimeType in interface AbstractFileResource
Returns:
the mime-type of the file.

getFileAsInputStream

public java.io.InputStream getFileAsInputStream()
                                         throws java.io.FileNotFoundException
Specified by:
getFileAsInputStream in interface AbstractFileResource
Returns:
@throws FileNotFoundException if exists() is false.
Throws:
java.io.FileNotFoundException

getFileAsString

public java.lang.String getFileAsString()
                                 throws java.io.FileNotFoundException
Description copied from interface: AbstractFileResource
Get the contents of the file as a string.

Specified by:
getFileAsString in interface AbstractFileResource
Returns:
@throws FileNotFoundException if exists() is false.
Throws:
java.io.FileNotFoundException

getBlog

public Blog getBlog()

setLastModified

public void setLastModified(java.util.Date lastModified)

setMimeType

public void setMimeType(java.lang.String mimeType)

isOriginal

public boolean isOriginal()
Description copied from interface: AbstractFileResource
Check whether this file has not been modified by the user. Only files that return this as false will be backed up.

Specified by:
isOriginal in interface AbstractFileResource
Returns:
true if the file has not been modified by the user and is the original file distributed.

getProperty

public java.lang.String getProperty(java.lang.String propertyName)
Description copied from interface: AbstractFileResource
Retrieve a property of the file. Properties are String/String key/value pairs. Implementation is optional.

Specified by:
getProperty in interface AbstractFileResource
Parameters:
propertyName - the name of the property to fetch.
Returns:
the property or null of the property does not exist or the file does not support properties.

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.String propertyContents)
Description copied from interface: AbstractFileResource
Set a property on a file. This method can fail silently if the file does not support properties. If the property exists, its contents will be overwritten.

Specified by:
setProperty in interface AbstractFileResource
Parameters:
propertyName - the name of the property.
propertyContents - the contents of the property.

isDirectory

public boolean isDirectory()
Description copied from interface: AbstractFileResource
Determine if this is a directory.

Specified by:
isDirectory in interface AbstractFileResource
Returns:
true if a directory


Copyright © 2003-2004 SourceForge.net. All Rights Reserved.