info.aduna.gee.publication.simpleshop
Class Product

java.lang.Object
  extended by info.aduna.gee.publication.simpleshop.Product

public class Product
extends Object


Field Summary
 int count
           
 String description
           
 String id
           
 WProperties options
           
 double price
           
 boolean required
           
 String unitDescription
           
 
Constructor Summary
Product(InputStream serialized)
          Create a Product from its serialized version.
Product(String serialized)
          Create a Product from its serialized version.
Product(String id, String description, String unitDescription, double price, WProperties options, boolean required)
          Create a new Product.
 
Method Summary
protected  String _base64Encode(String string)
          Create a Base64-encoded version of a string
 boolean equals(Object other)
          Two products are equal when their id's are equal and their selected options are the same.
 String getOptionsString()
          Get the selected options as a String.
 double getPrice()
          Get the total price of the product, depending on the selected options.
static String getPriceString(double price)
          Get a String representing a price.
 boolean hasVolumeDiscount()
           
 String toShortString()
          Creates Base64-encoded a String representation of this Product that contains only the essential information for the server-side to work with.
 String toString()
          Creates a Base64-encoded String representation of this Product that contains all information about the Product.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

public String id

description

public String description

unitDescription

public String unitDescription

price

public double price

count

public int count

required

public boolean required

options

public WProperties options
Constructor Detail

Product

public Product(String id,
               String description,
               String unitDescription,
               double price,
               WProperties options,
               boolean required)
Create a new Product.

Parameters:
id - the ID of the Product in the database
description - a description of the Product
unitDescription - a description of the unit this Product ships in
price - the price of this Product

Product

public Product(String serialized)
        throws IOException
Create a Product from its serialized version.

Parameters:
serialized - an String containing a Base64-encoded saved WProperties
Throws:
IOException
See Also:
Product(java.io.InputStream)

Product

public Product(InputStream serialized)
        throws IOException
Create a Product from its serialized version.

Parameters:
serialized - an InputStream containing a Base64-encoded saved WProperties
Throws:
IOException
See Also:
WProperties
Method Detail

hasVolumeDiscount

public boolean hasVolumeDiscount()

getPrice

public double getPrice()
Get the total price of the product, depending on the selected options. The price is rounded to two digits.


getPriceString

public static String getPriceString(double price)
Get a String representing a price. The price is rounded to two digits and padded with zeros as needed


getOptionsString

public String getOptionsString()
Get the selected options as a String.


toString

public String toString()
Creates a Base64-encoded String representation of this Product that contains all information about the Product. Use this when communicating from server to client.

Overrides:
toString in class Object

toShortString

public String toShortString()
Creates Base64-encoded a String representation of this Product that contains only the essential information for the server-side to work with. Use this when sending data from client to server.


_base64Encode

protected String _base64Encode(String string)
Create a Base64-encoded version of a string

Parameters:
string - the String to encode
Returns:
a Base64-encoded version of the string

equals

public boolean equals(Object other)
Two products are equal when their id's are equal and their selected options are the same.

Overrides:
equals in class Object


Copyright © 1997-2008 Aduna. All Rights Reserved.