SalesPoint Framework v3.1

data
Class QuoteValue

java.lang.Object
  extended bydata.QuoteValue
All Implemented Interfaces:
Cloneable, Comparable, Serializable, Value

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
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)
          Add the given value to this one, and return the result.
 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)
          Divide this value by the given one, and return the result.
 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)
          Multiply this value by the given 'scalar', and return the result.
 Value multiply(float fl)
          Multiply this value by the given 'scalar', and return the result.
 Value multiply(int n)
          Multiply this value by the given 'scalar', and return the result.
 Value multiply(long l)
          Multiply this value by the given 'scalar', and return the result.
 Value multiply(Value v)
          Multiply this value by the given one, and return the result.
 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)
          Subtract the given value from this one, and return the result.
 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.

Specified by:
clone in interface Value
Override:
Never

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.

Specified by:
addAccumulating in interface Value
Parameters:
v - the value to be added.
Override:
Never

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.

Specified by:
subtractAccumulating in interface Value
Parameters:
v - the value to be subtracted.
Override:
Never

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.

Specified by:
multiplyAccumulating in interface Value
Parameters:
v - the value to multiply by.
Override:
Never

multiplyAccumulating

public void multiplyAccumulating(double dl)
Both bid and offer get multiplied by the given 'scalar'.

Specified by:
multiplyAccumulating in interface Value
Parameters:
dl - the 'scalar' to multiply by.
Override:
Never

multiplyAccumulating

public void multiplyAccumulating(float fl)
Both bid and offer get multiplied by the given 'scalar'.

Specified by:
multiplyAccumulating in interface Value
Parameters:
fl - the 'scalar' to multiply by.
Override:
Never

multiplyAccumulating

public void multiplyAccumulating(long l)
Both bid and offer get multiplied by the given 'scalar'.

Specified by:
multiplyAccumulating in interface Value
Parameters:
l - the 'scalar' to multiply by.
Override:
Never

multiplyAccumulating

public void multiplyAccumulating(int n)
Both bid and offer get multiplied by the given 'scalar'.

Specified by:
multiplyAccumulating in interface Value
Parameters:
n - the 'scalar' to multiply by.
Override:
Never

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.

Specified by:
divideAccumulating in interface Value
Parameters:
v - the value to divide by.
Override:
Never

add

public Value add(Value v)
Description copied from interface: Value
Add the given value to this one, and return the result.

Specified by:
add in interface Value
Parameters:
v - the value to be added.
See Also:
addAccumulating(data.Value)
Override:
Never

subtract

public Value subtract(Value v)
Description copied from interface: Value
Subtract the given value from this one, and return the result.

Specified by:
subtract in interface Value
Parameters:
v - the value to be subtracted.
See Also:
subtractAccumulating(data.Value)
Override:
Never

multiply

public Value multiply(Value v)
Description copied from interface: Value
Multiply this value by the given one, and return the result.

Specified by:
multiply in interface Value
Parameters:
v - the value by which to multiply.
See Also:
multiplyAccumulating(data.Value)
Override:
Never

multiply

public Value multiply(double dl)
Description copied from interface: Value
Multiply this value by the given 'scalar', and return the result.

Specified by:
multiply in interface Value
Parameters:
dl - the 'scalar' by which to multiply.
See Also:
multiplyAccumulating(double)
Override:
Never

multiply

public Value multiply(float fl)
Description copied from interface: Value
Multiply this value by the given 'scalar', and return the result.

Specified by:
multiply in interface Value
Parameters:
fl - the 'scalar' by which to multiply.
See Also:
multiplyAccumulating(float)
Override:
Never

multiply

public Value multiply(long l)
Description copied from interface: Value
Multiply this value by the given 'scalar', and return the result.

Specified by:
multiply in interface Value
Parameters:
l - the 'scalar' by which to multiply.
See Also:
multiplyAccumulating(long)
Override:
Never

multiply

public Value multiply(int n)
Description copied from interface: Value
Multiply this value by the given 'scalar', and return the result.

Specified by:
multiply in interface Value
Parameters:
n - the 'scalar' by which to multiply.
See Also:
multiplyAccumulating(int)
Override:
Never

divide

public Value divide(Value v)
Description copied from interface: Value
Divide this value by the given one, and return the result.

Specified by:
divide in interface Value
Parameters:
v - the value by which to divide.
See Also:
divideAccumulating(data.Value)
Override:
Never

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.

Specified by:
compareTo in interface Comparable
Throws:
ClassCastException - if the given object could not be cast into a QuoteValue.
Override:
Sometimes

isAddZero

public boolean isAddZero()
True, iff both bid and offer are zero elements with respect to addition.

Specified by:
isAddZero in interface Value
Returns:
true if this is the zero element with respect to addition, i.e. if for any value v: (v.getClass() == this.getClass()) -> ((v.add (this).equals (v)) && (this.add (v).equals (v))).
Override:
Sometimes

isMulZero

public boolean isMulZero()
True, iff both bid and offer are zero elements with respect to multiplication.

Specified by:
isMulZero in interface Value
Returns:
true if this is the zero element with respect to multiplication, i.e. if for any value v: (v.getClass() == this.getClass()) -> ((v.multiply (this).equals (this)) && (this.multiply (v).equals (this))).
Override:
Sometimes

isMulOne

public boolean isMulOne()
True, iff both bid and offer are one elements with respect to multiplication.

Specified by:
isMulOne in interface Value
Returns:
true if this is the one element with respect to multiplication, i.e. if for any value v: (v.getClass() == this.getClass()) -> ((v.multiply (this).equals (v)) && (this.multiply (v).equals (v))).
Override:
Sometimes

SalesPoint Framework v3.1