public class Location extends Object
Modifier | Constructor and Description |
---|---|
protected |
Location() |
|
Location(File file) |
|
Location(Location parent,
String child) |
|
Location(String pathname) |
|
Location(String parent,
String child) |
Modifier and Type | Method and Description |
---|---|
static void |
cacheDirectoryListings(boolean cache)
Turn cacheing of directory listings on or off.
|
boolean |
canRead()
If the underlying location is a URL, this method will return true if
the URL exists.
|
boolean |
canWrite()
If the underlying location is a URL, this method will always return false.
|
static void |
checkValidId(String id)
Checks that the given id points at a valid data stream.
|
static void |
cleanStaleCacheEntries()
Remove any cached directory listings that have expired.
|
static void |
clearDirectoryListingsCache()
Clear the directory listings cache.
|
boolean |
createNewFile()
Creates a new empty file named by this Location's path name iff a file
with this name does not already exist.
|
boolean |
delete()
Deletes this file.
|
void |
deleteOnExit()
Request that this file be deleted when the JVM terminates.
|
boolean |
equals(Object obj) |
boolean |
exists()
Returns whether or not the pathname exists.
|
Location |
getAbsoluteFile() |
String |
getAbsolutePath() |
Location |
getCanonicalFile() |
String |
getCanonicalPath()
Returns the canonical path to this file.
|
static IRandomAccess |
getHandle(String id)
Gets an IRandomAccess object that can read from the given file.
|
static IRandomAccess |
getHandle(String id,
boolean writable)
Gets an IRandomAccess object that can read from or write to the given file.
|
static IRandomAccess |
getHandle(String id,
boolean writable,
boolean allowArchiveHandles)
Gets an IRandomAccess object that can read from or write to the given file.
|
static HashMap<String,Object> |
getIdMap()
Return the id mapping.
|
static IRandomAccess |
getMappedFile(String id)
Gets the random access handle for the given id.
|
static String |
getMappedId(String id)
Gets the actual filename on disk for the given id.
|
String |
getName()
Returns the name of this file, i.e.
|
String |
getParent()
Returns the name of this file's parent directory, i.e.
|
Location |
getParentFile() |
String |
getPath() |
int |
hashCode() |
boolean |
isAbsolute()
Tests whether or not this path name is absolute.
|
boolean |
isDirectory()
Returns true if this pathname exists and represents a directory.
|
boolean |
isFile()
Returns true if this pathname exists and represents a regular file.
|
boolean |
isHidden()
Returns true if the pathname is 'hidden'.
|
long |
lastModified()
Return the last modification time of this file, in milliseconds since
the UNIX epoch.
|
long |
length() |
String[] |
list()
Return a list of file names in this directory.
|
String[] |
list(boolean noHiddenFiles)
Return a list of all of the files in this directory.
|
Location[] |
listFiles()
Return a list of absolute files in this directory.
|
static void |
mapFile(String id,
IRandomAccess ira)
Maps the given id to the given IRandomAccess object.
|
static void |
mapId(String id,
String filename)
Maps the given id to an actual filename on disk.
|
boolean |
mkdirs() |
static void |
reset()
Clear all caches and reset cache-related bookkeeping variables to their
original values.
|
static void |
setCacheDirectoryTimeout(double sec)
Cache directory listings for this many seconds before relisting.
|
static void |
setIdMap(HashMap<String,Object> map)
Set the id mapping using the given HashMap.
|
String |
toString() |
URL |
toURL()
Return the URL corresponding to this pathname.
|
protected Location loc
public Location(String pathname)
public Location(File file)
protected Location()
public static void reset()
public static void cacheDirectoryListings(boolean cache)
cache
- - true to turn cacheing on, false to leave it off.public static void setCacheDirectoryTimeout(double sec)
sec
- - use the cache if a directory list was done within this many
seconds.public static void clearDirectoryListingsCache()
public static void cleanStaleCacheEntries()
public static void mapId(String id, String filename)
getMappedId(String)
public static void mapFile(String id, IRandomAccess ira)
public static String getMappedId(String id)
mapId(String, String)
public static IRandomAccess getMappedFile(String id)
public static void setIdMap(HashMap<String,Object> map)
IllegalArgumentException
- if the given HashMap is null.public static IRandomAccess getHandle(String id) throws IOException
IOException
IRandomAccess
public static IRandomAccess getHandle(String id, boolean writable) throws IOException
IOException
IRandomAccess
public static IRandomAccess getHandle(String id, boolean writable, boolean allowArchiveHandles) throws IOException
IOException
IRandomAccess
public static void checkValidId(String id) throws IOException
id
- The id string to validate.IOException
- if the id is not valid.public String[] list(boolean noHiddenFiles)
File.list()
public boolean canRead()
File.canRead()
public boolean canWrite()
File.canWrite()
public boolean createNewFile() throws IOException
IOException
- if an I/O error occurred, or the
abstract pathname is a URLFile.createNewFile()
public boolean mkdirs()
Location.mkdirs()
public boolean delete()
isDirectory()
returns true, then the
directory must be empty in order to be deleted. URLs cannot be deleted.File.delete()
public void deleteOnExit()
File.deleteOnExit()
public boolean equals(Object obj)
equals
in class Object
File.equals(Object)
,
URL.equals(Object)
public boolean exists()
File.exists()
public Location getAbsoluteFile()
public String getAbsolutePath()
public Location getCanonicalFile() throws IOException
IOException
public String getCanonicalPath() throws IOException
getAbsolutePath()
). Otherwise, this method
will delegate to File.getCanonicalPath()
.IOException
public String getName()
File.getName()
public String getParent()
File.getParent()
public Location getParentFile()
public String getPath()
public boolean isAbsolute()
File.isAbsolute()
public boolean isDirectory()
File.isDirectory()
public boolean isFile()
File.exists()
public boolean isHidden()
File.isHidden()
public long lastModified()
public long length()
public String[] list()
public Location[] listFiles()
public URL toURL() throws MalformedURLException
MalformedURLException
File.toURL()
public String toString()
toString
in class Object
File.toString()
,
URL.toString()
Copyright © 2014 Open Microscopy Environment