Url

The type core.io.Url stores a generic url. In the context of Storm, a url consists of a protocol followed by a sequence of /-separated parts. The Url is designed to be a convenient way of manipulating urls (such as paths) without resorting to string manipulation. As such, the Url class typically does not access the file system. It is therefore possible to create Urls that refer to non-existent or even invalid file names. To aid in differentiating between urls to files and urls to paths, the Url class has a notion of whether it refers to a file or directory. By convention, urls that refer to a directory are printed using a trailing slash /.

The associated protocol manages access to the underlying file system. As such, there are members of the Url class that uses the associated protocol to check if a constructed Url exists, to open it, list the contents of directories, etc. All protocols do not support all operations. For example, the file:// protocol that is used for local files (and pretty-printed as regular paths) supports all operations, while the protocol for relative paths supports none of them.

Creating Urls

The library contains a few convenience functions that produce Urls that serve as a starting point for further path traversal:

The system also contains the functions parsePath and parsePathAsDir that parses a string containing a path into a Url object. These functions have the limitation that they only support paths on the local filesystem:

An instance of the Url class is immutable. That is, none of the members of the class modify the object. Instead, they return a copy of the class with the modifications applied. It has the following operations:

Apart from the operations above, that operate on the contents of the Url itself, it contains the following operations that access the underlying filesystem through the associated Protocol. These operations are thus not available for all Protocols. In particular, they are not available for relative urls.

Protocols

The following protocols are provided by the library: