|
Extension SDK 10.1.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.ide.net.URLFileSystem
The URLFileSystem
class is responsible for encapsulating the
notion of file system operations on content that is pointed to by an
URL
.
The behavior of URLFileSystem
can be extended by subclasses
of URLFileSystemHelper
. An instance of
URLFileSystemHelper
is registered with URLFileSystem
in association with a particular protocol. Protocol-specific
behavior can thus be encapsulated by a specific implementation of
URLFileSystemHelper
.
Nested Class Summary | |
static class |
URLFileSystem.FileInfo
The FileInfo class encapsulates the information
describing files returned by the ls(URL) and ls(URL,
URLFilter) methods. |
Method Summary | |
static void |
addExistsTest(URLExistsTest existsTest)
Add an implementation of the URLExistTest interface. |
static boolean |
canCreate(java.net.URL url)
Tests whether the application can create the resource at the specified URL . |
static java.net.URL |
canonicalize(java.net.URL url)
Returns a canonical form of the URL , if one is available. |
static boolean |
canRead(java.net.URL url)
Tests whether the application can read the resource at the specified URL . |
static boolean |
canWrite(java.net.URL url)
Tests whether the application can modify the resource at the specified URL . |
static java.net.URL |
convertSuffix(java.net.URL url,
java.lang.String oldSuffix,
java.lang.String newSuffix)
Takes the given URL and checks if its Object.toString()
representation ends with the specified oldSuffix . |
static void |
copy(java.io.InputStream in,
java.net.URL dst)
Copies the contents of in to dst . |
static void |
copy(java.net.URL src,
java.io.File dst)
Copies the contents at src to dst . |
static void |
copy(java.net.URL src,
java.net.URL dst)
Copies the contents at src to dst . |
static java.net.URL |
createTempFile(java.lang.String prefix,
java.lang.String suffix,
java.net.URL directory)
Creates a new empty temporary file in the specified directory using the given prefix and suffix strings to generate its name. |
static boolean |
delete(java.net.URL url)
Deletes the content pointed to by the specified URL . |
static java.net.URL |
ensureSuffix(java.net.URL url,
java.lang.String suffix)
This method ensures that the specified URL ends with the
specified suffix . |
static boolean |
equals(java.net.URL url1,
java.net.URL url2)
Returns true if both of the specified URL
parameters point to the same URL object or if the
both URL parameters have the same protocol and the
protocol helper determines that the URL objects are
equal. |
static boolean |
exists(java.net.URL url)
Tests whether a resource at the specified URL location
currently exists. |
static URLFileSystemHelper |
findHelper(java.lang.String protocol)
Returns the URLFileSystemHelper class that is currently
registered to handle operations related to the specified
protocol . |
static URLFileSystemHelper |
findHelper(java.net.URL url)
Returns the URLFileSystemHelper class that is currently
registered to handle operations related to the specified
URL . |
static java.net.URL |
getBaseParent(java.net.URL url,
java.lang.String relativeSpec)
|
static javax.swing.Icon |
getDefaultIcon(java.net.URL url)
Returns a standard Icon that can be used to represent the
resource designated by the specified URL . |
static java.lang.String |
getFileName(java.net.URL url)
Returns the name of the file contained by the URL , not
including any protocol, hostname authentication, directory path,
anchor, or query. |
static long |
getLength(java.net.URL url)
Returns the size in bytes of the content pointed to by the specified URL . |
static java.lang.String |
getName(java.net.URL url)
Returns the name of the file contained by the URL with the file extension removed. |
static java.net.URL |
getParent(java.net.URL url)
Returns the URL representing the parent directory of
the specified URL . |
static java.lang.String |
getPath(java.net.URL url)
Returns the path part of the URL . |
static java.lang.String |
getPathNoExt(java.net.URL url)
Returns the path part of the URL without the last file
extension. |
static java.lang.String |
getPlatformPathName(java.net.URL url)
Returns the platform-dependent String representation of the URL ; the returned string should be considered acceptable
for users to read. |
static java.lang.String |
getSuffix(java.net.URL url)
If a dot ('.') occurs in the file name of the path portion of the URL , then all of the text starting at the last dot is
returned, including the dot. |
static javax.swing.Icon |
getSystemIcon(java.net.URL url)
Returns the Icon used by the operating system to represent
the resource designated by the specified URL ; if an
Icon cannot be obtained from the operating system, then
returns a standard Icon representing a file or folder,
as appropriate. |
static boolean |
hasSuffix(java.net.URL url,
java.lang.String suffix)
Returns true if the path part of the URL
ends with the given suffix String. |
static boolean |
hasSuffix(java.net.URL url,
java.lang.String[] suffixs)
Returns true if the path part of the URL
ends with any of the given suffixs String. |
static boolean |
isBaseURLFor(java.net.URL url1,
java.net.URL url2)
Returns true if url1 represents a
a directory and url2 points to a location within
url1 's directory tree. |
static boolean |
isBound(java.net.URL url)
This method tests whether the specified URL is bound to
an existing resource, which may reside in memory (i.e. |
static boolean |
isDirectory(java.net.URL url)
Tests whether the location indicated by the URL is
a directory. |
static boolean |
isDirectoryPath(java.net.URL url)
Tests whether the location indicated by the URL
represents a directory path. |
static boolean |
isHidden(java.net.URL url)
Tests whether the resource indiciated by the URL is a
hidden file. |
static boolean |
isLocalFileSystemCaseSensitive()
Returns true if the local file system is case
sensitive. |
static boolean |
isReadOnly(java.net.URL url)
Returns true if the resource pointed to by the
specified URL is read-only; returns false
otherwise. |
static boolean |
isRegularFile(java.net.URL url)
Tests whether the resource indiciated by the URL is
a regular file. |
static boolean |
isRoot(java.net.URL url)
Returns true if the specified URL
corresponds to a root file system; false
otherwise. |
static boolean |
isValid(java.net.URL url)
Tests whether the specified URL is valid. |
static long |
lastModified(java.net.URL url)
Returns the last modified time of the resource pointed to by the URL . |
static java.net.URL[] |
list(java.net.URL url)
Returns an array of URL s naming files and directories in
the directory indicated by the URL . |
static java.net.URL[] |
list(java.net.URL url,
URLFilter filter)
Returns an array of URL s naming files and directories in
the directory indicated by the URL ; the specified
URLFilter is applied to determine which URL s will
be returned. |
static java.net.URL[] |
listRoots()
Returns an array of URL s that represent the root file
systems that are currently available. |
static URLFileSystem.FileInfo[] |
ls(java.net.URL url)
|
static URLFileSystem.FileInfo[] |
ls(java.net.URL url,
URLFilter filter)
|
static boolean |
mkdir(java.net.URL url)
Creates the directory indicated by the URL . |
static boolean |
mkdirs(java.net.URL url)
Creates the directory indicated by the specified URL
including any necessary but nonexistent parent directories. |
static java.io.InputStream |
openInputStream(java.net.URL url)
Opens an InputStream for the location indicated by the
specified URL . |
static java.io.OutputStream |
openOutputStream(java.net.URL url)
Opens an OutputStream for the location indicated by the
specified URL . |
static void |
registerHelper(java.lang.String protocol,
URLFileSystemHelper helper)
Registers the specified URLFileSystemHelper as the object
that can handle URLFileSystem operations for URL s
of the specified protocol . |
static boolean |
renameTo(java.net.URL oldURL,
java.net.URL newURL)
Renames the resource indicated by the first URL to the
name indicated by the second URL . |
static boolean |
setLastModified(java.net.URL url,
long time)
Sets the last-modified timestamp of the resource indicated by the URL to the time specified by time . |
static boolean |
setReadOnly(java.net.URL url,
boolean readOnly)
Sets the read-only status of the resource indicated by the URL according to the specified readOnly
flag. |
static java.lang.String |
toDisplayString(java.net.URL url)
Returns a user-displayable form of the specified URL . |
static java.lang.String |
toEncodedString(java.net.URL url)
Returns a String representing the URL-encoded form of the specified URL . |
static java.lang.String |
toRelativeSpec(java.net.URL url,
java.net.URL base)
|
static java.lang.String |
toRelativeSpec(java.net.URL url,
java.net.URL base,
boolean mustConsumeBase)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void registerHelper(java.lang.String protocol, URLFileSystemHelper helper)
URLFileSystemHelper
as the object
that can handle URLFileSystem
operations for URL
s
of the specified protocol
.
If the protocol
is null
or the empty
string or if helper
is null
, this method
does nothing.
public static URLFileSystemHelper findHelper(java.lang.String protocol)
URLFileSystemHelper
class that is currently
registered to handle operations related to the specified
protocol
. If there is no registered helper, then a
default helper is returned that can produce a default result.
public static URLFileSystemHelper findHelper(java.net.URL url)
URLFileSystemHelper
class that is currently
registered to handle operations related to the specified
URL
. If there is no registered helper, then a default
helper is returned that can produce a default result.
public static void addExistsTest(URLExistsTest existsTest)
URLExistTest
interface.
The existsTest
object will be called by the
isBound()
method to determine if an URL
is unique.
public static java.net.URL canonicalize(java.net.URL url)
URL
, if one is available.
public static boolean canRead(java.net.URL url)
URL
.
true
if and only if the specified
URL
points to a resource that exists and can be
read by the application; false
otherwise.public static boolean canWrite(java.net.URL url)
URL
.
true
if and only if the specified
URL
points to a file that exists and the
application is allowed to write to the file; false
otherwise.public static boolean canCreate(java.net.URL url)
URL
. This method tests that all components of the path can
be created. If the resource pointed by the URL
is read-only,
this method returns false
.
true
if the resource at the specified URL
exists or can be created; false
otherwise.public static boolean isValid(java.net.URL url)
URL
is valid. If the resource
pointed by the URL
exists the method returns true
.
If the resource does not exist, the method tests that all components
of the path can be created.
true
if the URL
is valid.public static java.net.URL convertSuffix(java.net.URL url, java.lang.String oldSuffix, java.lang.String newSuffix)
URL
and checks if its Object.toString()
representation ends with the specified oldSuffix
. If
it does, the suffix is replaced with newSuffix
. Both
suffix parameters must include the leading dot ('.') if the dot is
part of the suffix. If the specified URL
does not end
with the oldSuffix
, then the newSuffix
is simply appended to the end of the original URL
.
public static void copy(java.net.URL src, java.net.URL dst) throws java.io.IOException
src
to dst
. If the
destination directory does not exist, it will be created.
IOException is throw if:
- failed to read the source contents
- failed to create destination directory
- failed to write source contents to the destination file
java.io.IOException
public static void copy(java.io.InputStream in, java.net.URL dst) throws java.io.IOException
in
to dst
.
java.io.IOException
public static void copy(java.net.URL src, java.io.File dst) throws java.io.IOException
src
to dst
.
java.io.IOException
public static boolean delete(java.net.URL url)
URL
. If
the content is a file (or analogous to a file), then the file is
removed from its directory (or container). If the content is a
directory (or analogous to a directory), then the directory is
removed only if it is empty (i.e. contains no other files or
directories).
true
if and only if the file or directory
is successfully deleted; false
otherwise.public static java.net.URL ensureSuffix(java.net.URL url, java.lang.String suffix)
URL
ends with the
specified suffix
. The suffix does not necessarily
have to start with a ".", so if a leading "." is required, the
specified suffix must contain it -- e.g. ".java", ".class".
If the URL
already ends in the specified suffix, then
the URL
itself is returned. Otherwise, a new
URL
is created with the the specified suffix appended
to the original URL
's path part, and the new URL
is returned.
URL
, based on the specified URL
, whose
path part ends with the specified suffix.
java.lang.NullPointerException
- if either the specified URL
or suffix
is null
. The caller is
responsible for checking that they are not null
.public static boolean equals(java.net.URL url1, java.net.URL url2)
true
if both of the specified URL
parameters point to the same URL
object or if the
both URL
parameters have the same protocol and the
protocol helper determines that the URL
objects are
equal.
public static boolean exists(java.net.URL url)
URL
location
currently exists. The test for existence only checks the actual
location and does not check any in-memory caches. To employ
additional existential tests that do check in-memory caches, see
isBound(URL)
.
true
if and only if a resource already exists
at the specified URL
location; false
otherwise.public static javax.swing.Icon getDefaultIcon(java.net.URL url)
Icon
that can be used to represent the
resource designated by the specified URL
.
getSystemIcon(URL)
public static java.lang.String getFileName(java.net.URL url)
URL
, not
including any protocol, hostname authentication, directory path,
anchor, or query. This simply returns the simple filename. For
example, if you pass in an URL
whose string representation
is:
protocol://host:1010/dir1/dir2/file.ext#anchor?query
the returned value is "file.ext
" (without the quotes).
URL
. This
value should only be used for display purposes and not for opening
streams or otherwise trying to locate the document.public static long getLength(java.net.URL url)
URL
.
URL
.public static java.lang.String getName(java.net.URL url)
public static java.net.URL getParent(java.net.URL url)
URL
representing the parent directory of
the specified URL
. If there is no parent directory,
then null
is returned.
public static java.lang.String getPath(java.net.URL url)
URL
. The returned string
is acceptable to use in one of the URLFactory
methods
that takes a path.
The default implementation delegates to URL.getPath()
.
public static java.lang.String getPathNoExt(java.net.URL url)
URL
without the last file
extension. To clarify, the following examples demonstrate the
different cases that come up:
URL |
String |
/dir/file.ext |
/dir/file |
/dir/file.ext1.ext2 |
/dir/file.ext1 |
/dir1.ext1/dir2.ext2/file.ext1.ext2 |
/dir1.ext1/dir2.ext2/file.ext1 |
/file.ext |
/file |
/dir.ext/file |
/dir.ext/file |
/dir/file |
/dir/file |
/file |
/file |
/.ext |
/ |
public static java.lang.String getPlatformPathName(java.net.URL url)
URL
; the returned string should be considered acceptable
for users to read. In general, the returned string should omit
as many parts of the URL
as possible. For the "file"
protocol, therefore, the platform pathname should just be the
pathname alone (no protocol) using the appropriate file separator
character for the current platform. For other protocols, it may
be necessary to reformat the URL
string into a more
human-readable form. That decision is left to each
URLFileSystemHelper
implementor.
URL
in
platform-dependent notation. This value should only be used for
display purposes and not for opening streams or otherwise trying
to locate the document.public static java.lang.String getSuffix(java.net.URL url)
URL
, then all of the text starting at the last dot is
returned, including the dot. If the last dot is also the last
character in the path, then the dot by itself is returned. If
there is no dot in the file name (even if a dot occurs elsewhere
in the path), then the empty string is returned.Examples:
public static javax.swing.Icon getSystemIcon(java.net.URL url)
Icon
used by the operating system to represent
the resource designated by the specified URL
; if an
Icon
cannot be obtained from the operating system, then
returns a standard Icon
representing a file or folder,
as appropriate.
getDefaultIcon(URL)
public static boolean hasSuffix(java.net.URL url, java.lang.String suffix)
true
if the path part of the URL
ends with the given suffix
String. The suffix can
be any String and doesn't necessarily have to be one that begins
with a dot ('.'). If you are trying to test whether the path
part of the URL
ends with a particular file extension,
then the suffix
parameter must begin with a '.'
character to ensure that you get the right return value.
public static boolean hasSuffix(java.net.URL url, java.lang.String[] suffixs)
true
if the path part of the URL
ends with any of the given suffixs
String. The suffixs can
be any String and doesn't necessarily have to be one that begins
with a dot ('.'). If you are trying to test whether the path
part of the URL
ends with a particular file extension,
then the suffixs
parameter must begin with a '.'
character to ensure that you get the right return value.
public static boolean isBaseURLFor(java.net.URL url1, java.net.URL url2)
true
if url1
represents a
a directory and url2
points to a location within
url1
's directory tree.
public static boolean isBound(java.net.URL url)
URL
is bound to
an existing resource, which may reside in memory (i.e. not yet
saved) or already exist at the URL
location. This is
similar to exists(URL)
but differs in that additional
tests are applied that check whether the URL
is bound
to an in-memory object before the actual URL
location is
checked.
More precisely, "bound" means either that an URL
is being
used in such a way that a registered URLExistsTest
is able
to detect the URL
's usage or that a document already
exists at the URL
location as determined by exists(URL)
).
Checking for uniqueness of a newly generated URL
is the
primary use for this method.
public static boolean isLocalFileSystemCaseSensitive()
true
if the local file system is case
sensitive. Returns false
if the local file system is
not case sensitive.
public static boolean isDirectory(java.net.URL url)
URL
is
a directory.
true
if and only if the location indicated
by the URL
exists and is a directory;
false
otherwise.public static boolean isDirectoryPath(java.net.URL url)
URL
represents a directory path. The directory path specified by
the URL
need not exist.
This method is intended to be a higher performance version of
the isDirectory(URL)
method. Implementations of this
method should attempt to ascertain whether the specified URL
represents a directory path by simply examining the URL
itself. Time consuming i/o operations should be
avoided.
true
if the location indicated by the
URL
represents a directory path; the directory path need
not exist.public static boolean isHidden(java.net.URL url)
URL
is a
hidden file. The exact definition of hidden is
protocol-dependent and possibly system-dependent. On UNIX
systems, a file is considered to be hidden if its name begins
with a period character ('.'). On Win32 systems, a file is
considered to be hidden if it has been marked as such in the
file system.
public static boolean isReadOnly(java.net.URL url)
true
if the resource pointed to by the
specified URL
is read-only; returns false
otherwise. If the read-only status cannot be determined for some
reason, this method returns true
.
true
if the document pointed to by the
specified URL
is read-only or if the read-only status
cannot be determined; false
otherwise.public static boolean isRegularFile(java.net.URL url)
URL
is
a regular file. A regular is a file that is not a
directory and, in addition, satisfies other system-dependent
criteria.
true
if and only if the resource
indicated by the URL
exists and is a normal
file.public static boolean isRoot(java.net.URL url)
true
if the specified URL
corresponds to a root file system; false
otherwise.
public static java.net.URL[] listRoots()
URL
s that represent the root file
systems that are currently available. The determination of the
roots is delegated to each registered URLFileSystemHelper
.
public static long lastModified(java.net.URL url)
URL
. The returned long
is the number of
milliseconds since the epoch (00:00:00 GMT Jan 1, 1970). If no
timestamp is available or if the URL
passed in is
null
, -1
is returned.
URL
.public static java.net.URL[] list(java.net.URL url)
URL
s naming files and directories in
the directory indicated by the URL
. If the specified
URL
does not represent a directory, then this method
returns null
. Otherwise, an array of URL
s
is returned, one for each file or directory in the directory.
URL
s representing the directory itself or its parent are
not included in the result. There is no guarantee that the
URL
s will occur in any particular order.
URL
s naming the files and directories
in the directory indicated by the URL
. The array will
be empty if the directory is empty. Returns null
if the URL
does not represent a directory or if an
I/O error occurs.public static java.net.URL[] list(java.net.URL url, URLFilter filter)
URL
s naming files and directories in
the directory indicated by the URL
; the specified
URLFilter
is applied to determine which URL
s will
be returned. If the specified URL
does not represent a
directory, then this method returns null
.
Otherwise, an array of URL
s is returned, one for each file
or directory in the directory that is accepted by the specified
filter. URL
s representing the directory itself or its
parent are not included in the result. There is no guarantee that
the URL
s will occur in any particular order.
If the specified URLFilter
is null
then
no filtering behavior is done.
URL
s naming the files and directories
in the directory indicated by the URL
that are accepted
by the specified URLFilter
. The array will be empty if
the directory is empty. Returns null
if the
URL
does not represent a directory or if an I/O error
occurs.public static URLFileSystem.FileInfo[] ls(java.net.URL url)
URLFileSystemHelper.ls(URL)
public static URLFileSystem.FileInfo[] ls(java.net.URL url, URLFilter filter)
URLFileSystemHelper.ls(URL, URLFilter)
public static boolean mkdir(java.net.URL url)
URL
.
true
if and only if the directory was
created; false
otherwise.public static boolean mkdirs(java.net.URL url)
URL
including any necessary but nonexistent parent directories. Note
that if this operation fails, it may have succeeded in creating
some of the necessary parent directories. This method returns
true
if the directory was created along with all
necessary parent directories or if the directories already
exist; it returns false
otherwise.
true
if all directories were created
successfully or exist; false
if there was a
failure somewhere.
Note that even if false
is returned, some directories
may still have been created.public static java.net.URL createTempFile(java.lang.String prefix, java.lang.String suffix, java.net.URL directory) throws java.io.IOException
prefix
- The prefix string to be used in generating the file's name;
must be at least three characters longsuffix
- The directory in which the file is to be created, or
null if the default temporary-file directory is to be useddirectory
- The directory in which the file is to be created,
or null if the default temporary-file directory is to be used
URL
to the temporary file.
java.io.IOException
public static java.io.InputStream openInputStream(java.net.URL url) throws java.io.IOException
InputStream
for the location indicated by the
specified URL
.
url
- An InputStream
is opened on the given
URL
. Depending on the protocol of the URL
, this
method may delegate to an URLFileSystemHelper
or attempt to
open the default InputStream
through the URL
's
associated URLConnection
.
InputStream
associated with the URL
.
java.io.FileNotFoundException
- if the resource at the
specified URL does not exist.
java.io.IOException
- if an I/O error occurs while creating
the input stream.
java.net.UnknownServiceException
- (a runtime exception) if
the associated URLConnection.getInputStream()
implementation does not support an InputStream
.public static java.io.OutputStream openOutputStream(java.net.URL url) throws java.io.IOException
OutputStream
for the location indicated by the
specified URL
.
url
- An OutputStream
is opened on the given
URL
. Depending on the protocol of the URL
, this
method may delegate to an URLFileSystemHelper
or attempt to
open the default OutputStream
through the URL
's
associated URLConnection
.
OutputStream
associated with the URL
.
java.io.IOException
- if an I/O error occurs while creating
the output stream.
java.net.UnknownServiceException
- (a runtime exception) if
the associated URLConnection.getOutputStream()
implementation does not support an OutputStream
.public static boolean renameTo(java.net.URL oldURL, java.net.URL newURL)
URL
to the
name indicated by the second URL
.
If either URL
parameter is null
or if both
of the specified URL
parameters refer to the same
resource, then the rename is not attempted and failure is
returned.
If the specified URL
parameters do not have the same
protocol, then the URLFileSystem
handles the rename
by first copying the resource to the destination with copy(URL, URL)
and then deleting the original
resource with delete(URL)
; if either
operation fails, then failure is returned.
Otherwise, the protocol helper is called to perform the actual
rename operation. Protocol helper implementations may therefore
assume that both URL
parameters are not
null
, do not refer to the same resource, and have
the same protocol.
If the original URL
refers to a nonexistent resource,
then the protocol helper implementations should return failure.
It is left up to the protocol helper implementations to decide
whether to overwrite the destination or return failure if the
destination URL
refers to an existing resource.
oldURL
- the URL
of the original resourcenewURL
- the desired URL
for the renamed resource
true
if and only if the resource is
successfully renamed; false
otherwise.public static boolean setLastModified(java.net.URL url, long time)
URL
to the time specified by time
.
The time is specified in the number of milliseconds since
the epoch (00:00:00 GMT Jan 1, 1970). The return value
indicates whether or not the setting of the timestamp
succeeded.
public static boolean setReadOnly(java.net.URL url, boolean readOnly)
URL
according to the specified readOnly
flag. The return value indicates whether or not the setting
of the read-only flag succeeded.
public static java.lang.String toDisplayString(java.net.URL url)
URL
.
public static java.lang.String toEncodedString(java.net.URL url)
URL
.
public static java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base)
URLFileSystemHelper.toRelativeSpec(URL, URL)
public static java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base, boolean mustConsumeBase)
URLFileSystemHelper.toRelativeSpec(URL, URL, boolean)
public static java.net.URL getBaseParent(java.net.URL url, java.lang.String relativeSpec)
URLFileSystemHelper.getBaseParent(URL, String)
|
Extension SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.