org.sitemesh.offline.directory
Class FileSystemDirectory

java.lang.Object
  extended by org.sitemesh.offline.directory.FileSystemDirectory
All Implemented Interfaces:
Directory

public class FileSystemDirectory
extends Object
implements Directory

Disk backed Directory implementation that uses java.io.File.

Author:
Joe Walnes
See Also:
Directory

Constructor Summary
FileSystemDirectory(File rootDir)
           
FileSystemDirectory(File rootDir, Charset encoding)
           
 
Method Summary
 void copy(String path, Directory destinationDirectory, String destinationPath)
          Copy a file from this directory to another location.
 boolean equals(Object o)
           
 File getFileByPath(String path)
          new ReadableByteChannel() { public int read(ByteBuffer dst) throws IOException { ByteBuffer buffer = dst.put(sourceData); return buffer.position(); } public boolean isOpen() { return true; } public void close() throws IOException { } }
 int hashCode()
           
 List<String> listAllFilePaths()
          Get a list of all file paths (relative to the Directory).
 CharBuffer load(String path)
          Load the contents from a file.
 void load(String path, WritableByteChannel channelToWriteTo)
          Load binary data.
 void save(String path, CharBuffer contents)
          Save the contents to a file, overwriting any existing content.
 void save(String path, ReadableByteChannel channelToReadFrom, int length)
          Save binary data.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileSystemDirectory

public FileSystemDirectory(File rootDir)

FileSystemDirectory

public FileSystemDirectory(File rootDir,
                           Charset encoding)
Method Detail

load

public CharBuffer load(String path)
                throws IOException
Description copied from interface: Directory
Load the contents from a file.

Specified by:
load in interface Directory
Throws:
IOException

save

public void save(String path,
                 CharBuffer contents)
          throws IOException
Description copied from interface: Directory
Save the contents to a file, overwriting any existing content.

Specified by:
save in interface Directory
Throws:
IOException

listAllFilePaths

public List<String> listAllFilePaths()
                              throws IOException
Description copied from interface: Directory
Get a list of all file paths (relative to the Directory). Excludes directories.

Specified by:
listAllFilePaths in interface Directory
Throws:
IOException

load

public void load(String path,
                 WritableByteChannel channelToWriteTo)
          throws IOException
Description copied from interface: Directory
Load binary data.

Specified by:
load in interface Directory
Throws:
IOException

save

public void save(String path,
                 ReadableByteChannel channelToReadFrom,
                 int length)
          throws IOException
Description copied from interface: Directory
Save binary data.

Specified by:
save in interface Directory
Throws:
IOException

copy

public void copy(String path,
                 Directory destinationDirectory,
                 String destinationPath)
          throws IOException
Description copied from interface: Directory
Copy a file from this directory to another location. Will copy raw bytes so can deal with binary data (e.g. images).

Specified by:
copy in interface Directory
Parameters:
path - Path of file to copy (from this Directory)
destinationDirectory - Target directory (may be this)
destinationPath - Path under target directory.
Throws:
IOException

getFileByPath

public File getFileByPath(String path)
new ReadableByteChannel() { public int read(ByteBuffer dst) throws IOException { ByteBuffer buffer = dst.put(sourceData); return buffer.position(); } public boolean isOpen() { return true; } public void close() throws IOException { } }


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.