Last published: January 25, 2007 by 'michael'
Defines 26 Classes
Extends 31 Classes
This package contains all the base URIs that exist in the world. It provides only the modelling of those URIs and not any behaviour for the URIs themselves.
The following URIs are included:
It also includes an abstraction for relative URIs (eg: '/index.html') which are only absolute when combined with a base URI, eg: 'http://localhost' asURI, '/index.html' asURI would make an absolute HTTP URI for localhost and then combine it with the relative URI for /index.html
This package also includes unknown URI support for protocols which we currently do not support and understand, eg: 'foo:mystuff' asURI will create a URI of UnknownURI which has a protocol of foo and a data variable of 'mystuff'.
The objects do the URI escaping/unescaping for you.
Because these URI objects are immutable, any change to them will give you back a copy of the URI - this is important to remember when you're setting parameters or variables on a URI to record the new URI you're given. Eg: myNewURI := myURI host: 'www.someotherplace.net'.
You can do bulk changes to a URI with the protocol:
myNewURI := myURI whileChangingDo: [:copy |
copy host: 'newhost.com'; port: 82; username: 'bob'].
This is a more efficient way than creating three copies for each attribute you change. The new URI is passed to you inside the whileChangingDo: block to ensure you're not editing the original URI object.
Because these URIs are immutable, that also means that you can do an identity compare on them to see if they are the same. In effect, these URIs act like Symbols since they uniquely identify a location on the internet that you can re-access consistently.