com.sun.tdk.sampleapi
Class StockSymbol

java.lang.Object
  |
  +--com.sun.tdk.sampleapi.StockSymbol

public abstract class StockSymbol
extends java.lang.Object

StockSymbol class represents a ticker symbol. Can be used to retrieve the quote.


Field Summary
static int timeout
          Timeout for Quote retrieval operation in milliseconds.
 
Constructor Summary
StockSymbol(java.lang.String symbol)
          Creates a new StockSymbol object.
 
Method Summary
 java.lang.String getName()
          Returns the name of the stock.
abstract  Quote getQuote()
          Gets the current quote of the stock.
 java.awt.Component getVisualComponent()
          Gets/updates a visual representation of the stock.
 Quote waitQoute()
          This method asynchroniously invokes getQuote() and waits timeout milleseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeout

public static int timeout
Timeout for Quote retrieval operation in milliseconds. waitQuote() returns Quote object, or should throw GetQuoteException after timeout milliseconds. Default value is 10000.

See Also:
GetQuoteException
Constructor Detail

StockSymbol

public StockSymbol(java.lang.String symbol)
Creates a new StockSymbol object.

Parameters:
symbol - Name (ticker symbol) of the stock
Throws:
java.lang.NullPointerException - if the specified symbol is null
Method Detail

getVisualComponent

public java.awt.Component getVisualComponent()
Gets/updates a visual representation of the stock. The default implementation displays the symbol, the time, the price, the change and the % change. Positive and negative changes are visualized in green and red, respectively. The quote info is obtained using the getQuote method. If the quote cannot be retrieved due to a GetQuoteException, the container displays a String of the form: symbol + ": data not available" The component is initially invisible and is not added to any container. The same component is returned for each repetitive call. Subclasses may override this method to include additional data such as charts.

Returns:
A Component object representing the Stock

getQuote

public abstract Quote getQuote()
                        throws GetQuoteException
Gets the current quote of the stock.

Returns:
The Quote value
Throws:
GetQuoteException - if an i/o exception occurs during stock retrieval

getName

public java.lang.String getName()
Returns the name of the stock.

Returns:
name The ticker symbol of the stock

waitQoute

public Quote waitQoute()
                throws GetQuoteException
This method asynchroniously invokes getQuote() and waits timeout milleseconds.

Throws:
GetQuoteException - if i/o exception occured during stock retrieval, or getQuote() does not return for timout milliseconds
See Also:
timeout, getQuote()