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

E17493-02

javax.ide.net
Class URIFactory

java.lang.Object
  extended by javax.ide.net.URIFactory

public final class URIFactory
extends java.lang.Object

This class contains methods which create new instances of URI. In order for URIs to be used effectively as keys in a hashtable, the URI must be created in a very consistent manner. Therefore, when creating a new instance of URI, it is strongly recommended that you use one of the methods in this class rather than calling the URI constructor directly. This will help prevent subtle bugs that can come up when two URI instances that should be equal aren't equal (resulting in caching bugs) because of a difference in some detail of the URI that affects the result of the Object.equals(Object) method but doesn't affect the location pointed to by the URI (which means that code other than the caching will actually continue to work).

Additionally, by using the methods in this class to create instances of URI, dependencies on URI can be tracked more easily.


Nested Class Summary
static interface URIFactory.NameGenerator
          This is a callback interface used by the URIFactory while it is in the process of producing a new unique URI.
 
Field Summary
static java.lang.String JAR_URI_SEPARATOR
           
 
Method Summary
static boolean isArchive(java.lang.String pathname)
          Determine if a given URL represents an jar or zip file.
static boolean isJarURI(java.net.URI jarURI)
          Returns true if the specified URI has the "jar" scheme.
static java.net.URI newDirURI(java.io.File dir)
          Creates a new URI with the "file" scheme that is for the specified directory.
static java.net.URI newDirURI(java.lang.String dirPath)
          Creates a new URI with the "file" scheme that is for the specified directory.
static java.net.URI newDirURI(java.lang.String scheme, java.lang.String dirPath)
          Creates a new URI that is the combination of the specified scheme and the directory path.
static java.net.URI newDirURI(java.net.URI baseURI, java.lang.String relativeSpec)
          Creates a new URI that is the combination of the specified base URI and the relative spec string.
static java.net.URI newFileURI(java.io.File file)
          This method converts a File instance into an URI instance using an algorithm that is consistent with the other factory methods in URIFactory.
static java.net.URI newFileURI(java.lang.String filePath)
          Creates a new URI using the "file" scheme.
static java.net.URI newJarURI(java.io.File archiveFile, java.lang.String entryName)
          Builds an URI using the "jar" scheme based on the specified archive File and the entry name passed in.
static java.net.URI newJarURI(java.net.URI archiveURI, java.lang.String entryName)
          Builds an URI using the "jar" scheme based on the specified archive URI and the entry name passed in.
static java.net.URI newUniqueURI(java.net.URI baseURI, URIFactory.NameGenerator nameGen)
          Creates a new unique URI using the scheme of the specified baseURI.
static java.net.URI newURI(java.lang.String uriSpec)
           
static java.net.URI newURI(java.lang.String scheme, java.lang.String path)
          Standard way of specifying a scheme with a file path.
static java.net.URI newURI(java.lang.String scheme, java.lang.String userinfo, java.lang.String host, int port, java.lang.String path, java.lang.String query, java.lang.String fragment)
          Creates a new URI whose parts have the exact values that are specified.
static java.net.URI newURI(java.net.URI baseURI, java.lang.String relativeSpec)
          Creates a new URI that is the combination of the specified base URI and the relative spec string.
static java.net.URI newURI(java.net.URL url)
          Creates a new URI form an URL.
static java.net.URI replaceFragmentPart(java.net.URI uri, java.lang.String newFragment)
          Returns a new URI that is identical to the specified URI except that the fragment part of the URI has been replaced with the specified newRef.
static java.net.URI replaceHostPart(java.net.URI uri, java.lang.String newHost)
          Returns a new URI that is identical to the specified URI except that the host part of the URI has been replaced with the specified newHost.
static java.net.URI replacePathPart(java.net.URI uri, java.lang.String newPath)
          Returns a new URI that is identical to the specified URI except that the path part of URI has been replaced with the specified newPath.
static java.net.URI replacePortPart(java.net.URI uri, int newPort)
          Returns a new URI that is identical to the specified URI except that the port part of the URI has been replaced with the specified newPort.
static java.net.URI replaceQueryPart(java.net.URI uri, java.lang.String newQuery)
          Returns a new URI that is identical to the specified URI except that the query part of the URI has been replaced with the specified newQuery.
static java.net.URI replaceSchemePart(java.net.URI uri, java.lang.String newScheme)
          Returns a new URI that is identical to the specified URI except that the scheme part of the URI has been replaced with the specified newscheme.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAR_URI_SEPARATOR

public static final java.lang.String JAR_URI_SEPARATOR
See Also:
Constant Field Values
Method Detail

newURI

public static java.net.URI newURI(java.net.URI baseURI,
                                  java.lang.String relativeSpec)
Creates a new URI that is the combination of the specified base URI and the relative spec string. The base URI is treated as a directory, whether or not the URI ends with the "/" character, and the relative spec is always treated as relative, even if it begins with a "/".

Non-sanitizing.


newDirURI

public static java.net.URI newDirURI(java.net.URI baseURI,
                                     java.lang.String relativeSpec)
Creates a new URI that is the combination of the specified base URI and the relative spec string. The base URI is treated as a directory whether or not it ends with the "/" character. The returned URI will return with the "/" character in the path part.

Non-sanitizing.


newURI

public static java.net.URI newURI(java.lang.String scheme,
                                  java.lang.String path)
