pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.component.shop.model
Class Price

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.component.shop.model.Price
All Implemented Interfaces:
java.io.Serializable, JDOMable

@Entity(name="Price")
public class Price
extends AbstractBasicEntity
implements JDOMable

represents a Price in the shop's model.

Version:
$Revision: 1557 $
Author:
Thomas Weber, Christian Schatt, Daniel Dietz
See Also:
Serialized Form

Nested Class Summary
static class Price.IncomparablePricesException
          exception identifying errors during price comparison.
 
Constructor Summary
protected Price()
          Deprecated. 
  Price(TaxGroup t, long a)
          creates a Price with the given sales tax and amount.
  Price(TaxGroup t, long a, Status s)
          creates a Price with the given sales tax, amount and status.
  Price(TaxGroup t, java.lang.String a)
          creates a Price with the given sales tax and amount.
  Price(TaxGroup t, java.lang.String a, Status s)
          creates a Price with the given sales tax, amount and status.
 
Method Summary
 boolean availableForOrderSize(int a)
          returns whether the Price is available for the given order size.
 org.jdom.Element deserializeToJDOM()
          returns a JDOM representation of the Price.
 long getAmount()
          returns the amount of the Price.
 java.util.Currency getCurrency()
          returns the Currency of the Price.
 java.lang.Integer getMaxOrderSize()
          returns the maximum amount of items the price is valid for or null, if no maximum is set.
 java.lang.Integer getMinOrderSize()
          returns the minimal amount of items needed to get the price.
 java.util.Set<java.lang.Long> getRoleIds()
          returns the ids of the roles that are assigned to the price.
 java.util.Set<Role> getRoles()
          returns a set of roles for whose members the price is available for.
 Status getStatus()
          returns the status of the price.
 TaxGroup getTaxGroup()
          returns the sales tax of the Price.
 boolean isCheaperThan(Price price)
          returns whether this Price is cheaper than the given Price.
 boolean isMoreExpensiveThan(Price price)
          returns whether this Price is more expensive than the given Price.
 boolean isNetBased()
          returns the netBased flag of the Price.
 void setAmount(long a)
          Sets the amount of the Price.
 void setAmount(java.lang.String a)
          Sets the amount of the Price.
 void setMaxOrderSize(java.lang.Integer a)
          sets the maximum amount of items the price is valid for.
 void setMinOrderSize(java.lang.Integer a)
          sets the minimal amount of items needed to get the price.
 void setRoles(java.util.Set<Role> r)
          sets the roles for whose members the price is available for.
 void setStatus(Status s)
          sets the status of the price.
 void setTaxGroup(TaxGroup t)
          sets the sales tax of the Price.
 net.sf.json.JSONObject toJSON()
          returns a JSONObject representing the Price.
static java.lang.String toPriceString(long a, java.util.Currency c)
          returns the given long a as a price string.
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, equals, getFullQualifiedClassNameJAXB, getId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Price

@Deprecated
protected Price()
Deprecated. 

used by HibernateTM.


Price

public Price(TaxGroup t,
             long a)
creates a Price with the given sales tax and amount.

Parameters:
t - the sales tax
a - the amount

Price

public Price(TaxGroup t,
             java.lang.String a)
creates a Price with the given sales tax and amount.

Parameters:
t - the sales tax
a - the amount as a String

Price

public Price(TaxGroup t,
             long a, Status s)
creates a Price with the given sales tax, amount and status.

Parameters:
t - the sales tax
a - the amount
s - the status

Price

public Price(TaxGroup t,
             java.lang.String a, Status s)
creates a Price with the given sales tax, amount and status.

Parameters:
t - the sales tax
a - the amount as a String
s - the status
Method Detail

getCurrency

public final java.util.Currency getCurrency()
returns the Currency of the Price.

Returns:
the Currency of the Price

isNetBased

public final boolean isNetBased()
returns the netBased flag of the Price.

Returns:
the netBased flag of the Price

getAmount

public final long getAmount()
returns the amount of the Price.

Returns:
the amount of the Price

setAmount

public final void setAmount(long a)
Sets the amount of the Price.

Parameters:
a - the amount of the Price

setAmount

public final void setAmount(java.lang.String a)
Sets the amount of the Price.

Parameters:
a - the amount of the Price as String
Throws:
java.lang.NumberFormatException

getTaxGroup

public final TaxGroup getTaxGroup()
returns the sales tax of the Price.

Returns:
the sales tax of the Price

setTaxGroup

public final void setTaxGroup(TaxGroup t)
sets the sales tax of the Price.

Parameters:
t - the sales tax in percent

getRoles

public final java.util.Set<Role> getRoles()
returns a set of roles for whose members the price is available for.

Returns:
a set of roles for whose members the price is available for

setRoles

public final void setRoles(java.util.Set<Role> r)
sets the roles for whose members the price is available for.

Parameters:
r - the roles to set

getRoleIds

public final java.util.Set<java.lang.Long> getRoleIds()
returns the ids of the roles that are assigned to the price.

use: assorter-load in administration

Returns:
the ids of the roles

getMinOrderSize

public final java.lang.Integer getMinOrderSize()
returns the minimal amount of items needed to get the price.

Returns:
the minimal amount

setMinOrderSize

public final void setMinOrderSize(java.lang.Integer a)
sets the minimal amount of items needed to get the price.

Parameters:
a - the minimal amount

getMaxOrderSize

public final java.lang.Integer getMaxOrderSize()
returns the maximum amount of items the price is valid for or null, if no maximum is set.

Returns:
the maximum amount of items or null, if no maximum is set

setMaxOrderSize

public final void setMaxOrderSize(java.lang.Integer a)
sets the maximum amount of items the price is valid for.

Parameters:
a - the maximum amount (may be null)

availableForOrderSize

public final boolean availableForOrderSize(int a)
returns whether the Price is available for the given order size.

Parameters:
a - the order size
Returns:
true, if and only if, the Price is available for the given order size. Otherwise false.

getStatus

public final Status getStatus()
returns the status of the price.

Returns:
the status

setStatus

public final void setStatus(Status s)
sets the status of the price.

Parameters:
s - the status to set

isCheaperThan

public final boolean isCheaperThan(Price price)
returns whether this Price is cheaper than the given Price.

Parameters:
price - the price to check against
Returns:
true, if and only if this Price is cheaper than the given Price. Otherwise false

isMoreExpensiveThan

public final boolean isMoreExpensiveThan(Price price)
returns whether this Price is more expensive than the given Price.

Parameters:
price - the price to check against
Returns:
true, if and only if this Price is more expensive than the given Price. Otherwise false

deserializeToJDOM

public org.jdom.Element deserializeToJDOM()
returns a JDOM representation of the Price.

Specified by:
deserializeToJDOM in interface JDOMable
Returns:
a JDOM representation of the Price
See Also:
JDOMable.deserializeToJDOM()

toJSON

public final net.sf.json.JSONObject toJSON()
returns a JSONObject representing the Price.

Returns:
a JSONObject representing the Price

toPriceString

public static java.lang.String toPriceString(long a,
                                             java.util.Currency c)
returns the given long a as a price string.

If "defaultFractionDigits" of the given currency is greater than 0, "strRep" (strRep = Long.toString(a)) is expanded with leading '0's, if strRep.length() is lesser than or equal to "defaultFractionDigits". After that, a '.' (decimal point) is inserted in strRep at (strRep.length() - "defaultFractionDigits").

Parameters:
a - the amount
c - the currency
Returns:
the given amount a as a price string