|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.borland.primetime.vfs.Url
The Url class defines immutable resource references similar to the JDK URL class.
The Url class also serves as the registration point for Filesystem implementations:
registerFilesystem
associates a Url protocol
(eg: "file") with a concrete implementation of the Filesystem class. Once
registered, a filesystem cannot be unregistered.
findFilesystem
method used by the Url maps all
unrecognized protocols to null which will cause exceptions to be thrown when
constructing Url instances. It is recommended that the constants
FileFilesystem.PROTOCOL, ZipFilesystem.PROTOCOL, and NewFilesystem.PROTOCOL
be used to avoid generating run-time errors.
registerFilesystem
.
toString
method will never use any shortcuts in this representation.
Field Summary | |
static Url[] |
EMPTY_ARRAY
|
static Strings.StringEncoding |
URL_ENCODING
|
Constructor Summary | |
Url(java.io.File file)
Create a new Url from an existing java.io.File object, using "file" for the protocol, an empty String for the host and no anchor. |
|
Url(Filesystem filesystem,
java.lang.String host,
java.lang.String file,
java.lang.String anchor)
Create a new Url from the four components supplied. |
|
Url(java.lang.String url)
Create a new Url by parsing a complete Url string in either of two forms: <protocol>://<host>/<file> or <protocol>://<host>/<file>#<anchor> |
|
Url(java.lang.String protocol,
java.lang.String file)
Create a new Url from the two components supplied, an empty String for the host and no anchor. |
|
Url(java.lang.String protocol,
java.lang.String host,
java.lang.String file)
Create a new Url from the three components supplied and no anchor. |
|
Url(java.lang.String protocol,
java.lang.String host,
java.lang.String file,
java.lang.String anchor)
Create a new Url from the four components supplied. |
Method Summary | |
int |
compareTo(java.lang.Object other)
|
boolean |
equals(java.lang.Object other)
Retrieve the Url's anchor. |
static Filesystem |
findFilesystem(java.lang.String protocol)
Find the filesystem registered for the protocol associated with the given Url. |
java.lang.String |
getAnchor()
Retrieve the Url's anchor. |
java.lang.String |
getFile()
Retrieve the Url's file. |
java.lang.String |
getFileExtension()
Retrieve the file extension portion of a Url's file. |
java.io.File |
getFileObject()
Describes the Url in terms of a java.io.File instance. |
Filesystem |
getFilesystem()
Retrieve the Filesystem associated with this Url. |
java.lang.Object |
getFilesystemObject()
For use only by Filesystem implementations. |
java.lang.String |
getHost()
Retrieve the Url's host. |
java.lang.String |
getName()
Returns a short name for the Url, typically consisting of the the last element of the file path. |
Url |
getParent()
Returns a new Url with the last element of the file path removed. |
static java.lang.String |
getPath(Url[] urls)
Produces a semicolon delimited string of Url descriptions from an array of Url objects. |
java.lang.String |
getProtocol()
Retrieve the Url's protocol. |
java.lang.String |
getRelativePath(Url target)
Create a relative path from an existing Url to specified target Url. |
java.lang.String |
getRelativePath(Url[] urls)
Produces a semicolon delimited string of relative paths from an array of Url objects, assuming that the Url asked to perform the operation is the root from which relative paths are to be determined. |
java.lang.String |
getRelativePath(Url target,
boolean onlyChildren)
Create a relative path from an existing Url to specified target Url. |
Url |
getRelativeUrl(java.lang.String relativePath)
Create a new Url from an existing root Url and a relative component. |
int |
hashCode()
Retrieve the Url's hashCode. |
boolean |
isChild(Url url)
Determines whether or not a given Url is subpath of this Url. |
static Url[] |
parsePath(java.lang.String path)
Translates a semicolon delimited list of Url descriptions into an array of Url objects. |
static Url[] |
parseRelativePath(Url root,
java.lang.String path)
Translates a semicolon delimited list of relative paths into an array of Url objects. |
static void |
registerFilesystem(Filesystem filesystem)
Add a new protocol / filesystem mapping to the Virtual File System. |
void |
setFilesystemObject(java.lang.Object filesystemObject)
For use only by Filesystem implementations. |
java.lang.String |
toString()
Retrieves the Url as a String formatted in the standard manner: <protocol>://<host>/<file> or <protocol>://<host>/<file>#<anchor> |
java.net.URL |
toURL()
Creates a JDK-style URL which maps to a protocol handler capable of reading the contents of the underlying PrimeTime-style Url. |
Url |
withAnchor(java.lang.String newAnchor)
Create a new Url derived from an existing Url by changing only the anchor portion. |
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final Url[] EMPTY_ARRAY
public static final Strings.StringEncoding URL_ENCODING
Constructor Detail |
public Url(java.io.File file)
file
- The file object.public Url(java.lang.String protocol, java.lang.String file)
protocol
- A String representing the protocol. Must not be null.file
- A String representing the file. Must not be null.public Url(java.lang.String protocol, java.lang.String host, java.lang.String file)
protocol
- A String representing the protocol. Must not be null.host
- A String representing the host. Must not be null.file
- A String representing the file. Must not be null.public Url(java.lang.String protocol, java.lang.String host, java.lang.String file, java.lang.String anchor)
protocol
- A String representing the protocol. Must not be null.host
- A String representing the host. Must not be null.file
- A String representing the file. Must not be null.anchor
- A String representing the anchor, or null if the Url is to
have no anchor.public Url(Filesystem filesystem, java.lang.String host, java.lang.String file, java.lang.String anchor)
filesystem
- A Filesystem representing the protocol. Must not be null.host
- A String representing the host. Must not be null.file
- A String representing the file. Must not be null.anchor
- A String representing the anchor, or null if the Url is to
have no anchor.public Url(java.lang.String url) throws InvalidUrlException
url
- The String to be parsed.Method Detail |
public static void registerFilesystem(Filesystem filesystem)
protocol
- The protocol for which the filesystem should be used.filesystem
- The appropriate filesystem for use with the specified
protocol.public static Filesystem findFilesystem(java.lang.String protocol)
protocol
- The protocol for which the filesystem should be used.public Url getRelativeUrl(java.lang.String relativePath)
root
- The Url root.relativePath
- The relative path from the root.public java.lang.String getRelativePath(Url target)
target
- The Url target.public java.lang.String getRelativePath(Url target, boolean onlyChildren)
target
- The Url target.onlyChildren
- True if the target must be a descendant of the root,
false if absolute paths and paths with leading "../" entries should be
considered.public boolean isChild(Url url)
url
- The potential child Url.public Url withAnchor(java.lang.String newAnchor)
newAnchor
- The anchor portion for the new Url. A null value is
interpreted as requesting a Url that has no anchor portion.public static Url[] parsePath(java.lang.String path) throws InvalidUrlException
path
- The semicolon delimited string of Urls.public static java.lang.String getPath(Url[] urls)
urls
- The array of Url objects.The
- semicolon delimited string of Urls.public static Url[] parseRelativePath(Url root, java.lang.String path) throws InvalidUrlException
root
- The Url root from which all relative paths are interpreted.path
- The semicolon delimited string of relative paths.public java.lang.String getRelativePath(Url[] urls) throws InvalidUrlException
urls
- The array of Url objects.public Filesystem getFilesystem()
public java.lang.String getProtocol()
public java.lang.String getHost()
public java.lang.String getFile()
public java.lang.String getFileExtension()
public java.io.File getFileObject()
java.io.File
instance. Note
that this may not be appropriate for many filesystem types, and will
return null in these cases.public java.lang.String getAnchor()
public Url getParent()
public java.lang.String getName()
public java.net.URL toURL()
public int compareTo(java.lang.Object other)
public boolean equals(java.lang.Object other)
other
- Another object to compare the Url with.public int hashCode()
public java.lang.String toString()
public java.lang.Object getFilesystemObject()
setFilesystemObject
.public void setFilesystemObject(java.lang.Object filesystemObject)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |