Package org.scijava.io.location
Class FileLocation
- java.lang.Object
-
- org.scijava.io.location.AbstractLocation
-
- org.scijava.io.location.FileLocation
-
- All Implemented Interfaces:
BrowsableLocation,Location
public class FileLocation extends AbstractLocation implements BrowsableLocation
- Author:
- Curtis Rueden, Gabriel Einsdorf
-
-
Constructor Summary
Constructors Constructor Description FileLocation(File file)FileLocation(String path)FileLocation(URI path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileLocationchild(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.FilegetFile()Gets the associatedFile.StringgetName()Gets a (typically short) name expressing this location.URIgetURI()Gets the location expressed as aURI, or null if the location cannot be expressed as such.booleanisDirectory()Tests whether this location is a directory, meaning that it can have children.FileLocationparent()Obtains a location pointing to the parent directory of this one.FileLocationsibling(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 class org.scijava.io.location.AbstractLocation
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.scijava.io.location.Location
defaultName
-
-
-
-
Method Detail
-
getURI
public URI getURI()
Description copied from interface:LocationGets the location expressed as aURI, or null if the location cannot be expressed as such.
-
getName
public String getName()
Description copied from interface:LocationGets a (typically short) name expressing this location. This string is not intended to unambiguously identify the location, but rather act as a friendly, human-readable name. The precise behavior will depend on the implementation, but as an example, a file-based location could return the name of the associated file without its full path.
-
parent
public FileLocation parent() throws IOException
Description copied from interface:BrowsableLocationObtains a location pointing to the parent directory of this one.- Specified by:
parentin interfaceBrowsableLocation- Returns:
- the parent location of this one, or
nullif this location has no parent. - Throws:
IOException- if something goes wrong obtaining the parent.
-
children
public Set<BrowsableLocation> children() throws IOException
Description copied from interface:BrowsableLocationObtains a collection of locations for whom this location is the parent. Note that this will only succeed if calls toBrowsableLocation.isDirectory()on this location returntrue.- Specified by:
childrenin interfaceBrowsableLocation- 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.
-
sibling
public FileLocation sibling(String path)
Description copied from interface:BrowsableLocationObtains a location relative to this one, which will be configured like the current location, but point to a the file specified by thepathparameter.- Specified by:
siblingin interfaceBrowsableLocation- Parameters:
path- the relative path of the desired location.- Returns:
- A location that points to the specified file location.
-
child
public FileLocation child(String name)
Description copied from interface:BrowsableLocationObtains a location with the given name, for whom this location is the parent. Note that this will only succeed if calls toBrowsableLocation.isDirectory()on this location returntrue.- Specified by:
childin interfaceBrowsableLocation- Parameters:
name- the name of the child- Returns:
- a location pointing to the child
-
isDirectory
public boolean isDirectory()
Description copied from interface:BrowsableLocationTests whether this location is a directory, meaning that it can have children. It is recommended to use this method before callingBrowsableLocation.child(String)orBrowsableLocation.children(), to ensure those calls succeed.- Specified by:
isDirectoryin interfaceBrowsableLocation- Returns:
- True iff the location represents a directory.
-
-