package data;
public final class BasketEntryValues {
public static final BasketEntryValue ONLY_STOCK_ITEMS = new BasketEntryValue() {
public Value getEntryValue (DataBasketEntry dbe) {
Stock st = (Stock) dbe.getDestination();
if (st == null) {
st = (Stock) dbe.getSource();
}
if (st != null) {
try {
int nCount = ((dbe.getValue() instanceof Number)?
(((Number) dbe.getValue()).intValue()):
(1));
return st.getCatalog (dbe.getOwner()).get (dbe.getSecondaryKey(), null, false).getValue().
multiply (nCount);
}
catch (Throwable t) {
return new IntegerValue (0);
}
}
else {
return new IntegerValue (0);
}
}
};
public static final BasketEntryValue ONLY_CATALOG_ITEMS = new BasketEntryValue() {
public Value getEntryValue (DataBasketEntry dbe) {
try {
return ((CatalogItem) dbe.getValue()).getValue();
}
catch (Throwable t) {
return new IntegerValue (0);
}
}
};
public static final BasketEntryValue COUNT_ITEMS = new BasketEntryValue() {
private IntegerValue m_ivOne = new IntegerValue (1);
public Value getEntryValue (DataBasketEntry dbe) {
return m_ivOne;
}
};
}