net.landspurg.util
Class URLFetcher

java.lang.Object
  extended by net.landspurg.util.URLFetcher
All Implemented Interfaces:
java.lang.Runnable

public class URLFetcher
extends java.lang.Object
implements java.lang.Runnable

A class that is going to fetch a specific URL and then, notify the the listner after each line read, or when the complete URL has been loaded....
note: works for text only!

This is done asynchronously..
first, initiate the fetcher, and eventully setup the listener and then call fetch to start...
example:
u=new URLFetcher("http://landspurg.net");
u.setListener(this);
u.fetch();
....


Field Summary
 java.lang.StringBuffer m_res
           
 
Constructor Summary
URLFetcher(java.lang.String in_url)
          Set the URL to fetch...
 
Method Summary
static java.lang.String encode64(byte[] data)
           
static java.lang.StringBuffer encode64(byte[] data, int start, int len, java.lang.StringBuffer buf)
          Encodes the part of the given byte array denoted by start and len to the Base64 format.
static java.lang.String encode64(java.lang.String str)
           
 void fetch()
          Fetch the data effectivily.
 void run()
           
 void setListener(NotifyLoadURL inRef)
          Set the listener to be called when an event happens during the download...
 void setMethod(java.lang.String inMethod)
           
 void setUserNamePassword(java.lang.String inUsername, java.lang.String inPassword)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_res

public java.lang.StringBuffer m_res
Constructor Detail

URLFetcher

public URLFetcher(java.lang.String in_url)
Set the URL to fetch...

Parameters:
in_url -
Method Detail

setMethod

public void setMethod(java.lang.String inMethod)

setUserNamePassword

public void setUserNamePassword(java.lang.String inUsername,
                                java.lang.String inPassword)

fetch

public void fetch()
Fetch the data effectivily. In practicle start the download thread and return


setListener

public void setListener(NotifyLoadURL inRef)
Set the listener to be called when an event happens during the download...
Can be set to null to remove it.

Parameters:
inRef -

run

public void run()
Specified by:
run in interface java.lang.Runnable

encode64

public static java.lang.String encode64(byte[] data)

encode64

public static java.lang.String encode64(java.lang.String str)

encode64

public static java.lang.StringBuffer encode64(byte[] data,
                                              int start,
                                              int len,
                                              java.lang.StringBuffer buf)
Encodes the part of the given byte array denoted by start and len to the Base64 format. The encoded data is appended to the given StringBuffer. If no StringBuffer is given, a new one is created automatically. The StringBuffer is the return value of this method.