Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


oracle.ide.net
Class JarURLFileSystemHelper

java.lang.Object
  extended by oracle.ide.net.URLFileSystemHelper
      extended by oracle.ide.net.JarURLFileSystemHelper


public class JarURLFileSystemHelper
extends URLFileSystemHelper

This class handles the URLFileSystem operations associated with the "jar" protocol.


Constructor Summary
JarURLFileSystemHelper()
           

 

Method Summary
 boolean canCreate(java.net.URL url)
          Tests whether the application can create 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.
 boolean exists(java.net.URL url)
          Returns true if the specified URL points to a resource that currently exists; returns false otherwise.
 javax.swing.Icon getDefaultIcon(java.net.URL url)
          If this URL represents the root directory entry of a jar file, then returns a standard archive folder Icon; otherwise, returns the built-in icons for a file or directory.
 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.net.URL getParent(java.net.URL url)
          Since jar URLs are compound, when you reach the root of the jar entry, you get a jar URL with an empty entry name.
 java.lang.String getPlatformPathName(java.net.URL url)
          If this jar URL does not include a JarEntry bit, then we can just return the platform path name for the jar file's URL.
 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)
          If the specified URL points to just the jar file and not to any particular entry within it, then this method will return true if the jar file exists.
 boolean isLocal(java.net.URL url)
          Determines whether the URL points to a resource on the local machine, or whether it requires network access.
 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 URLs naming files and directories in the directory indicated by the URL.
 java.io.InputStream openInputStream(java.net.URL url)
          Overrides default implemention to provide a more optimized way way of obtaining an input stream for a jar entry.
 void rename(java.net.URL oldURL, java.net.URL newURL)
          If both of the specified URL objects refer to just a jar file and not a particular entry within it, then the jar file itself is renamed.
 java.lang.String toRelativeSpec(java.net.URL url, java.net.URL base)
          For the time being, there is no supported syntax for a relative URL reference for a "jar" URL.

 

Methods inherited from class oracle.ide.net.URLFileSystemHelper
addURLFileSystemListener, appendRelativePath, areEqual, areEqualPathElems, canDelete, code, convertSuffix, createReader, createTempFile, delete, ensureSuffix, equals, getBaseParent, getName, getPath, getPathNoExt, getPort, getSuffix, getSystemDisplayName, getSystemIcon, getTempDirectory, hashCode, hasSuffix, haveSameAuthority, haveSameHost, haveSamePath, haveSamePort, haveSameProtocol, haveSameQuery, haveSameRef, haveSameUserInfo, isDirectoryPath, isHidden, isReadOnly, isRegularFile, isValid, list, list, listRoots, ls, ls, lsCached, lsCached, mkdir, mkdirs, openOutputStream, removeURLFileSystemListener, setLastModified, setReadOnly, toDisplayString, toEncodedString, toEncodedString, toRelativeSpec, verifyList

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

JarURLFileSystemHelper

public JarURLFileSystemHelper()

Method Detail

isBaseURLFor

public boolean isBaseURLFor(java.net.URL url1,
                            java.net.URL url2)
Description copied from class: URLFileSystemHelper
Returns true if url1 represents a a directory and url2 points to a location within url1's directory tree.
Overrides:
isBaseURLFor in class URLFileSystemHelper

canonicalize

public java.net.URL canonicalize(java.net.URL url)
Description copied from class: URLFileSystemHelper
Returns a canonical form of the URL, if one is available.

The default implementation just returns the specified URL as-is.

Overrides:
canonicalize in class URLFileSystemHelper

canRead

public boolean canRead(java.net.URL url)
Description copied from class: URLFileSystemHelper
Tests whether the application can read the resource at the specified URL.
Overrides:
canRead in class URLFileSystemHelper
Returns:
true if and only if the specified URL points to a resource that exists and can be read by the application; false otherwise.

canWrite

public boolean canWrite(java.net.URL url)
Description copied from class: URLFileSystemHelper
Tests whether the application can modify the resource at the specified URL.
Overrides:
canWrite in class URLFileSystemHelper
Returns:
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.

canCreate

public boolean canCreate(java.net.URL url)
Description copied from class: URLFileSystemHelper
Tests whether the application can create the resource at the specified URL.
Overrides:
canCreate in class URLFileSystemHelper
Returns:
true if the resource at the specified URL exists or can be created; false otherwise.

exists

public boolean exists(java.net.URL url)
Description copied from class: URLFileSystemHelper
Returns true if the specified URL points to a resource that currently exists; returns false otherwise.

The default implementation simply returns false without doing anything.

Overrides:
exists in class URLFileSystemHelper

getDefaultIcon

public javax.swing.Icon getDefaultIcon(java.net.URL url)
If this URL represents the root directory entry of a jar file, then returns a standard archive folder Icon; otherwise, returns the built-in icons for a file or directory.
Overrides:
getDefaultIcon in class URLFileSystemHelper
See Also:
URLFileSystemHelper.getSystemIcon(URL)

