StocksMonitor 1.5.0

hirondelle.stocks.quotes
Class Stock

Object
  extended by Stock
All Implemented Interfaces:
Comparable<Stock>

public final class Stock
extends Object
implements Comparable<Stock>

Data-centric, immutable value class which encapsulates items related to a stock.

All permitted values are specified by the constructor.


Constructor Summary
Stock(String aName, String aTicker, Exchange aExchange, Integer aNumShares, BigDecimal aAveragePrice)
           
 
Method Summary
 int compareTo(Stock aThat)
           
 boolean equals(Object aThat)
           
 BigDecimal getAveragePrice()
           
 BigDecimal getBookValue()
          Return the product of getNumShares() and getAveragePrice().
 Exchange getExchange()
           
 String getName()
           
 Integer getNumShares()
           
 String getTicker()
           
 int hashCode()
           
 boolean isIndex()
          Return true only if the ticker represents an index such as the Dow Jones or the Standard and Poor 500 , as opposed to a regular stock.
static boolean isValidInput(List<String> aErrorMessages, String aName, String aTicker, Exchange aExchange, Integer aNumShares, BigDecimal aAvgPrice)
          Validate user input to a fine-grained level.
 String toString()
          Format this object as text which can be used as input to valueOf(java.lang.String).
 Stock valueOf(String aStockText)
          Parse a result of toString() into a Stock object.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Stock

public Stock(String aName,
             String aTicker,
             Exchange aExchange,
             Integer aNumShares,
             BigDecimal aAveragePrice)
Parameters:
aName - has visible content, and is the full name of the stock.
aTicker - non-null, contains only letters, periods, underscores, and the ^ character, and must have a length in the range 1..20 inclusive ; it is the ticker symbol used by aExchange, and does not include the suffix used by Yahoo to identify the exchange.
aExchange - is not null
aNumShares - is not null, and represents a holding as input by the user (and usually reflects their actual holding).
aAveragePrice - is not null, satisfies !aAveragePrice.doubleValue<0, and equals the average price paid by the user for aNumShares.
Method Detail

valueOf

public Stock valueOf(String aStockText)
Parse a result of toString() into a Stock object.

Parameters:
aStockText - is in the format defined by toString().

toString

public String toString()
Format this object as text which can be used as input to valueOf(java.lang.String). The return value is used for persistence of Stock objects.

The format is shown by this example:
SUNW:Sun Microsystems:Nasdaq Stock Exchange:100:46.25
That is:
Ticker:Name:Exchange:NumShares:AveragePrice

Overrides:
toString in class Object

isValidInput

public static boolean isValidInput(List<String> aErrorMessages,
                                   String aName,
                                   String aTicker,
                                   Exchange aExchange,
                                   Integer aNumShares,
                                   BigDecimal aAvgPrice)
Validate user input to a fine-grained level.

All parameters other than aErrorMessages may take any value whatsoever. All parameters other than aErrorMessages are examined, and every invalid parameter will cause a corresponding error message to be added to aErrorMessages. Valid parameters have no corresponding message.

All criteria for validity are identical with those of the constructor.

This method is intended to help validate textual user input into a dialog, before any attempt is made to call the constructor of this class. In the event of an error, the associated error messages can be displayed to the user.

Parameters:
aErrorMessages - is an out parameter, in which an error message is placed for each problem found; it must be non-null and empty.

getName

public String getName()

getTicker

public String getTicker()

getExchange

public Exchange getExchange()

getNumShares

public Integer getNumShares()

getAveragePrice

public BigDecimal getAveragePrice()

getBookValue

public BigDecimal getBookValue()
Return the product of getNumShares() and getAveragePrice().

The book value of a security is simply the cost of its acquisition.


isIndex

public boolean isIndex()
Return true only if the ticker represents an index such as the Dow Jones or the Standard and Poor 500 , as opposed to a regular stock.

In the Yahoo system, an index always begins with the ^ character.


equals

public boolean equals(Object aThat)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Stock aThat)
Specified by:
compareTo in interface Comparable<Stock>

StocksMonitor 1.5.0

Copyright Hirondelle Systems - License - Generated 2008Jul12.10.53