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.


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 a visual representation of the stock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 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