org.codehaus.mojo.mrm.api
Interface FileSystem

All Superinterfaces:
Serializable
All Known Implementing Classes:
BaseFileSystem

public interface FileSystem
extends Serializable

A repository is just a type of file system.

Since:
1.0

Method Summary
 Entry get(String path)
          Returns the entry at the specified path.
 long getLastModified(DirectoryEntry entry)
          Returns the time that the specified directory entry was last modified.
 DirectoryEntry getRoot()
          Returns the root directory entry.
 Entry[] listEntries(DirectoryEntry directory)
          Lists the entries in the specified directory.
 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).
 

Method Detail

listEntries

Entry[] listEntries(DirectoryEntry directory)
Lists the entries in the specified directory. Some implementations may be lazy caching implementations, in which case it is permitted to return either an empty array, or only those entries which have been loaded into the cache, so consumers should not assume that a missing entry implies non-existence. The only way to be sure that an artifact does not exist is to call the FileEntry.getInputStream() method, although get(String) returning null is also definitive, a non-null does not prove existence).

Parameters:
directory - the directory to list the entries of.
Returns:
a copy of the known entries in the specified directory, never null. The caller can safely modify the returned array.
Since:
1.0

getRoot

DirectoryEntry getRoot()
Returns the root directory entry.

Returns:
the root directory entry.
Since:
1.0

get

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.

Parameters:
path - the path to retrieve the Entry of.
Returns:
the Entry or null if the path definitely does not exist.
Since:
1.0

getLastModified

long getLastModified(DirectoryEntry entry)
                     throws IOException
Returns the time that the specified directory entry was last modified. Note: DefaultDirectoryEntry.getLastModified() delegates to this method.

Parameters:
entry - the directory entry.
Returns:
A long value representing the time the directory was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the the time is unknown.
Throws:
IOException - if an I/O error occurs.
Since:
1.0

mkdir

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

Parameters:
parent - the directory in which the child is to be created.
name - the name of the child directory.
Returns:
the child directory entry.
Throws:
UnsupportedOperationException - if the repository is read-only.
Since:
1.0

put

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

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:
UnsupportedOperationException - if the repository is read-only.
IOException - if the content could not be read/written.
Since:
1.0

put

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

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:
UnsupportedOperationException - if the repository is read-only.
IOException - if the content could not be read/written.
Since:
1.0

remove

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

Parameters:
entry - the entry to remove.
Throws:
UnsupportedOperationException - if the repository is read-only.
Since:
1.0


Copyright © 2009-2011 Codehaus. All Rights Reserved.