|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cuny.cat.core.Shout
public class Shout
A class representing a shout in an auction. A shout may be either a bid (offer to buy) or an ask (offer to sell).
Shouts are mutable within this package for performance reasons, hence care should be taken not to rely on, e.g. shouts held in collections remaining constant.
Nested Class Summary | |
---|---|
static class |
Shout.MutableShout
A Shout that is publically mutable. |
Field Summary | |
---|---|
protected Shout |
child
The child of this shout. |
static int |
CREATED
|
protected java.lang.String |
id
The agent placing this offer |
protected boolean |
isBid
True if this shout is a bid. |
static int |
MATCHED
|
protected Shout |
parent
the parent of this shout. |
static int |
PENDING
different meaning at different locations: (TRADER): placing shout being attempted; (SERVER): an attempted shout placing or modification is under way (SPECIALIST): a transaction involving this shout is proposed to server |
static int |
PLACED
|
protected double |
price
The price of this offer |
protected int |
quantity
The number of items offered/wanted. |
static int |
REJECTED
|
protected Specialist |
specialist
|
protected int |
state
|
static boolean |
TRACE
a switch for debug purposes. |
protected Trader |
trader
|
Constructor Summary | |
---|---|
Shout()
|
|
Shout(int quantity,
double price,
boolean isBid)
|
|
Shout(Shout existing)
|
|
Shout(java.lang.String shoutId,
double price,
boolean isBid)
|
|
Shout(java.lang.String shoutId,
int quantity,
double price,
boolean isBid)
|
|
Shout(java.lang.String shoutId,
int quantity,
double price,
boolean isBid,
Trader trader,
Specialist specialist)
|
Method Summary | |
---|---|
java.lang.Object |
clone()
|
int |
compareTo(Shout other)
|
void |
copyFrom(Shout other)
|
boolean |
equals(Shout shout)
TODO: currently only shout ID is compared, however this cannot rule out the parent shout and child shout. |
Shout |
getChild()
Get the child of this shout. |
java.lang.String |
getId()
|
Shout |
getParent()
Get the parent of this shout. |
double |
getPrice()
|
int |
getQuantity()
|
Specialist |
getSpecialist()
|
int |
getState()
|
java.lang.String |
getStateDescription()
|
Trader |
getTrader()
|
boolean |
isAsk()
|
boolean |
isBid()
|
boolean |
isMatched()
|
boolean |
isValid()
|
static double |
maxPrice(Shout s,
double price)
|
static double |
maxPrice(Shout s1,
Shout s2)
|
static double |
minPrice(Shout s,
double price)
|
static double |
minPrice(Shout s1,
Shout s2)
|
boolean |
satisfies(Shout other)
|
void |
setChild(Shout child)
|
void |
setId(java.lang.String id)
|
void |
setIsBid(boolean isBid)
|
void |
setParent(Shout parent)
|
void |
setPrice(double price)
|
void |
setQuantity(int quantity)
|
void |
setSpecialist(Specialist specialist)
|
void |
setState(int state)
|
void |
setTrader(Trader trader)
|
Shout |
splat(int excess)
|
Shout |
split(int excess)
Reduce the quantity of this shout by excess and return a new child shout containing the excess quantity. |
java.lang.String |
toPrettyString()
|
java.lang.String |
toString()
|
static int |
totalVolume(java.util.Iterator<Shout> itor)
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final boolean TRACE
protected int quantity
protected double price
protected java.lang.String id
protected Trader trader
protected Specialist specialist
protected boolean isBid
public static final int CREATED
public static final int PLACED
public static final int REJECTED
public static final int MATCHED
public static final int PENDING
protected int state
protected Shout child
protected Shout parent
Constructor Detail |
---|
public Shout()
public Shout(java.lang.String shoutId, double price, boolean isBid)
public Shout(int quantity, double price, boolean isBid)
public Shout(Shout existing)
public Shout(java.lang.String shoutId, int quantity, double price, boolean isBid, Trader trader, Specialist specialist)
public Shout(java.lang.String shoutId, int quantity, double price, boolean isBid)
Method Detail |
---|
public int getQuantity()
public double getPrice()
public java.lang.String getId()
public Trader getTrader()
public Specialist getSpecialist()
public boolean isBid()
public boolean isAsk()
public int getState()
public void setState(int state)
public boolean isMatched()
public boolean satisfies(Shout other)
public int compareTo(Shout other)
compareTo
in interface java.lang.Comparable<Shout>
public boolean equals(Shout shout)
shout
- the shout to be compared with this shout
public boolean isValid()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toPrettyString()
public static int totalVolume(java.util.Iterator<Shout> itor)
itor
-
public static double maxPrice(Shout s1, Shout s2)
public static double maxPrice(Shout s, double price)
public static double minPrice(Shout s1, Shout s2)
public static double minPrice(Shout s, double price)
public Shout getChild()
public void setChild(Shout child)
public Shout getParent()
public void setParent(Shout parent)
public void copyFrom(Shout other)
public Shout split(int excess)
excess
- The excess quantitypublic Shout splat(int excess)
public void setIsBid(boolean isBid)
public void setId(java.lang.String id)
public void setPrice(double price)
public void setQuantity(int quantity)
public void setTrader(Trader trader)
public void setSpecialist(Specialist specialist)
public java.lang.String getStateDescription()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |