Package org.scijava.io.location
Interface BrowsableLocation
-
- All Superinterfaces:
Location
- All Known Implementing Classes:
FileLocation
public interface BrowsableLocation extends Location
ALocationthat offers methods to browse other locations relative to it.- Author:
- Gabriel Einsdorf, Curtis Rueden
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BrowsableLocationchild(String name)Obtains a location with the given name, for whom this location is the parent.Set<BrowsableLocation>children()Obtains a collection of locations for whom this location is the parent.booleanisDirectory()Tests whether this location is a directory, meaning that it can have children.BrowsableLocationparent()Obtains a location pointing to the parent directory of this one.BrowsableLocationsibling(String path)Obtains a location relative to this one, which will be configured like the current location, but point to a the file specified by thepathparameter.-
Methods inherited from interface org.scijava.io.location.Location
defaultName, getName, getURI
-
-
-
-
Method Detail
-
parent
BrowsableLocation parent() throws IOException
Obtains a location pointing to the parent directory of this one.- Returns:
- the parent location of this one, or
nullif this location has no parent. - Throws:
IOException- if something goes wrong obtaining the parent.
-
children
Set<BrowsableLocation> children() throws IOException
Obtains a collection of locations for whom this location is the parent. Note that this will only succeed if calls toisDirectory()on this location returntrue.- Returns:
- A set containing the children of this location, or
Collections.EMPTY_SETif this location has no children. - Throws:
IOException- if something goes wrong obtaining the children.IllegalArgumentException- if this location is not a directory (i.e.,isDirectory()returns false).
-
sibling
BrowsableLocation sibling(String path) throws IOException
Obtains a location relative to this one, which will be configured like the current location, but point to a the file specified by thepathparameter.- Parameters:
path- the relative path of the desired location.- Returns:
- A location that points to the specified file location.
- Throws:
IOException- if something goes wrong obtaining the sibling
-
isDirectory
boolean isDirectory()
Tests whether this location is a directory, meaning that it can have children. It is recommended to use this method before callingchild(String)orchildren(), to ensure those calls succeed.- Returns:
- True iff the location represents a directory.
-
child
BrowsableLocation child(String name) throws IOException
Obtains a location with the given name, for whom this location is the parent. Note that this will only succeed if calls toisDirectory()on this location returntrue.- Parameters:
name- the name of the child- Returns:
- a location pointing to the child
- Throws:
IOException- if something goes wrong obtaining the child.IllegalArgumentException- if this location is not a directory (i.e.,isDirectory()returns false).
-
-