net.sourceforge.blogentis.storage
Class LocalFileResource

java.lang.Object
  extended bynet.sourceforge.blogentis.storage.LocalFileResource
All Implemented Interfaces:
AbstractFileResource

public class LocalFileResource
extends java.lang.Object
implements AbstractFileResource

Implementation of an AbstractFileResource using local files.

Author:
abas

Field Summary
protected  java.io.File localFile
           
protected  java.lang.String originalPath
           
 
Constructor Summary
(package private) LocalFileResource(java.lang.String path)
           
 
Method Summary
 boolean exists()
          Check whether the file exists.
static java.util.Set getAllFiles(java.lang.String path, FileResourceFilter filter)
           
 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 getName()
           
 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 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

localFile

protected java.io.File localFile

originalPath

protected java.lang.String originalPath
Constructor Detail

LocalFileResource

LocalFileResource(java.lang.String path)
Method Detail

getAllFiles

public static java.util.Set getAllFiles(java.lang.String path,
                                        FileResourceFilter filter)

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.

getName

public java.lang.String getName()

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

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.

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.