Standard way of specifying a scheme with a file path. The file path is used in the URI verbatim, without any changes to the file separator character or any other characters. For an URI whose scheme is "file", the newFileURI(String) factory method should be used instead.

Non-sanitizing.


newDirURI

public static java.net.URI newDirURI(java.lang.String scheme,
                                     java.lang.String dirPath)
Creates a new URI that is the combination of the specified scheme and the directory path. The directory path is used in the URI verbatim, without any changes to the file separator character or any other characters. The returned URI will return with the "/" character in the path part.

Non-sanitizing.


newUniqueURI

public static java.net.URI newUniqueURI(java.net.URI baseURI,
                                        URIFactory.NameGenerator nameGen)
Creates a new unique URI using the scheme of the specified baseURI. The nameGen object is called to generate a unique name that will be appended to the base uri. Non-sanitizing.


replaceSchemePart

public static java.net.URI replaceSchemePart(java.net.URI uri,
                                             java.lang.String newScheme)
Returns a new URI that is identical to the specified URI except that the scheme part of the URI has been replaced with the specified newscheme.

Non-sanitizing.


replacePortPart

public static java.net.URI replacePortPart(java.net.URI uri,
                                           int newPort)
Returns a new URI that is identical to the specified URI except that the port part of the URI has been replaced with the specified newPort.

Non-sanitizing.


replaceHostPart

public static java.net.URI replaceHostPart(java.net.URI uri,
                                           java.lang.String newHost)
Returns a new URI that is identical to the specified URI except that the host part of the URI has been replaced with the specified newHost.

Non-sanitizing.


replacePathPart

public static java.net.URI replacePathPart(java.net.URI uri,
                                           java.lang.String newPath)
Returns a new URI that is identical to the specified URI except that the path part of URI has been replaced with the specified newPath.

Non-sanitizing.


replaceFragmentPart

public static java.net.URI replaceFragmentPart(java.net.URI uri,
                                               java.lang.String newFragment)
Returns a new URI that is identical to the specified URI except that the fragment part of the URI has been replaced with the specified newRef.

Non-sanitizing.


replaceQueryPart

public static java.net.URI replaceQueryPart(java.net.URI uri,
                                            java.lang.String newQuery)
Returns a new URI that is identical to the specified URI except that the query part of the URI has been replaced with the specified newQuery.

Non-sanitizing.


newURI

public static java.net.URI newURI(java.lang.String uriSpec)

newFileURI

public static java.net.URI newFileURI(java.lang.String filePath)
Creates a new URI using the "file" scheme. The specified filePath can be expressed in the notation of the platform that the Java VM is currently running on, or it can be expressed using the forward slash character ("/") as its file separator character, which is the standard file separator for URIs. Note that technically, the forward slash character is the only officially recognized hierarchy separator character for an URI. Sanitizing.


newFileURI

public static java.net.URI newFileURI(java.io.File file)
This method converts a File instance into an URI instance using an algorithm that is consistent with the other factory methods in URIFactory.

Sanitizing.

Returns:
An URI corresponding to the given File. The URI is produced using a mechanism that ensures uniformity of the URI format across platforms.

newDirURI

public static java.net.URI newDirURI(java.lang.String dirPath)
Creates a new URI with the "file" scheme that is for the specified directory. Leading and trailing "/" characters are added if they are missing. If the specified dirPath is null, then the returned URI is null.

Sanitizing.


newDirURI

public static java.net.URI newDirURI(java.io.File dir)
Creates a new URI with the "file" scheme that is for the specified directory. Leading and trailing "/" characters are added if they are missing. This method does not check whether the specified File is actually a directory on disk; it just assumes that it is. If the specified dirPath is null, then the returned URI is null.

Sanitizing.


newJarURI

public static java.net.URI newJarURI(java.io.File archiveFile,
                                     java.lang.String entryName)
Builds an URI using the "jar" scheme based on the specified archive File and the entry name passed in. The entry name is relative to the root of the jar file, so it should not begin with a slash. The entry name may be the empty string or null, which means that the returned URI should represent the jar file itself. Sanitizing for archiveFile; non-sanitizing for entryName.


isJarURI

public static boolean isJarURI(java.net.URI jarURI)
Returns true if the specified URI has the "jar" scheme. Returns false if the specified URI is null or has a scheme other than "jar".


isArchive

public static boolean isArchive(java.lang.String pathname)
Determine if a given URL represents an jar or zip file. The method does a simple check to determine if the pathname ends with .jar or .zip.


newJarURI

public static java.net.URI newJarURI(java.net.URI archiveURI,
                                     java.lang.String entryName)
Builds an URI using the "jar" scheme based on the specified archive URI and the entry name passed in. The entry name is relative to the root of the jar file, so it should not begin with a slash. The entry name may be the empty string or null, which means that the returned URI should represent the jar file itself.

Non-sanitizing for both archiveURI and entryName.


newURI

public static java.net.URI newURI(java.lang.String scheme,
                                  java.lang.String userinfo,
                                  java.lang.String host,
                                  int port,
                                  java.lang.String path,
                                  java.lang.String query,
                                  java.lang.String fragment)
Creates a new URI whose parts have the exact values that are specified. In general, you should avoid calling this method directly.

This method is the ultimate place where all of the other URIFactory methods end up when creating an URI. Non-sanitizing.


newURI

public static java.net.URI newURI(java.net.URL url)
Creates a new URI form an URL.

Parameters:
url - The URL from which URI is derived.
Returns:
New URI.

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

E17493-02

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