Class DataLoader
java.lang.Object
|
+----DataLoader
- public class DataLoader
- extends Object
- implements Runnable
This class is used to load the text data for TextScroll in an
asynchronous way. It will also apply the automatic line wrapping
to the data. It provides a refresh() method which
can be used to force this DataLoader to reload
the data from the URL it was given when it was constructed.
-
VERSION
- The current version of this class.
-
DataLoader(URL, Font, int)
- Constructor.
-
DataLoader(URL, Font, int, boolean)
- Constructor.
-
dataReady()
- Method for determining when the data has arrived.
-
errorOccurred()
- Method for determining if an error has occurred.
-
getData()
- Method for getting the actual data.
-
refresh()
- This method is called to reload the data from the URL.
-
run()
- This method actually loads the data.
-
start()
- Method called when the thread is started.
-
stop()
- Method called to terminate the Thread.
VERSION
public static final String VERSION
- The current version of this class.
DataLoader
public DataLoader(URL url,
Font startingFont,
int width)
- Constructor. It expects the URL of the data file to load from.
The constructed
DataLoader will apply line
wrapping to the retrieved data.
- Parameters:
- url - The URL to load the data from.
- startingFont - The starting Font, used for line wrapping.
- width - The width of the starting font, use for line
wrapping.
DataLoader
public DataLoader(URL url,
Font startingFont,
int width,
boolean shouldWrap)
- Constructor. It expects the URL of the data file to load from.
It returns immediately.
- Parameters:
- url - The URL to load the data from.
- startingFont - The starting Font, used for line wrapping.
- width - The width of the starting font, use for line
wrapping.
- shouldWrap - A boolean indicating whether or not this
DataLoader should apply line
wrapping or not.
refresh
public void refresh()
- This method is called to reload the data from the URL. It returns
immediately. It performs automatic line wrapping based on the
width and
Font given in the constructor.
run
public void run()
- This method actually loads the data. It sets the internal flags
appropriately, such that calls to
dataReady() and
errorOccurred will always return correct information.
stop
public void stop()
- Method called to terminate the Thread.
start
public void start()
- Method called when the thread is started.
dataReady
public boolean dataReady()
- Method for determining when the data has arrived.
- Returns:
-
true if the data is ready, false
otherwise.
errorOccurred
public boolean errorOccurred()
- Method for determining if an error has occurred.
- Returns:
-
true if an error occurred, and the data is never
going to arrive, false if no error has occurred.
getData
public String[] getData()
- Method for getting the actual data. If it hasn't arrived yet, this
method returns
null.
- Returns:
- The array of
Strings which are the data, if it
is here, or null if it is still loading or if an
error occurred.