jgnash.engine
Class SecurityNode

java.lang.Object
  extended by jgnash.engine.StoredObject
      extended by jgnash.engine.CommodityNode
          extended by jgnash.engine.SecurityNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<CommodityNode>

public class SecurityNode
extends CommodityNode
implements java.lang.Cloneable

Security Node

The last market price is cached to improve performance

Version:
$Id$
Author:
Craig Cavanaugh
See Also:
Serialized Form

Field Summary
private  QuoteSource cachedQuoteSource
           
private  java.util.List<SecurityHistoryNode> historyNodes
           
private  java.lang.String isin
          Symbol for quote download.
private  java.util.concurrent.locks.ReadWriteLock lock
           
private  java.lang.String quoteSource
          The currency that security values are reported in
private  CurrencyNode reportedCurrency
           
private static long serialVersionUID
           
 
Constructor Summary
SecurityNode()
           
SecurityNode(CurrencyNode node)
           
 
Method Summary
(package private)  boolean addHistoryNode(SecurityHistoryNode node)
           
 java.lang.Object clone()
          Return a clone of this security node Security history is not cloned
protected  SecurityHistoryNode getHistoryNode(java.util.Date date)
           
 java.util.List<SecurityHistoryNode> getHistoryNodes()
          Get a copy of SecurityHistoryNodes for this security
 java.lang.String getISIN()
           
private  SecurityHistoryNode getLastHistoryNode()
           
private  java.util.concurrent.locks.ReadWriteLock getLock()
           
(package private)  java.math.BigDecimal getMarketPrice(java.util.Date date)
           
 java.math.BigDecimal getMarketPrice(java.util.Date date, CurrencyNode node)
          Returns the latest market price exchanged to the specified currency
 java.lang.String getPrefix()
          Prefix is deferred to the reported currency
 QuoteSource getQuoteSource()
          Returns the quote download source
 CurrencyNode getReportedCurrencyNode()
          Returns the CurrencyNode that security histories are reported in
 java.lang.String getSuffix()
          Suffix is deferred to the reported currency
protected  java.lang.Object readResolve()
           
(package private)  boolean removeHistoryNode(SecurityHistoryNode hNode)
           
 void setISIN(java.lang.String isin)
           
 void setPrefix(java.lang.String ignored)
           
 void setQuoteSource(QuoteSource source)
          Sets the quote download source
 void setReportedCurrencyNode(CurrencyNode node)
          Set the CurrencyNode that security histories are reported in
 void setSuffix(java.lang.String ignored)
           
 
Methods inherited from class jgnash.engine.CommodityNode
compareTo, equals, getDescription, getScale, getSymbol, hashCode, matches, round, setDescription, setScale, setSymbol, toString
 
Methods inherited from class jgnash.engine.StoredObject
getUuid, isMarkedForRemoval, setMarkedForRemoval
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

reportedCurrency

private CurrencyNode reportedCurrency

quoteSource

private java.lang.String quoteSource
The currency that security values are reported in


cachedQuoteSource

private transient QuoteSource cachedQuoteSource

isin

private java.lang.String isin
Symbol for quote download. Not always the same as the commodity symbol


historyNodes

private java.util.List<SecurityHistoryNode> historyNodes

lock

private transient java.util.concurrent.locks.ReadWriteLock lock
Constructor Detail

SecurityNode

public SecurityNode()

SecurityNode

public SecurityNode(CurrencyNode node)
Method Detail

getLock

private java.util.concurrent.locks.ReadWriteLock getLock()

getPrefix

public java.lang.String getPrefix()
Prefix is deferred to the reported currency

Overrides:
getPrefix in class CommodityNode
Returns:
prefix of the reported currency

setPrefix

public void setPrefix(java.lang.String ignored)
Overrides:
setPrefix in class CommodityNode

getSuffix

public java.lang.String getSuffix()
Suffix is deferred to the reported currency

Overrides:
getSuffix in class CommodityNode
Returns:
suffix of the reported currency

setSuffix

public void setSuffix(java.lang.String ignored)
Overrides:
setSuffix in class CommodityNode

getQuoteSource

public QuoteSource getQuoteSource()
Returns the quote download source

Returns:
quote download source

setQuoteSource

public void setQuoteSource(QuoteSource source)
Sets the quote download source

Parameters:
source - QuoteSource to use

getISIN

public java.lang.String getISIN()

setISIN

public void setISIN(java.lang.String isin)

setReportedCurrencyNode

public void setReportedCurrencyNode(CurrencyNode node)
Set the CurrencyNode that security histories are reported in

Parameters:
node - reported CurrencyNode

getReportedCurrencyNode

public CurrencyNode getReportedCurrencyNode()
Returns the CurrencyNode that security histories are reported in

Returns:
reported CurrencyNode

addHistoryNode

boolean addHistoryNode(SecurityHistoryNode node)

removeHistoryNode

boolean removeHistoryNode(SecurityHistoryNode hNode)

getLastHistoryNode

private SecurityHistoryNode getLastHistoryNode()

getHistoryNodes

public java.util.List<SecurityHistoryNode> getHistoryNodes()
Get a copy of SecurityHistoryNodes for this security

Returns:
Returns a shallow copy of the history nodes to protect against modification

getHistoryNode

protected SecurityHistoryNode getHistoryNode(java.util.Date date)

getMarketPrice

java.math.BigDecimal getMarketPrice(java.util.Date date)

getMarketPrice

public java.math.BigDecimal getMarketPrice(java.util.Date date,
                                           CurrencyNode node)
Returns the latest market price exchanged to the specified currency

Parameters:
date - date to find closest matching rate without exceeding
node - currency to exchange to
Returns:
latest market price

clone

public java.lang.Object clone()
Return a clone of this security node Security history is not cloned

Overrides:
clone in class StoredObject
Returns:
clone of this SecurityNode with history nodes

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Throws:
java.io.ObjectStreamException