SalesPoint Framework v3.0

data
Class QuoteValue

java.lang.Object
  |
  +--data.QuoteValue

public class QuoteValue
extends Object
implements Value

A QuoteValue consists of two values: A bid and an offer.

QuoteValues usually represent prices. The bid is the price to be paid if someone wants to buy something from the Shop. The offer is the price paid when the Shop bought the product.

QuoteValues have two more attributes: the spread and the mid. While the mid is the mean value of bid and offer, the spread is defined as bid - offer.

Since:
v2.0
Version:
2.0 19/08/1999
Author:
Steffen Zschaler
See Also:
Serialized Form

Field Summary
protected  Value m_vBid
          The bid.
protected  Value m_vOffer
          The offer.
 
Constructor Summary
QuoteValue(Value vBid, Value vOffer)
          Create a new QuoteValue.
 
Method Summary
 Value add(Value v)
           
 void addAccumulating(Value v)
          If the given value is a QuoteValue, its bid and offer get added to this value's bid and offer, resp.
 Object clone()
          Create and return a deep clone of the QuoteValue.
 int compareTo(Object o)
          Compare this value to the given one.
 Value divide(Value v)
           
 void divideAccumulating(Value v)
          If the given value is a QuoteValue, this value's bid and offer get divided by its bid and offer, resp.
 Value getBid()
          Get the current bid of this QuoteValue.
 Value getMid()
          Get the mid of this value.
 Value getOffer()
          Get the current offer of this QuoteValue.
 Value getSpread()
          Get the spread of this value.
 boolean isAddZero()
          True, iff both bid and offer are zero elements with respect to addition.
 boolean isMulOne()
          True, iff both bid and offer are one elements with respect to multiplication.
 boolean isMulZero()
          True, iff both bid and offer are zero elements with respect to multiplication.
 Value multiply(double dl)
           
 Value multiply(float fl)
           
 Value multiply(int n)
           
 Value multiply(long l)
           
 Value multiply(Value v)
           
 void multiplyAccumulating(double dl)
          Both bid and offer get multiplied by the given 'scalar'.
 void multiplyAccumulating(float fl)
          Both bid and offer get multiplied by the given 'scalar'.
 void multiplyAccumulating(int n)
          Both bid and offer get multiplied by the given 'scalar'.
 void multiplyAccumulating(long l)
          Both bid and offer get multiplied by the given 'scalar'.
 void multiplyAccumulating(Value v)
          If the given value is a QuoteValue, its bid and offer get multiplied by this value's bid and offer, resp.
 Value subtract(Value v)
           
 void subtractAccumulating(Value v)
          If the given value is a QuoteValue, its bid and offer get subtracted from this value's bid and offer, resp.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_vBid

protected Value m_vBid
The bid.

m_vOffer

protected Value m_vOffer
The offer.
Constructor Detail

QuoteValue

public QuoteValue(Value vBid,
                  Value vOffer)
Create a new QuoteValue.
Parameters:
vBid - the bid
vOffer - the offer
Throws:
IllegalArgumentException - if (vBid.getClass() != vOffer.getClass()).
Method Detail

getBid

public Value getBid()
Get the current bid of this QuoteValue.
Override:
Never.

getOffer

public Value getOffer()
Get the current offer of this QuoteValue.
Override:
Never.

clone

public Object clone()
Create and return a deep clone of the QuoteValue. Bid and offer are cloned and the clones become bid and offer of the new Value.
Override:
Never.
Specified by:
clone in interface Value
Overrides:
clone in class Object

addAccumulating

public void addAccumulating(Value v)
If the given value is a QuoteValue, its bid and offer get added to this value's bid and offer, resp. Otherwise, the value is added to both, bid and offer. An analogous algorithm is used for all other operations.
Override:
Never.
Specified by:
addAccumulating in interface Value
Parameters:
v - the value to be added.

subtractAccumulating

public void subtractAccumulating(Value v)
If the given value is a QuoteValue, its bid and offer get subtracted from this value's bid and offer, resp. Otherwise, the value is subtracted from both, bid and offer. An analogous algorithm is used for all other operations.
Override:
Never.
Specified by:
subtractAccumulating in interface Value
Parameters:
v - the value to be subtracted.

multiplyAccumulating

public void multiplyAccumulating(Value v)
If the given value is a QuoteValue, its bid and offer get multiplied by this value's bid and offer, resp. Otherwise, both bid and offer are multiplied by the given value. An analogous algorithm is used for all other operations.
Override:
Never.
Specified by:
multiplyAccumulating in interface Value
Parameters:
v - the value to multiply by.

multiplyAccumulating

public void multiplyAccumulating(double dl)
Both bid and offer get multiplied by the given 'scalar'.
Override:
Never.
Specified by:
multiplyAccumulating in interface Value
Parameters:
dl - the 'scalar' to multiply by.

multiplyAccumulating

public void multiplyAccumulating(float fl)
Both bid and offer get multiplied by the given 'scalar'.
Override:
Never.
Specified by:
multiplyAccumulating in interface Value
Parameters:
fl - the 'scalar' to multiply by.

multiplyAccumulating

public void multiplyAccumulating(long l)
Both bid and offer get multiplied by the given 'scalar'.
Override:
Never.
Specified by:
multiplyAccumulating in interface Value
Parameters:
l - the 'scalar' to multiply by.

multiplyAccumulating

public void multiplyAccumulating(int n)
Both bid and offer get multiplied by the given 'scalar'.
Override:
Never.
Specified by:
multiplyAccumulating in interface Value
Parameters:
n - the 'scalar' to multiply by.

divideAccumulating

public void divideAccumulating(Value v)
If the given value is a QuoteValue, this value's bid and offer get divided by its bid and offer, resp. Otherwise, both bid and offer are divided by the given value. An analogous algorithm is used for all other operations.
Override:
Never.
Specified by:
divideAccumulating in interface Value
Parameters:
v - the value to divide by.

add

public Value add(Value v)
Override:
Never.
Specified by:
add in interface Value
See Also:
addAccumulating(data.Value)

subtract

public Value subtract(Value v)
Override:
Never.
Specified by:
subtract in interface Value
See Also:
subtractAccumulating(data.Value)

multiply

public Value multiply(Value v)
Override:
Never.
Specified by:
multiply in interface Value
See Also:
multiplyAccumulating(data.Value)

multiply

public Value multiply(double dl)
Override:
Never.
Specified by:
multiply in interface Value
See Also:
multiplyAccumulating(double)

multiply

public Value multiply(float fl)
Override:
Never.
Specified by:
multiply in interface Value
See Also:
multiplyAccumulating(float)

multiply

public Value multiply(long l)
Override:
Never.
Specified by:
multiply in interface Value
See Also:
multiplyAccumulating(long)

multiply

public Value multiply(int n)
Override:
Never.
Specified by:
multiply in interface Value
See Also:
multiplyAccumulating(int)

divide

public Value divide(Value v)
Override:
Never.
Specified by:
divide in interface Value
See Also:
divideAccumulating(data.Value)

getSpread

public Value getSpread()
Get the spread of this value. The spread is defined as bid - offer.
Override:
Never.

getMid

public Value getMid()
Get the mid of this value. The mid is defined as (bid + offer) / 2.
Override:
Never.

compareTo

public int compareTo(Object o)
Compare this value to the given one. This will compare the mids.
Override:
Sometimes.
Throws:
ClassCastException - if the given object could not be cast into a QuoteValue.

isAddZero

public boolean isAddZero()
True, iff both bid and offer are zero elements with respect to addition.
Override:
Sometimes.
Specified by:
isAddZero in interface Value

isMulZero

public boolean isMulZero()
True, iff both bid and offer are zero elements with respect to multiplication.
Override:
Sometimes.
Specified by:
isMulZero in interface Value

isMulOne

public boolean isMulOne()
True, iff both bid and offer are one elements with respect to multiplication.
Override:
Sometimes.
Specified by:
isMulOne in interface Value

SalesPoint Framework v3.0