org.codehaus.mojo.mrm.api
Class BaseFileSystem

java.lang.Object
  extended by org.codehaus.mojo.mrm.api.BaseFileSystem
All Implemented Interfaces:
Serializable, FileSystem

public abstract class BaseFileSystem
extends Object
implements FileSystem

Base implementation of FileSystem that all implementations should extend from.

Since:
1.0
See Also:
Serialized Form

Constructor Summary
BaseFileSystem()
           
 
Method Summary
protected  Entry get(DirectoryEntry parent, String name)
          Gets the named entry in the specified directory.
 Entry get(String path)
          Returns the entry at the specified path.
 DirectoryEntry getRoot()
          Returns the root directory entry.
 DirectoryEntry mkdir(DirectoryEntry parent, String name)
          Makes the specified child directory.
 FileEntry put(DirectoryEntry parent, String name, byte[] content)
          Puts the specified content into a the specified directory.
 FileEntry put(DirectoryEntry parent, String name, InputStream content)
          Puts the specified content into a the specified directory.
 void remove(Entry entry)
          Removes the specified entry (and if the entry is a directory, all its children).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.mojo.mrm.api.FileSystem
getLastModified, listEntries
 

Constructor Detail

BaseFileSystem

public BaseFileSystem()
Method Detail

getRoot

public DirectoryEntry getRoot()
Returns the root directory entry.

Specified by:
getRoot in interface FileSystem
Returns:
the root directory entry.

get

public Entry get(String path)
Returns the entry at the specified path. A null result proves the path does not exist, however very lazy caching implementations may return a non-null entry for paths which do not exist.

Specified by:
get in interface FileSystem
Parameters:
path - the path to retrieve the Entry of.
Returns:
the Entry or null if the path definitely does not exist.

get

protected Entry get(DirectoryEntry parent,
                    String name)
Gets the named entry in the specified directory. The default implementation lists all the entries in the directory and looks for the one with the matching name. Caching implementations will likely want to override this behaviour.

Parameters:
parent - the directory.
name - the name of the entry to get.
Returns:
the Entry or null if the entry does not exist.

mkdir

public DirectoryEntry mkdir(DirectoryEntry parent,
                            String name)
Makes the specified child directory.

Specified by:
mkdir in interface FileSystem
Parameters:
parent - the directory in which the child is to be created.
name - the name of the child directory.
Returns:
the child directory entry.

put

public FileEntry put(DirectoryEntry parent,
                     String name,
                     InputStream content)
              throws IOException
Puts the specified content into a the specified directory.

Specified by:
put in interface FileSystem
Parameters:
parent - the directory in which the content is to be created/updated.
name - the name of the file.
content - the content (implementer is responsible for closing).
Returns:
the FileEntry that was created/updated.
Throws:
IOException - if the content could not be read/written.

put

public FileEntry put(DirectoryEntry parent,
                     String name,
                     byte[] content)
              throws IOException
Puts the specified content into a the specified directory.

Specified by:
put in interface FileSystem
Parameters:
parent - the directory in which the content is to be created/updated.
name - the name of the file.
content - the content.
Returns:
the FileEntry that was created/updated.
Throws:
IOException - if the content could not be read/written.

remove

public void remove(Entry entry)
Removes the specified entry (and if the entry is a directory, all its children).

Specified by:
remove in interface FileSystem
Parameters:
entry - the entry to remove.


Copyright © 2009-2011 Codehaus. All Rights Reserved.