Skip to content
Snippets Groups Projects
Commit 64adffa7 authored by ribeaudc's avatar ribeaudc
Browse files

add:

- exceptions thrown

SVN: 2198
parent ef7e2588
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException;
/**
* Node representing a directory.
*
*
* @author Franz-Josef Elmer
*/
public interface IDirectory extends INode, Iterable<INode>
......@@ -34,7 +34,7 @@ public interface IDirectory extends INode, Iterable<INode>
* @return <code>null</code> if there is no child node named <code>name</code>.
*/
public INode tryToGetNode(String name);
/**
* Makes a new subdirectory in this directory. Does nothing if the subdirectory already exists.
*
......@@ -43,21 +43,21 @@ public interface IDirectory extends INode, Iterable<INode>
* @throws EnvironmentFailureException if the subdirectory cannot be created because of some other reason.
*/
public IDirectory makeDirectory(String name) throws UserFailureException, EnvironmentFailureException;
/**
* Adds the specified real file to this directory. The content of <code>file</code> will be copied. If it
* is a folder also its complete content including all subfolders will be copied.
* Adds the specified real file to this directory. The content of <code>file</code> will be copied. If it is a
* folder also its complete content including all subfolders will be copied.
*
* @return the new node. It will be a {@link ILink} if <code>file</code> is a symbolic link, a {@link IDirectory}
* if <code>file</code> is a folder, or {@link IFile} if <code>file</code> is a plain file.
* if <code>file</code> is a folder, or {@link IFile} if <code>file</code> is a plain file.
*/
public INode addFile(File file);
public INode addFile(File file) throws UserFailureException, EnvironmentFailureException;
/**
* Adds a plain file named <code>key</code> with content <code>value</code> to this directory.
*/
public IFile addKeyValuePair(String key, String value);
/**
* Adds the link named <code>name</code> to this directory which refers to the specified node.
*/
......
......@@ -39,7 +39,7 @@ class Directory extends AbstractNode implements IDirectory
throw new UserFailureException("Not a directory: " + directory.getAbsolutePath());
}
}
public INode tryToGetNode(String name)
{
java.io.File[] files = nodeFile.listFiles();
......@@ -68,7 +68,7 @@ class Directory extends AbstractNode implements IDirectory
if (successful == false)
{
throw new EnvironmentFailureException("Couldn't create directory " + dir.getAbsolutePath()
+ " for some unknown reason.");
+ " for some unknown reason.");
}
return new Directory(dir);
}
......@@ -80,7 +80,7 @@ class Directory extends AbstractNode implements IDirectory
return new File(file);
}
public INode addFile(java.io.File file)
public INode addFile(java.io.File file) throws UserFailureException, EnvironmentFailureException
{
INode node = NodeFactory.createNode(file);
node.extractTo(nodeFile);
......@@ -98,18 +98,19 @@ class Directory extends AbstractNode implements IDirectory
return new Iterator<INode>()
{
private java.io.File[] files = nodeFile.listFiles();
private int index;
public void remove()
{
throw new UnsupportedOperationException();
}
public INode next()
{
return index >= files.length ? null : NodeFactory.createNode(files[index++]);
}
public boolean hasNext()
{
return index < files.length;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment