public final class URIFactory
extends java.lang.Object
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.
| Modifier and Type | Class and Description | 
|---|---|
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. | 
| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
JAR_URI_SEPARATOR  | 
| Modifier and Type | Method and Description | 
|---|---|
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. | 
public static final java.lang.String JAR_URI_SEPARATOR
public static java.net.URI newURI(java.net.URI baseURI,
                                  java.lang.String relativeSpec)
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.
public static java.net.URI newDirURI(java.net.URI baseURI,
                                     java.lang.String relativeSpec)
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.
public static java.net.URI newURI(java.lang.String scheme,
                                  java.lang.String path)
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.
public static java.net.URI newDirURI(java.lang.String scheme,
                                     java.lang.String dirPath)
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.
public static java.net.URI newUniqueURI(java.net.URI baseURI,
                                        URIFactory.NameGenerator nameGen)
baseURI. The nameGen object is called to 
  generate a unique name that will be appended to the base uri.
  Non-sanitizing.public static java.net.URI replaceSchemePart(java.net.URI uri,
                                             java.lang.String newScheme)
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.
public static java.net.URI replacePortPart(java.net.URI uri,
                                           int newPort)
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.
public static java.net.URI replaceHostPart(java.net.URI uri,
                                           java.lang.String newHost)
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.
public static java.net.URI replacePathPart(java.net.URI uri,
                                           java.lang.String newPath)
URI that is identical to the specified
  URI except that the path part of URI has been
  replaced with the specified newPath.Non-sanitizing.
public static java.net.URI replaceFragmentPart(java.net.URI uri,
                                               java.lang.String newFragment)
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.
public static java.net.URI replaceQueryPart(java.net.URI uri,
                                            java.lang.String newQuery)
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.
public static java.net.URI newURI(java.lang.String uriSpec)
public static java.net.URI newFileURI(java.lang.String filePath)
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.public static java.net.URI newFileURI(java.io.File file)
File instance into an URI
  instance using an algorithm that is consistent with the other
  factory methods in URIFactory.Sanitizing.
URI corresponding to the given File.
  The URI is produced using a mechanism that ensures
  uniformity of the URI format across platforms.public static java.net.URI newDirURI(java.lang.String dirPath)
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.
public static java.net.URI newDirURI(java.io.File dir)
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.
public static java.net.URI newJarURI(java.io.File archiveFile,
                                     java.lang.String entryName)
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.public static boolean isJarURI(java.net.URI jarURI)
true if the specified URI has
  the "jar" scheme.  Returns false if the specified
  URI is null or has a scheme other than
  "jar".public static boolean isArchive(java.lang.String pathname)
public static java.net.URI newJarURI(java.net.URI archiveURI,
                                     java.lang.String entryName)
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.
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)
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.
public static java.net.URI newURI(java.net.URL url)
URI form an URL.url - The URL from which URI is derived.