The Artima Developer Community
Sponsored Link

Agile Buzz Forum
PartialURLs in VisualWorks 7.6

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
PartialURLs in VisualWorks 7.6 Posted: Dec 14, 2007 8:08 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: PartialURLs in VisualWorks 7.6
Feed Title: Michael Lucas-Smith
Feed URL: http://www.michaellucassmith.com/site.atom
Feed Description: Smalltalk and my misinterpretations of life
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Michael Lucas-Smith

Advertisement

Every now and then you get to do a minor improvement to an already exceptional area of the system. URIs are a really great idea and their APIs are pretty neat. Modelling a URI as an object gives you advantages when you're programming - it lets you manipulate the urls in object form, then serialize them out as encoded urls and suddenly you never have to worry about remembering to call URIEncoder.

Many moons ago I made a package called RelativeURL for WithStyle when we were doing anchor clicks. If you clicked on an anchor and the URL is relative - where should you go? ... VisualWorks had some basic functionality for this called #resolvePath: but in this instance, the API threw away the object on the right hand side of the equation and took a string.

Now with PartialURLs you can model not only a full URL but a URL that is just a path, query and fragment. For example, the following is now valid: '/images/test.png' asURI. Because they are real objects, you can now manipulate them like you would other kinds of URLs, except that these ones have no host or port.

Often when dealing with XML resources of one form or another, you'll be handed a relative URL that is meant to be relative to the xml:base URL. you can combine the two together with PartialURLs without having to know if the RHS of the equation is just a string or an actual URL. In fact, the RHS of the equation can be a full URL too - so now you don't even have to think about whether the "relative url" is a full url or not.

What do I mean by that? Well, take the following: 'http://localhost:7777/' aURI, '/images/test.png' asURI - this will output a URL of 'http://localhost:7777/images/test.png'. But if our program is more generic, eg: baseURL, optionURL then we may not know what kind of URL the optionURL is. If it ends up being something like this: 'http://localhost:7777/' asURI, 'https://secret:1234/files/things.zip' then the resultant URL will be 'https://secret:1234/files/things.zip'

The #resolvePath: methods (of which #, is an alias for) works the same way the web browsers do when combining the base with another url. This will be available in VisualWorks 7.6 and the next release of ObjectStudio 8.

Read: PartialURLs in VisualWorks 7.6

Topic: Xtreams-20071207-API.png Previous Topic   Next Topic Topic: New Blog Stuff

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use