|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.ide.net.URLFileSystemHelper
public class URLFileSystemHelper
The URLFileSystemHelper
class specifies the URLFileSystem
operations that may have protocol-specific handling. By default, the URLFileSystem
delegates its operations to URLFileSystemHelper
. However, a subclass of URLFileSystemHelper
can be registered with the URLFileSystem
to handle the URLFileSystem
operations for a particular protocol. A helper class is registered through the URLFileSystem.registerHelper(String, URLFileSystemHelper)
method.
Special implementation note: classes that extend URLFileSystemHelper
must be completely thread-safe because a single instance of each registered helper is held by the URLFileSystem
and reused for all threads.
Note also that if you add a new method to this class you MUST provide an implementation in the IdeURLFileSystemHelper
. That helper cannot rely in a default implementation of the new method since it deals with special "ide" protocol based urls.
URLFileSystem
Constructor Summary | |
---|---|
protected |
URLFileSystemHelper() |
Method Summary | |
---|---|
void |
addURLFileSystemListener(java.net.URL rootURL, URLFileSystemListener listener) |
protected boolean |
appendRelativePath(java.net.URL url, java.net.URL base, java.lang.StringBuffer relativeURL, boolean mustConsumeBase) This is a helper for the toRelativeSpec(URL, URL) method, which uses the template method design pattern. |
protected boolean |
areEqual(java.lang.String s1, java.lang.String s2) |
protected boolean |
areEqualPathElems(java.lang.String urlElem, java.lang.String baseElem) This is a helper for the appendRelativePath(URL, URL, StringBuffer, boolean) method, which uses the template method design pattern. |
boolean |
canCreate(java.net.URL url) Tests whether the application can create the resource at the specified URL . |
boolean |
canDelete(java.net.URL url) Tests whether the application can delete the resource at the specified URL . |
java.net.URL |
canonicalize(java.net.URL url) Returns a canonical form of the URL , if one is available. |
boolean |
canRead(java.net.URL url) Tests whether the application can read the resource at the specified URL . |
boolean |
canWrite(java.net.URL url) Tests whether the application can modify the resource at the specified URL . |
protected int |
code(java.lang.Object object) |
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 . |
java.io.Reader |
createReader(java.net.URL url, java.lang.String encoding) Creates a Reader on the specified URL with the specified encoding. |
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. |
void |
delete(java.net.URL url) Deletes the content pointed to by the specified URL . |
java.net.URL |
ensureSuffix(java.net.URL url, java.lang.String suffix) This method ensures that the specified URL ends with the specified suffix . |
boolean |
equals(java.net.URL url1, java.net.URL url2) Compares the specified URL objects to determine whether they point to the same resource. |
boolean |
exists(java.net.URL url) Returns true if the specified URL points to a resource that currently exists; returns false otherwise. |
java.net.URL |
getBaseParent(java.net.URL url, java.lang.String relativeSpec) This method gets the base directory fully containing the relative path. |
javax.swing.Icon |
getDefaultIcon(java.net.URL url) Returns one of the built-in JFileChooser icons for a directory or file, depending on the type of resource represented by the URL . |
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. |
long |
getLength(java.net.URL url) Returns the number of bytes contained in the resource that the specified URL points to. |
java.lang.String |
getName(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. |
java.net.URL |
getParent(java.net.URL url) Returns the URL representing the parent directory of the specified URL . |
java.lang.String |
getPath(java.net.URL url) Returns the path part of the URL . |
java.lang.String |
getPathNoExt(java.net.URL url) Returns the path part of the URL without the last file extension. |
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. |
java.lang.String |
getSuffix(java.net.URL url) If a dot ('.') occurs in the path portion of the URL , then all of the text starting at the last dot is returned, including the dot. |
java.lang.String |
getSystemDisplayName(java.net.URL url) The default implementation maps to URLFileSystem.getFileName(URL) . |
javax.swing.Icon |
getSystemIcon(java.net.URL url) The default implementation returns the default icon obtained from URLFileSystem.getDefaultIcon(URL) . |
java.io.File |
getTempDirectory() Returns a temporal directory suitable for URLs handled by this helper. |
int |
hashCode(java.net.URL url) Computes a hash code for the specified URL object consistent with equals(java.net.URL, java.net.URL) . |
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. |
protected boolean |
haveSameAuthority(java.net.URL url, java.net.URL base) This is a helper for the toRelativeSpec(URL, URL) method, which uses the template method design pattern. |
protected boolean |
haveSameHost(java.net.URL url1, java.net.URL url2) |
protected boolean |
haveSamePath(java.net.URL url1, java.net.URL url2) |
protected boolean |
haveSamePort(java.net.URL url1, java.net.URL url2) |
protected boolean |
haveSameProtocol(java.net.URL url, java.net.URL base) This is a helper for the toRelativeSpec(URL, URL) method, which uses the template method design pattern. |
protected boolean |
haveSameQuery(java.net.URL url1, java.net.URL url2) |
protected boolean |
haveSameRef(java.net.URL url1, java.net.URL url2) |
protected boolean |
haveSameUserInfo(java.net.URL url1, java.net.URL url2) |
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. |
boolean |
isDirectory(java.net.URL url) Tests whether the location indicated by the URL is a directory. |
boolean |
isDirectoryPath(java.net.URL url) Tests whether the location indicated by the URL represents a directory path. |
boolean |
isHidden(java.net.URL url) Tests whether the resource indiciated by the URL is a hidden file. |
boolean |
isLocal(java.net.URL url) Determines whether the URL points to a resource on the local machine, or whether it requires network access. |
boolean |
isReadOnly(java.net.URL url) Returns true if the resource is read-only. |
boolean |
isRegularFile(java.net.URL url) Tests whether the resource indiciated by the URL is a regular file. |
boolean |
isValid(java.net.URL url) Tests whether the specified URL is valid. |
long |
lastModified(java.net.URL url) Returns the last modification time (timestamp) of the resource indicated by the specified URL in milliseconds since 00:00:00 GMT, Jan 1, 1970. |
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 . |
java.net.URL[] |
list(java.net.URL url, URLFilenameFilter filter) Returns an aray of URL s naming files and directories in the directory indicated by the URL . |
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. |
java.net.URL[] |
listRoots() Lists the root "file systems" that are supported by this helper. |
URLFileSystem.FileInfo[] |
ls(java.net.URL url) Returns an array of URLFileSystem.FileInfo objects describing files and directories in the directory indicated by the URL . |
URLFileSystem.FileInfo[] |
ls(java.net.URL url, URLFilter filter) Returns an array of URLFileSystem.FileInfo objects describing files and directories in the directory indicated by the URL that satisfy the specified URLFilter . |
URLFileSystem.FileInfo[] |
lsCached(java.net.URL url) |
URLFileSystem.FileInfo[] |
lsCached(java.net.URL url, URLFilter filter) |
boolean |
mkdir(java.net.URL url) Creates the directory indicated by the URL . |
boolean |
mkdirs(java.net.URL url) Creates the directory indicated by the specified URL including any necessary but nonexistent parent directories. |
java.io.InputStream |
openInputStream(java.net.URL url) Opens an InputStream on the specified URL . |
java.io.OutputStream |
openOutputStream(java.net.URL url) Opens an OutputStream on the URL . |
void |
removeURLFileSystemListener(java.net.URL rootURL, URLFileSystemListener listener) |
void |
rename(java.net.URL oldURL, java.net.URL newURL) Renames the resource indicated by the first URL to the name indicated by the second URL . |
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 . |
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. |
java.lang.String |
toDisplayString(java.net.URL url) Returns a displayable form of the complete URL . |
java.lang.String |
toEncodedString(java.net.URL url) |
java.lang.String |
toEncodedString(java.net.URL url, java.lang.String encoding) |
java.lang.String |
toRelativeSpec(java.net.URL url, java.net.URL base) This method attempts all possible ways of deriving a relative URI reference as described in RFC 2396 using the url parameter as the URL whose relative URI reference is to be determined and the base parameter as the URL that serves as the base document for the url pararmeter. |
java.lang.String |
toRelativeSpec(java.net.URL url, java.net.URL base, boolean mustConsumeBase) Variant of toRelativeSpec(URL, URL) that has a flag that indicates whether the base URL should be fully consumed in the process of calculating the relative spec. |
void |
verifyList(java.net.URL url) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected URLFileSystemHelper()
Method Detail |
---|
public java.net.URL canonicalize(java.net.URL url)
URL
, if one is available.
The default implementation just returns the specified URL
as-is.
public 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 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 boolean canCreate(java.net.URL url)
URL
.true
if the resource at the specified URL
exists or can be created; false
otherwise.public boolean canDelete(java.net.URL url)
URL
.true
if the resource at the specified URL
can be deleted.URLFileSystem.canDelete(URL)
public 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 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 void delete(java.net.URL url) throws java.io.IOException
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).
The default implementation does nothing.
java.io.IOException
- if an I/O exception occurred when trying to delete the URL.public 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.
The default implementation first checks with hasSuffix(URL, String)
to see if the URL
already ends with the specified suffix. If not, the suffix is simply appended to the path part of the URL
, 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 boolean equals(java.net.URL url1, java.net.URL url2)
URL
objects to determine whether they point to the same resource. This method returns true
if the URL
s point to the same resource and returns false
if the URL
s do not point to the same resource.
This method and all subclass implementations can assume that both URL
parameters are not null
. The URLFileSystem.equals(URL, URL)
method is responsible for checking that the two URL
s are not null
.
It can also be assumed that both URL
parameters have the same protocol and that the protocol is appropriate for this URLFileSystemHelper
. This determination is also the responsibility of URLFileSystem.equals(URL, URL)
.
The default implementation for this method checks to see if the various parts of the URLs are equal. Unlike URL.equals(java.lang.Object)
, the host names are not resolved to InetAddresses.
public int hashCode(java.net.URL url)
URL
object consistent with equals(java.net.URL, java.net.URL)
. This method and all subclass implementations can assume that the URL
parameter is not null
. The URLFileSystem.hashCode(URL)
method is responsible for ensuring this condition.
It can also be assumed that the protocol is appropriate for this URLFileSystemHelper
. The URLFileSystem.hashCode(URL)
method is also responsible for ensuring this condition and for incorporating the protocol into the hash code.
The default implementation for this method computes the hash code from the hash codes of the various parts of the URLs are equal. Unlike URL.equals(java.lang.Object)
, the host names is not resolved to an InetAddress.
protected int code(java.lang.Object object)
public boolean exists(java.net.URL url)
true
if the specified URL
points to a resource that currently exists; returns false
otherwise.
The default implementation simply returns false
without doing anything.
public javax.swing.Icon getDefaultIcon(java.net.URL url)
JFileChooser
icons for a directory or file, depending on the type of resource represented by the URL
.getSystemIcon(URL)
public 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).
The returned file name should only be used for display purposes and not for opening streams or otherwise trying to locate the resource indicated by the URL
.
public long getLength(java.net.URL url)
URL
points to. If the length cannot be determined, -1
is returned.
The default implementation attempts to get the content length from the URLConnection
associated with the URL
. If that fails for some reason (e.g. the resource does not exist, there was some other an I/O exception, etc.), -1
is returned.
URLConnection
public java.lang.String getName(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.ext1.ext2#anchor?query
the returned value is "file.ext1
" (without the quotes).
The returned file name should only be used for display purposes and not for opening streams or otherwise trying to locate the resource indicated by the URL
.
The default implementation first calls getFileName(URL)
to get the file name part. Then all characters starting with the last occurrence of '.' are removed. The remaining string is then returned.
Note: The implementation of this method changed in the 11.1.1 release of the platform to trim the filename on the last '.'. In previous releases of the platform, it would trim the filename on the first '.'.
public 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.
The default implementation returns the value of invoking URLFactory.newURL( url, ".." )
, removing the reference portion of the URL.
public 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 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 |
/ |
getPath(URL)
and then trims off all of the characters beginning with the last "." in the path, if and only if the last "." comes after the last "/" in the path. If the last "." comes before the last "/" or if there is no "." at all, then the entire path is returned.public 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. The default implementation returns url.toString()
. If the URL
is null
, the empty string is returned.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 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 path, then the empty string is returned.public java.lang.String getSystemDisplayName(java.net.URL url)
URLFileSystem.getFileName(URL)
.public javax.swing.Icon getSystemIcon(java.net.URL url)
URLFileSystem.getDefaultIcon(URL)
.getDefaultIcon(URL)
public 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 should begin with a '.' character to ensure that you get the right return value.public 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 boolean isDirectory(java.net.URL url)
URL
is a directory.
The default implementation always returns false
.
true
if and only if the location indicated by the URL
exists and is a directory; false
otherwise.public 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.
The default implementation returns true
if the path part of the URL
ends with a '/' and the query and ref parts of the URL
are null.
true
if the location indicated by the URL
represents a directory path; the directory path need not exist.public 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.
The default implementation always returns false
.
public boolean isReadOnly(java.net.URL url)
true
if the resource is read-only. A return value of false
means that trying to get an OutputStream
or trying to write to an OutputStream
based on the URL
will cause an exception to be thrown.
The default implementation always returns true
. This means that all resources are considered read-only unless a protocol-specific URLFileSystemHelper
is registered for the specified URL
and is able to determine that the resource underlying the specified URL
is not read-only.
public 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.
The default implementation returns the value of exists( url ) && !isDirectory( url )
.
true
if and only if the resource indicated by the URL
exists and is a normal file.public boolean isLocal(java.net.URL url)
URL
points to a resource on the local machine, or whether it requires network access.url
- the URLtrue
if the URL
is local, false
if it requires network accesspublic long lastModified(java.net.URL url)
URL
in milliseconds since 00:00:00 GMT, Jan 1, 1970. If the timestamp can't be determined, -1
is returned.
The default implementation attemps to get the last modified time from the URLConnection
associated with the URL
. If that fails for some reason (e.g. the resource does not exist, there was some other I/O exception, etc.), -1
is returned.
URLConnection
public 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.
The default implementation always returns an empty URL
array.
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 void verifyList(java.net.URL url) throws java.io.IOException
java.io.IOException
public 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.
The default implementation calls list(URL)
first and then applies the URLFilter
to the resulting list.
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 java.net.URL[] list(java.net.URL url, URLFilenameFilter filter)
URL
s naming files and directories in the directory indicated by the URL
. The specified URLFilenameFilter
is applied to determine which URL
s will be returned.
This method has better performance characteristics for some protocols than list(URL,URLFilter)
if you are able to filter out URLs based only on their name, because helpers may be able to avoid IO on children of the directory url.
This implementation wraps the URLFilenameFilter
in a URLFilter
and calls list(URL,URLFilter)
. It is expected that subclasses override this and provide a more performant implementation specific to the protocol.
url
- a directory URL to list. Must be a directory URL, and must not be null.filter
- a filter implementation. May be null, in which case this method behaves exactly like list(URL)
.URL
s naming the files and directories in the directory indicated by the URL
that are accepted by the specified URLFilenameFilter
. The array will be empty if the directory is empty. Returns null if an IO error occurs.public java.net.URL[] listRoots()
URLChooser
to list all of the roots that are available for the user to browse. If no root file systems are supported, this method must return null
or an empty URL array. If the returned array is not empty, then each URL contained in it must represent a directory and must not be null.
The default implementation always returns null
.
public URLFileSystem.FileInfo[] ls(java.net.URL url)
URLFileSystem.FileInfo
objects describing 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 URLFileSystem.FileInfo
objects is returned, one for each file or directory in the directory. URLFilesystem.FileInfo
objects representing the directory itself or its parent are not included in the result.
There is no guarantee that the URLFileSystem.FileInfo
objects will be returned in any specific order; in particular, they are not guaranteed to be returned in alphabetical order.
The default implementation calls ls(URL, null)
.
URLFileSystem.FileInfo
objects describing 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 URLFileSystem.FileInfo[] lsCached(java.net.URL url)
public URLFileSystem.FileInfo[] ls(java.net.URL url, URLFilter filter)
URLFileSystem.FileInfo
objects describing files and directories in the directory indicated by the URL
that satisfy the specified URLFilter
.
The behavior of this method is the same as ls(URL)
, except that the URL
s indicated by the returned array must satisfy the filter. If the given filter is null
, then all URL
s are accepted. Otherwise, an URL
satisfies the filter if and only if the value of true
results when the URLFilter.accept(URL)
method of the filter is invoked on the URL
of a file or directory in the directory that it denotes.
The default implementation calls URLFileSystem.list(URL, URLFilter)
and builds the URLFileSystem.FileInfo
objects from the returned URL
s.
URLFileSystem.FileInfo
objects describing 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 URLFileSystem.FileInfo[] lsCached(java.net.URL url, URLFilter filter)
public boolean mkdir(java.net.URL url)
URL
.
The default implementation always returns false
.
true
if and only if the directory was created; false
otherwise.public 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 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 usedURL
to the temporary file.java.io.IOException
public java.io.InputStream openInputStream(java.net.URL url) throws java.io.IOException
InputStream
on the specified URL
.
The default implementation attempts to open the InputStream
through the URLConnection
associated with the URL
. If the URLConnection
implementation does not support an InputStream
then an UnknownServiceException
(a runtime exception) will be thrown.
java.io.FileNotFoundException
- if the resource at the specified URL does not exist.java.io.IOException
- if an I/O error occurs when trying to open the InputStream
.java.net.UnknownServiceException
- if the URLConnection
backing the specified URL
does not support an InputStream
.IOException
, URLConnection
, UnknownServiceException
public java.io.OutputStream openOutputStream(java.net.URL url) throws java.io.IOException
OutputStream
on the URL
. If the file does not exist, the file should be created. If the directory path to the file does not exist, all necessary directories should be created.
The default implementation attempts to open the OutputStream
through the URLConnection
associated with the URL
. If the URLConnection
implementation does not support an OutputStream
then an UnknownServiceException
(a runtime exception) will be thrown.
java.io.IOException
- if an I/O error occurs when trying to open the OutputStream
.java.net.UnknownServiceException
- if the URLConnection
backing the specified URL
does not support an OutputStream
.IOException
, URLConnection
, UnknownServiceException
public void rename(java.net.URL oldURL, java.net.URL newURL) throws java.io.IOException
URL
to the name indicated by the second URL
.
The default implementation does nothing.
java.io.IOException
- if an I/O exception occurs while renaming the URL.URLFileSystem.renameTo(URL, URL)
, URLFileSystem.renameEx(URL, URL)
public 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.
The default implementation always returns false
without doing anything.
public 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.
The default implementation always returns false
without doing anything.
public java.lang.String toDisplayString(java.net.URL url)
URL
.
The default implementation delegates to URL.toString()
.
public java.lang.String toEncodedString(java.net.URL url)
public java.lang.String toEncodedString(java.net.URL url, java.lang.String encoding)
public java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base)
url
parameter as the URL
whose relative URI reference is to be determined and the base
parameter as the URL
that serves as the base document for the url
pararmeter. If it is not possible to produce a relative URI reference because the two URL
s are too different, then a full, absolute reference for the url
parameter is returned.
Whatever value is returned by this method, it can be used in conjunction with the base
URL
to reconstruct the fully-qualified URL
by using one of the URL
constructors that takes a context URL
plus a String
spec (i.e. the String
returned by this method).
Both the url
and base
parameters should point to documents and be absolute URL
s. Specifically, the base
parameter does not need to be modified to represent the base directory if the base
parameter already points to a document that is in the directory to which the url
parameter will be made relative. This relationship between url
and base
is exactly how relative references are treated within HTML documents. Relative references in an HTML page are resolved against the HTML page's base URL. The base URL is the HTML page itself, not the directory that contains it.
If either the url
or base
parameter needs to represent a directory rather than a file, they must end with a "/" in the path part of the URL
, such as:
http://host.com/root/my_directory/
The algorithm used by this method to determine the relative reference closely follows the recommendations made in RFC 2396. The following steps are performed, in order, to determine the relative reference:
File
so that, for example, on Win32 the comparison is case-insensitive, whereas on Unix the comparison is case-sensitive. When the protocol is not "file", comparison is always case-sensitive. (This distinction is made by FileURLFileSystemHelper
, which overrides the relevant part of the algorithm.)URL
(except for the document name itself), then a "../" sequence is prepended to the resulting relative path for each base path element that was not consumed while matching path elements.url
were consumed, then those path elements are appended to the resulting relative path as well. If the first remaining path element in url
contains a ':' character and there is no "../" sequence was prepended to the relative reference, then a "./" sequence is prepended to prevent the ':' character from being interpreted as a protocol delimiter (this is a special case in RFC 2396).url
are not appended.
This method is implemented using the template method design pattern, so it is possible for subclasses to override just part of the algorithm in order to handle protocol-specific details.
public java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base, boolean mustConsumeBase)
toRelativeSpec(URL, URL)
that has a flag that indicates whether the base URL
should be fully consumed in the process of calculating the relative spec.
If mustConsumeBase
is true
, then this method will return a non-null
relative spec if and only if the base URL
was fully consumed in the process of calculating the relative spec. Otherwise, if any part of the base URL
remained, then this method returns null
.
If mustConsumeBase
is false
, then this method will return a non-null
relative spec regardless of how much of the base URL
is consumed during the determination.
public java.net.URL getBaseParent(java.net.URL url, java.lang.String relativeSpec)
url
should be absolute and point to a directory. It must end with a "/" in the path part of the URL
, such as:
http://host.com/root/my_directory/
If the url
does not end with a "/", it will be assumed that the url
points to a document. The document name will then be stripped in order to determine the parent directory. The relativeSpec
parameter should be a relative path. If the relativeSpec
does not end with a "/", it will be assumed that the relativeSpec
points to a document. The document name will then be stripped in order to determine the parent directory. For example, if the url
points to:
file://c:/root/dir1/dir2/dir3/
and the relativeSpec
is:
dir2/dir3
The returned value would be:
file://c:/root/dir1/
If the relativeSpec
path elements are not fully contained in the last part of the url
path the value returned is the url itself if the url path ends with a "/" or the url parent otherwise.public java.io.Reader createReader(java.net.URL url, java.lang.String encoding) throws java.io.IOException
Reader
on the specified URL
with the specified encoding.
The default implementation opens the InputStream
and then creates an InputStreamReader
.
java.io.IOException
- if an I/O error occurs when trying to open the InputStream
.java.net.UnknownServiceException
- if the URLConnection
backing the specified URL
does not support an InputStream
.InputStreamReader
, IOException
, URLConnection
, UnknownServiceException
public void addURLFileSystemListener(java.net.URL rootURL, URLFileSystemListener listener)
public void removeURLFileSystemListener(java.net.URL rootURL, URLFileSystemListener listener)
public java.io.File getTempDirectory()
protected boolean haveSameUserInfo(java.net.URL url1, java.net.URL url2)
protected boolean haveSameHost(java.net.URL url1, java.net.URL url2)
protected boolean haveSamePath(java.net.URL url1, java.net.URL url2)
protected boolean haveSameQuery(java.net.URL url1, java.net.URL url2)
protected boolean haveSameRef(java.net.URL url1, java.net.URL url2)
protected boolean haveSamePort(java.net.URL url1, java.net.URL url2)
protected final boolean areEqual(java.lang.String s1, java.lang.String s2)
protected boolean haveSameProtocol(java.net.URL url, java.net.URL base)
toRelativeSpec(URL, URL)
method, which uses the template method design pattern.
By default, the url
and base
parameters must have identical protocols as a prerequisite to being able to produce a relative URL
spec.
protected boolean haveSameAuthority(java.net.URL url, java.net.URL base)
toRelativeSpec(URL, URL)
method, which uses the template method design pattern.
The "authority" part is a combination of the user info, hostname, and port number. The full syntax in the URL
string is:
userinfo@hostname:port
It may appear in an URL
such as:
ftp://jdijamco@javatools-dev:21/jtinteg/JDev50.zip
The authority part may be null
, if the URL
scheme does not require one.
By default, the url
and base
parameters must have identical authority strings as a prerequisite to being able to produce a relative URL
spec.
protected boolean appendRelativePath(java.net.URL url, java.net.URL base, java.lang.StringBuffer relativeURL, boolean mustConsumeBase)
toRelativeSpec(URL, URL)
method, which uses the template method design pattern.true
if the entire base URL
was consumed in the process of determining the relative path; false
otherwise (i.e. not all of the base URL
was consumed).protected boolean areEqualPathElems(java.lang.String urlElem, java.lang.String baseElem)
appendRelativePath(URL, URL, StringBuffer, boolean)
method, which uses the template method design pattern.
The two String
s that are passed in represent elements of the path parts of the url
and base
parameters that are passed into appendRelativePath(URL, URL, StringBuffer, boolean)
.
By default, path elements are compared exactly in a case-sensitive manner using regular String
comparison.
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.7.2) E13403-10 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |