public class Location
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected class |
Location.ListingsResult |
Constructor and Description |
---|
Location(java.io.File file) |
Location(Location parent,
java.lang.String child) |
Location(java.lang.String pathname) |
Location(java.lang.String parent,
java.lang.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(java.lang.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(java.lang.Object obj) |
boolean |
exists()
Returns whether or not the pathname exists.
|
Location |
getAbsoluteFile() |
java.lang.String |
getAbsolutePath() |
Location |
getCanonicalFile() |
java.lang.String |
getCanonicalPath()
Returns the canonical path to this file.
|
static IRandomAccess |
getHandle(java.lang.String id)
Gets an IRandomAccess object that can read from the given file.
|
static IRandomAccess |
getHandle(java.lang.String id,
boolean writable)
Gets an IRandomAccess object that can read from or write to the given file.
|
static IRandomAccess |
getHandle(java.lang.String id,
boolean writable,
boolean allowArchiveHandles)
Gets an IRandomAccess object that can read from or write to the given file.
|
static IRandomAccess |
getHandle(java.lang.String id,
boolean writable,
boolean allowArchiveHandles,
int bufferSize) |
static java.util.HashMap<java.lang.String,java.lang.Object> |
getIdMap()
Return the id mapping.
|
static IRandomAccess |
getMappedFile(java.lang.String id)
Gets the random access handle for the given id.
|
static java.lang.String |
getMappedId(java.lang.String id)
Gets the actual filename on disk for the given id.
|
java.lang.String |
getName()
Returns the name of this file, i.e.
|
java.lang.String |
getParent()
Returns the name of this file's parent directory, i.e.
|
Location |
getParentFile() |
java.lang.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() |
java.lang.String[] |
list()
Return a list of file names in this directory.
|
java.lang.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(java.lang.String id,
IRandomAccess ira)
Maps the given id to the given IRandomAccess object.
|
static void |
mapId(java.lang.String id,
java.lang.String filename)
Maps the given id to an actual filename on disk.
|
boolean |
mkdirs()
Creates a directory structures described by this Location's internal
File instance. |
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(java.util.HashMap<java.lang.String,java.lang.Object> map)
Set the id mapping using the given HashMap.
|
java.lang.String |
toString() |
java.net.URL |
toURL()
Return the URL corresponding to this pathname.
|
public Location(java.lang.String pathname)
public Location(java.io.File file)
public Location(java.lang.String parent, java.lang.String child)
public Location(Location parent, java.lang.String child)
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(java.lang.String id, java.lang.String filename)
getMappedId(String)
public static void mapFile(java.lang.String id, IRandomAccess ira)
public static java.lang.String getMappedId(java.lang.String id)
mapId(String, String)
public static IRandomAccess getMappedFile(java.lang.String id)
public static java.util.HashMap<java.lang.String,java.lang.Object> getIdMap()
public static void setIdMap(java.util.HashMap<java.lang.String,java.lang.Object> map)
java.lang.IllegalArgumentException
- if the given HashMap is null.public static IRandomAccess getHandle(java.lang.String id) throws java.io.IOException
java.io.IOException
IRandomAccess
public static IRandomAccess getHandle(java.lang.String id, boolean writable) throws java.io.IOException
java.io.IOException
IRandomAccess
public static IRandomAccess getHandle(java.lang.String id, boolean writable, boolean allowArchiveHandles) throws java.io.IOException
java.io.IOException
IRandomAccess
public static IRandomAccess getHandle(java.lang.String id, boolean writable, boolean allowArchiveHandles, int bufferSize) throws java.io.IOException
java.io.IOException
public static void checkValidId(java.lang.String id) throws java.io.IOException
id
- The id string to validate.java.io.IOException
- if the id is not valid.public java.lang.String[] list(boolean noHiddenFiles)
File.list()
public boolean canRead()
File.canRead()
public boolean canWrite()
File.canWrite()
public boolean createNewFile() throws java.io.IOException
java.io.IOException
- if an I/O error occurred, or the
abstract pathname is a URLFile.createNewFile()
public boolean mkdirs()
File
instance.true
if the directory structure was created
successfully.File.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(java.lang.Object obj)
equals
in class java.lang.Object
File.equals(Object)
,
URL.equals(Object)
public int hashCode()
hashCode
in class java.lang.Object
public boolean exists()
File.exists()
public Location getAbsoluteFile()
public java.lang.String getAbsolutePath()
public Location getCanonicalFile() throws java.io.IOException
java.io.IOException
public java.lang.String getCanonicalPath() throws java.io.IOException
getAbsolutePath()
). Otherwise, this method
will delegate to File.getCanonicalPath()
.java.io.IOException
public java.lang.String getName()
File.getName()
public java.lang.String getParent()
File.getParent()
public Location getParentFile()
public java.lang.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()
File.lastModified()
,
URLConnection.getLastModified()
public long length()
File.length()
,
URLConnection.getContentLength()
public java.lang.String[] list()
public Location[] listFiles()
public java.net.URL toURL() throws java.net.MalformedURLException
java.net.MalformedURLException
File.toURL()
public java.lang.String toString()
toString
in class java.lang.Object
File.toString()
,
URL.toString()
Copyright © 2014 Open Microscopy Environment