Done.

Paulo

----- Original Message ----- 
From: "robert engels" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, June 28, 2007 2:50 PM
Subject: Re: [iText-questions] changes to Image.toURL()


> Actually, catching exceptions is not expensive (creating them is),  
> and in almost all cases using
> 
> new URL(string)
> 
> is not going to throw an exception. See http://www.ibm.com/ 
> developerworks/library/j-perf07303.html
> 
> The file references you use are only applicable they use a direct  
> filename. They should be using
> 
> file:c:/hello.jpg
> 
> if they are passing a URL.
> 
> It may be simpler to just add a Image.getInstance(URL) method that  
> doesn't do any of this checking.
> 
> The HTMLWorker should be changed to use the Image.getInstance(URL).
> 
> I will still argue that toURL() is needlessly complicated. It could  
> be as simple as
> 
> URL toURL(String s) {
> try {
> return new URL(s);
> } catch(Exception e) {
> // you do not need the separator stuff, File does this for you
> return new File(s).toURL();
> }
> }
> 
> 
> 
> 
>> The toURL() method in Image is needlessly complicated and restrictive.
>>
> 
> Restrictive, yes. Complicated, it has to be.
> 
> 
>>
>> Rather than checking if the string starts with various prefixes, a
>> better solutions would be to either just call new URL(string) and
>> trap an InvalidURLException, or minimally check that the string
>>
> 
> Catching exceptions takes time and 99% of the time the "urls" are local
> files.
> 
> 
>> contains the :/ character sequence.
>>
> 
> That will allways happens in windows, like "c:/hello.jpg".
> 
> 
>>
>> Without doing this, it is impossible to use URL that use a custom
>> protocol.
>>
>>
> 
> The toURL() will have to be complicated even further to take care of
> that, and it will.
> 
> 
>> Similarly, the checking of http: in HTMLWorker should be changed to
>> check for the :/ sequence.
>>
>>
> 
> Images in HTMLWorker are not very consistent, they will have to be
> revised.
> 
> Paulo


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to