getFileName

public java.lang.String getFileName(java.net.URL url)
Description copied from class: URLFileSystemHelper
Returns the name of the file contained by the 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.

Overrides:
getFileName in class URLFileSystemHelper

getLength

public long getLength(java.net.URL url)
Description copied from class: URLFileSystemHelper
Returns the number of bytes contained in the resource that the specified 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.

Overrides:
getLength in class URLFileSystemHelper
See Also:
URLConnection

getParent

public java.net.URL getParent(java.net.URL url)
Since jar URLs are compound, when you reach the root of the jar entry, you get a jar URL with an empty entry name. If you then get the parent of that, you will get the parent directory of the jar file itself, and the returned URL will no longer have the "jar" protocol. For example, the following sequence of URL strings represents an iterative sequence of calls to getParent:
  1. jar:file:/C:/jre-lib/rt.jar!/java/lang/Object.class
  2. jar:file:/C:/jre-lib/rt.jar!/java/lang/
  3. jar:file:/C:/jre-lib/rt.jar!/java/
  4. jar:file:/C:/jre-lib/rt.jar!/
  5. file:/C:/jre-lib/
  6. file:/C:/
  7. null
Overrides:
getParent in class URLFileSystemHelper

getPlatformPathName

public java.lang.String getPlatformPathName(java.net.URL url)
If this jar URL does not include a JarEntry bit, then we can just return the platform path name for the jar file's URL. Otherwise return a synthetic platform path name composed of the jar file platform path name followed by the jar entry platform path name.
Overrides:
getPlatformPathName in class URLFileSystemHelper
Returns:
The path portion of the specified 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.

isDirectory

public boolean isDirectory(java.net.URL url)
If the specified URL points to just the jar file and not to any particular entry within it, then this method will return true if the jar file exists.
Overrides:
isDirectory in class URLFileSystemHelper
Returns:
true if and only if the location indicated by the URL exists and is a directory; false otherwise.

isLocal

public boolean isLocal(java.net.URL url)
Description copied from class: URLFileSystemHelper
Determines whether the URL points to a resource on the local machine, or whether it requires network access.
Overrides:
isLocal in class URLFileSystemHelper
Parameters:
url - the URL
Returns:
true if the URL is local, false if it requires network access

lastModified

public long lastModified(java.net.URL url)
Description copied from class: URLFileSystemHelper
Returns the last modification time (timestamp) of the resource indicated by the specified 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.

Overrides:
lastModified in class URLFileSystemHelper
See Also:
URLConnection

list

public java.net.URL[] list(java.net.URL url)
Description copied from class: URLFileSystemHelper
Returns an array of URLs 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 URLs is returned, one for each file or directory in the directory. URLs representing the directory itself or its parent are not included in the result. There is no guarantee that the URLs will occur in any particular order.

The default implementation always returns an empty URL array.

Overrides:
list in class URLFileSystemHelper
Returns:
An array of URLs 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.

openInputStream

public java.io.InputStream openInputStream(java.net.URL url)
                                    throws java.io.IOException
Overrides default implemention to provide a more optimized way way of obtaining an input stream for a jar entry. This also allows the file handle for the jar file to be closed.
Overrides:
openInputStream in class URLFileSystemHelper
Returns:
an InputStream for the specified jar entry. If no such jar entry exists or if the URL points to the root of the JAR file, FileNotFoundException is thrown.
Throws:
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.
See Also:
IOException, URLConnection, UnknownServiceException

rename

public void rename(java.net.URL oldURL,
                   java.net.URL newURL)
            throws java.io.IOException
If both of the specified URL objects refer to just a jar file and not a particular entry within it, then the jar file itself is renamed. Otherwise, failure is returned, since we do not allow renaming an entry within a jar file.
Overrides:
rename in class URLFileSystemHelper
Throws:
java.io.IOException - if an I/O exception occurs while renaming the URL.
See Also:
URLFileSystem.renameTo(URL, URL), URLFileSystem.renameEx(URL, URL)

toRelativeSpec

public java.lang.String toRelativeSpec(java.net.URL url,
                                       java.net.URL base)
For the time being, there is no supported syntax for a relative URL reference for a "jar" URL. The reason for this is that the URL constructors that accept a context URL and a spec String do not handle "jar" URLs in the same way as other protocols. For example, "../" sequences are not resolved in the same way. Also relative "jar" references more than likely will need to be relative references to the jar file itself, rather than a relative reference to some path within the jar file, since everything in the jar file is already relative to the jar file.

However, relative references for a jar URL are supported in the limited circumstance that both URLs refer to entries within the same jar file and the base entry contains the target URL entry.

Overrides:
toRelativeSpec in class URLFileSystemHelper

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.3.0)

E17493-04


Copyright © 1997, 2012, Oracle. All rights reserved.