|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.paneris.melati.shopping.ShoppingTrolley
public abstract class ShoppingTrolley
A Shopping Trolley stores information in the user's Shopping Trolley.
It does this by storing itself in the session.
For this reason, the constructors are private, and you will be expected always to get the Shopping Trolley using getInstance();
Usage example:
ShoppingTrolley trolley = ShoppingTrolley.getInstance(Melati melati); context.put("trolley", trolley);
Field Summary | |
---|---|
protected java.lang.String |
address
|
MelatiShoppingConfig |
config
|
protected java.lang.String |
country
|
protected java.lang.String |
county
|
protected java.lang.String |
email
|
protected boolean |
hasDetails
|
protected java.util.Locale |
locale
|
org.melati.Melati |
melati
|
protected java.lang.String |
message
|
protected java.lang.String |
name
|
protected java.lang.String |
postcode
|
protected java.lang.String |
tel
|
protected java.lang.String |
town
|
static double |
VAT_PERCENT_TIMES_TEN
|
Constructor Summary | |
---|---|
ShoppingTrolley()
|
Method Summary | |
---|---|
java.lang.String |
abandonURL()
|
void |
addItem(ShoppingTrolleyItem item)
Add an item to the trolley. |
abstract void |
assertLogin(org.melati.Melati melatiIn)
Do something to force users to login. |
java.lang.String |
baseURL()
|
void |
configureRequest(org.melati.Melati melatiIn)
This is done for each request, so anything special that needs to be done can be put in here |
abstract void |
confirmPayment(org.melati.Melati melatiIn)
Confirm payment of this trolley. |
java.lang.String |
confirmURL()
|
java.lang.String |
detailsURL()
|
java.lang.String |
displayCurrency(double value)
Format a number in the locale currency. |
java.lang.String |
displayCurrency(java.lang.Double value)
Format a number in the locale currency. |
java.lang.String |
getCountry()
Get the country. |
java.lang.String |
getCounty()
Get the county. |
java.lang.String |
getDeliveryAddress()
Get the address. |
java.lang.String |
getDeliveryDisplay()
Format the delivery value for display. |
abstract double |
getDeliveryValue()
You need to provide some mechanism for calculating the delivery value for the order (item delivery values are calculated individually. |
abstract double |
getDiscountRate()
If you want to apply a discount to this order, do it here. |
java.lang.String |
getDiscountRateDisplay()
Display the discount (if present). |
double |
getDiscountValue()
Work out the value of the discout applied to this order (returns a negative value). |
java.lang.String |
getDiscountValueDisplay()
Format the discount value for display. |
java.lang.String |
getEmail()
Get the email address. |
static ShoppingTrolley |
getInstance(org.melati.Melati melati,
MelatiShoppingConfig config)
Returns the single instance, creating one if it can't be found. |
ShoppingTrolleyItem |
getItem(java.lang.Integer id)
Get an item from the trolley. |
java.util.Enumeration |
getItems()
Get the items from the trolley. |
abstract java.util.Locale |
getLocale()
Get the Locale for this trolley. |
java.lang.String |
getMessage()
Get the delivery message. |
java.lang.String |
getName()
Get the name. |
java.lang.String |
getPostcode()
Get the postcode. |
java.lang.String |
getTel()
Get the telephone number. |
double |
getTotalDeliveryValue()
The delivery charge for the order is the sum of the charges on the items and an overall charge. |
double |
getTotalValue()
Calculate the total value of this order. |
java.lang.String |
getTotalValueDisplay()
Format the total order value for display. |
java.lang.String |
getTotalValuePence()
Format the total order value in pence, typically ecomerce sites accept the values in pence not pounds. |
java.lang.String |
getTown()
Get the town. |
double |
getValue()
Calculate the value of the items in the trolley. |
java.lang.String |
getValueDisplay()
Format the order value for display. |
java.lang.String |
getVATDisplay()
Format the vat value for display. |
double |
getVATValue()
Calculate the VAT value of the order. |
abstract boolean |
hasDelivery()
Provide a mechanism for working out if this order should include a delivery charge. |
boolean |
hasDetails()
Have we entered any personal information. |
abstract boolean |
hasDiscount()
Provide a mechanism for working out if this order should include a discount. |
abstract boolean |
hasVAT()
Provide a mechanism for working out if this order should include VAT (default should be true). |
protected void |
initialise(org.melati.Melati melatiIn,
MelatiShoppingConfig configIn)
Private Constructor to build an empty ShoppingTrolley |
void |
initialise(org.melati.Melati melatiIn,
MelatiShoppingConfig configIn,
java.lang.Integer id)
Public Constructor to build a trolley from some id. |
boolean |
isEmpty()
Have we got anything in the trolley. |
abstract void |
load(java.lang.Integer id)
Load a trolley from something persistent. |
static java.lang.String |
name()
Return the name of the trolley (for storing in the session). |
ShoppingTrolleyItem |
newItem(java.lang.Integer id,
java.lang.String description,
java.lang.Double price)
Create an item and put it in the Trolley. |
static ShoppingTrolley |
newTrolley(MelatiShoppingConfig config)
|
java.lang.String |
paidURL()
|
void |
remove(org.melati.Melati melatiIn)
Remove any trolley from the session. |
void |
removeItem(ShoppingTrolleyItem item)
Remove an item from the trolley. |
static double |
roundTo2dp(double num)
|
abstract void |
save()
Save a trolley to something persistent. |
void |
setCountry(java.lang.String a)
Set the country. |
void |
setCounty(java.lang.String a)
Set the county. |
abstract void |
setDefaultDetails(org.melati.Melati melatiIn)
Set the user's detault details into this trolley. |
void |
setDeliveryAddress(java.lang.String a)
Set the address. |
void |
setEmail(java.lang.String a)
Set the email address. |
void |
setFromForm(org.melati.Melati melati)
Set values from form fileds. |
void |
setLocale(java.util.Locale locale)
Set the Locale for this trolley. |
void |
setMessage(java.lang.String a)
Set the delivery message. |
void |
setName(java.lang.String a)
Set the name. |
void |
setPostcode(java.lang.String a)
Set the postcode. |
void |
setTel(java.lang.String a)
Set the telephone number. |
void |
setTown(java.lang.String a)
Set the town. |
java.lang.String |
updateURL()
|
java.lang.String |
viewURL()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Locale locale
protected java.lang.String address
protected java.lang.String name
protected java.lang.String tel
protected java.lang.String town
protected java.lang.String county
protected java.lang.String country
protected java.lang.String postcode
protected java.lang.String message
protected java.lang.String email
protected boolean hasDetails
public static final double VAT_PERCENT_TIMES_TEN
public MelatiShoppingConfig config
public org.melati.Melati melati
Constructor Detail |
---|
public ShoppingTrolley()
Method Detail |
---|
protected void initialise(org.melati.Melati melatiIn, MelatiShoppingConfig configIn)
public void initialise(org.melati.Melati melatiIn, MelatiShoppingConfig configIn, java.lang.Integer id) throws org.melati.util.InstantiationPropertyException
org.melati.util.InstantiationPropertyException
public void remove(org.melati.Melati melatiIn)
public static ShoppingTrolley getInstance(org.melati.Melati melati, MelatiShoppingConfig config) throws org.melati.util.InstantiationPropertyException
org.melati.util.InstantiationPropertyException
public static ShoppingTrolley newTrolley(MelatiShoppingConfig config) throws org.melati.util.InstantiationPropertyException
org.melati.util.InstantiationPropertyException
public abstract java.util.Locale getLocale()
public void setLocale(java.util.Locale locale)
public abstract void confirmPayment(org.melati.Melati melatiIn)
public abstract void load(java.lang.Integer id) throws org.melati.util.InstantiationPropertyException
org.melati.util.InstantiationPropertyException
public abstract void save()
public void configureRequest(org.melati.Melati melatiIn)
public abstract void assertLogin(org.melati.Melati melatiIn)
public abstract void setDefaultDetails(org.melati.Melati melatiIn)
public static java.lang.String name()
public java.util.Enumeration getItems()
public boolean isEmpty()
public boolean hasDetails()
public ShoppingTrolleyItem getItem(java.lang.Integer id)
public void removeItem(ShoppingTrolleyItem item)
public void addItem(ShoppingTrolleyItem item)
public ShoppingTrolleyItem newItem(java.lang.Integer id, java.lang.String description, java.lang.Double price) throws org.melati.util.InstantiationPropertyException
id
- description
- price
-
org.melati.util.InstantiationPropertyException
public double getValue()
public java.lang.String getValueDisplay()
public double getTotalValue()
public java.lang.String getTotalValueDisplay()
public java.lang.String getTotalValuePence()
public abstract boolean hasDelivery()
public abstract double getDeliveryValue()
public double getTotalDeliveryValue()
public java.lang.String getDeliveryDisplay()
public abstract boolean hasDiscount()
public abstract double getDiscountRate()
public double getDiscountValue()
public java.lang.String getDiscountRateDisplay()
public java.lang.String getDiscountValueDisplay() throws java.lang.Exception
java.lang.Exception
public abstract boolean hasVAT()
public double getVATValue()
public java.lang.String getVATDisplay()
public void setFromForm(org.melati.Melati melati)
melati
- public void setDeliveryAddress(java.lang.String a)
public java.lang.String getDeliveryAddress()
public void setName(java.lang.String a)
public java.lang.String getName()
public void setEmail(java.lang.String a)
public java.lang.String getEmail()
public void setPostcode(java.lang.String a)
public java.lang.String getPostcode()
public void setTel(java.lang.String a)
public java.lang.String getTel()
public void setTown(java.lang.String a)
public java.lang.String getTown()
public void setCounty(java.lang.String a)
public java.lang.String getCounty()
public void setCountry(java.lang.String a)
public java.lang.String getCountry()
public void setMessage(java.lang.String a)
public java.lang.String getMessage()
public java.lang.String displayCurrency(double value)
public java.lang.String displayCurrency(java.lang.Double value)
public java.lang.String baseURL()
public java.lang.String viewURL()
public java.lang.String detailsURL()
public java.lang.String confirmURL()
public java.lang.String abandonURL()
public java.lang.String updateURL()
public java.lang.String paidURL()
public static double roundTo2dp(double num)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |