|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectstockDataRetrieval.NewsDownloader
Singleton class that controls the downloading of the news stories for all stocks.
The object is triggered to activate a new thread or store it for later when a new ticker is added or when a previously spawned thread completes.
| Field Summary | |
private int |
MAX_NUM_THREADS
the max number of news downloading threads allowed |
private java.util.Vector |
newsThreads
a collection of threads that are waiting their turn to execute |
private static int |
numActiveThreads
the nubmer of currently active threads |
private static int |
numCompletedThreads
the number of completed threads |
private static NewsDownloader |
theInstance
the instance of the NewsDownloader |
| Constructor Summary | |
private |
NewsDownloader()
Configure the downloader with a set max number of simultaneous threads |
| Method Summary | |
void |
addTicker(java.lang.String newTicker)
Add a new ticker for which to fetch a news story for |
static NewsDownloader |
getInstance()
Return the instance of the singleton object |
void |
getStockNews(java.lang.String tickerFile)
Retrieves files containing all news stories about a stock and stores it to a local directory. |
private void |
handleNotify()
Whenever a new ticker name is added, this function enables the class to analyze the state of active threads and activate new threads or wait |
void |
notifyMe()
When a thread previously spawned completes, the thread notifies the singleton via this method. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static NewsDownloader theInstance
private int MAX_NUM_THREADS
private java.util.Vector newsThreads
private static int numActiveThreads
private static int numCompletedThreads
| Constructor Detail |
private NewsDownloader()
| Method Detail |
public static NewsDownloader getInstance()
public void addTicker(java.lang.String newTicker)
newTicker - The ticker for which to add to the list tickers to get news stories forprivate void handleNotify()
public void notifyMe()
The function calls code to determine if a new thread should be spawned.
public void getStockNews(java.lang.String tickerFile)
tickerFile - The name of the file containing all the ticker - company tuples
which serves as the list of tickers to get the news for
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||