|
|||||||||
Home >> All >> javax >> ide >> [ net overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
javax.ide.net
Class URIFactory

java.lang.Objectjavax.ide.net.URIFactory
- public final class URIFactory
- extends java.lang.Object
This class contains methods which create new instances of
java.net.URI. In order for java.net.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 java.net.URI, it
is strongly recommended that you use one of the methods in this class
rather than calling the java.net.URI constructor directly. This will
help prevent subtle bugs that can come up when two java.net.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)>Object.equals(Object)
55 method but doesn't
affect the location pointed to by the java.net.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 java.net.URI, dependencies on java.net.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
|
Constructor Summary | |
private |
URIFactory()
Private constructor prevents instantiation. |
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 java.net.URI has
the "jar" scheme. |
static java.net.URI |
newDirURI(java.io.File dir)
Creates a new java.net.URI with the "file" scheme that is for the specified directory. |
static java.net.URI |
newDirURI(java.lang.String dirPath)
Creates a new java.net.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 java.net.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 java.net.URI that is the combination of the specified base java.net.URI and the relative spec string. |
static java.net.URI |
newFileURI(java.io.File file)
This method converts a java.io.File instance into an java.net.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 java.net.URI using the " file " scheme. |
private static java.net.URI |
newJarFileURIImpl(java.lang.String uriStr)
|
static java.net.URI |
newJarURI(java.io.File archiveFile,
java.lang.String entryName)
Builds an java.net.URI using the " jar " scheme based
on the specified archive java.io.File and the entry name passed
in. |
static java.net.URI |
newJarURI(java.net.URI archiveURI,
java.lang.String entryName)
Builds an java.net.URI using the " jar " scheme based
on the specified archive java.net.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)
|
(package private) static java.net.URI |
newURI(java.lang.String uriSpec,
boolean forceDir,
boolean assumeFile)
|
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 java.net.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 java.net.URI that is the combination of the specified base java.net.URI and the relative spec string. |
static java.net.URI |
newURI(java.net.URL url)
Creates a new java.net.URI form an java.net.URL. |
static java.net.URI |
replaceFragmentPart(java.net.URI uri,
java.lang.String newFragment)
Returns a new java.net.URI that is identical to the specified java.net.URI except that the fragment part of the java.net.URI has been replaced with the specified newRef . |
static java.net.URI |
replaceHostPart(java.net.URI uri,
java.lang.String newHost)
Returns a new java.net.URI that is identical to the specified java.net.URI except that the host part of the java.net.URI has been replaced with the specified newHost . |
static java.net.URI |
replacePathPart(java.net.URI uri,
java.lang.String newPath)
Returns a new java.net.URI that is identical to the specified java.net.URI except that the path part of java.net.URI has been replaced with the specified newPath . |
static java.net.URI |
replacePortPart(java.net.URI uri,
int newPort)
Returns a new java.net.URI that is identical to the specified java.net.URI except that the port part of the java.net.URI has been replaced with the specified newPort . |
static java.net.URI |
replaceQueryPart(java.net.URI uri,
java.lang.String newQuery)
Returns a new java.net.URI that is identical to the specified java.net.URI except that the query part of the java.net.URI has been replaced with the specified newQuery . |
static java.net.URI |
replaceSchemePart(java.net.URI uri,
java.lang.String newScheme)
Returns a new java.net.URI that is identical to the specified java.net.URI except that the scheme part of the java.net.URI has been replaced with the specified newscheme . |
private static java.lang.String |
resolveRelative(java.lang.String basePath,
java.lang.String relPath)
|
private static java.lang.String |
sanitizePath(java.lang.String path)
This "sanitizes" the specified string path by converting all File.separatorChar> File.separatorChar 55 characters to forward slash ('/'). |
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
Constructor Detail |
URIFactory
private URIFactory()
- Private constructor prevents instantiation.
Method Detail |
newURI
public static java.net.URI newURI(java.net.URI baseURI, java.lang.String relativeSpec)
- Creates a new java.net.URI that is the combination of the
specified base java.net.URI and the relative spec string. The
base java.net.URI is treated as a directory, whether or not the
java.net.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 java.net.URI that is the combination of the
specified base java.net.URI and the relative spec string. The
base java.net.URI is treated as a directory whether or not it
ends with the "/" character. The returned java.net.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 java.net.URI verbatim, without any changes to
the file separator character or any other characters. For an java.net.URI whose scheme is "file", the
newFileURI(String)
55 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 java.net.URI that is the combination of the
specified
scheme
and the directory path. The directory path is used in the java.net.URI verbatim, without any changes to the file separator character or any other characters. The returned java.net.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
. ThenameGen
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 java.net.URI that is identical to the specified
java.net.URI except that the scheme part of the java.net.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 java.net.URI that is identical to the specified
java.net.URI except that the port part of the java.net.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 java.net.URI that is identical to the specified
java.net.URI except that the host part of the java.net.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 java.net.URI that is identical to the specified
java.net.URI except that the path part of java.net.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 java.net.URI that is identical to the specified
java.net.URI except that the fragment part of the java.net.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 java.net.URI that is identical to the specified
java.net.URI except that the query part of the java.net.URI
has been replaced with the specified
newQuery
.Non-sanitizing.
newURI
public static java.net.URI newURI(java.lang.String uriSpec)
newURI
static java.net.URI newURI(java.lang.String uriSpec, boolean forceDir, boolean assumeFile)
newFileURI
public static java.net.URI newFileURI(java.lang.String filePath)
- Creates a new java.net.URI using the "
file
" scheme. The specifiedfilePath
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 java.net.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 java.io.File instance into an java.net.URI
instance using an algorithm that is consistent with the other
factory methods in
URIFactory
.Sanitizing.
newDirURI
public static java.net.URI newDirURI(java.lang.String dirPath)
- Creates a new java.net.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
isnull
, then the returned java.net.URI isnull
.Sanitizing.
newDirURI
public static java.net.URI newDirURI(java.io.File dir)
- Creates a new java.net.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 java.io.File is actually a directory on disk; it just
assumes that it is. If the specified
dirPath
isnull
, then the returned java.net.URI isnull
.Sanitizing.
newJarURI
public static java.net.URI newJarURI(java.io.File archiveFile, java.lang.String entryName)
- Builds an java.net.URI using the "
jar
" scheme based on the specified archive java.io.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 java.net.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 java.net.URI has the "jar" scheme. Returnsfalse
if the specified java.net.URI isnull
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 java.net.URI using the "
jar
" scheme based on the specified archive java.net.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 java.net.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 java.net.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 java.net.URI. Non-sanitizing.
newURI
public static java.net.URI newURI(java.net.URL url)
- Creates a new java.net.URI form an java.net.URL.
sanitizePath
private static java.lang.String sanitizePath(java.lang.String path)
- This "sanitizes" the specified string path by converting all
File.separatorChar>
File.separatorChar
55 characters to forward slash ('/'). Also, a leading forward slash is prepended if the path does not begin with one.
resolveRelative
private static java.lang.String resolveRelative(java.lang.String basePath, java.lang.String relPath)
newJarFileURIImpl
private static java.net.URI newJarFileURIImpl(java.lang.String uriStr)
|
|||||||||
Home >> All >> javax >> ide >> [ net overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |