public class ShoppingBasket
extends org.xml.sax.helpers.DefaultHandler
implements org.xml.sax.ContentHandler, java.io.Serializable
Shopping basket
This class is specially designed for usage as a shopping basket for a websiteConstructor and Description |
---|
ShoppingBasket()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addLine()
Add empty order line to this basket
|
void |
addLine(java.util.Map oLine)
Add order line to this basket
Each line has an arbitrary number of named attributes given in the Map passed as parameter
|
void |
addLine(java.lang.String sInputStr,
java.lang.String sDelimiter)
Add order line to this basket
This method adds a line from a string of the form: "attribute1=value1,attribute2=value2,attribute3=value3"
|
void |
characters(char[] ch,
int start,
int length)
Characters.
|
void |
clearLine(int nLine)
Clear all attributes for a line
|
void |
clearProperties()
Clear all global properties
|
boolean |
containsProperty(java.lang.String sKey)
Whether or not this shopping basket contains a given global property
|
int |
countAddresses() |
void |
endElement(java.lang.String uri,
java.lang.String local,
java.lang.String qname) |
void |
error(org.xml.sax.SAXParseException ex)
Error.
|
void |
fatalError(org.xml.sax.SAXParseException ex)
Fatal error.
|
int |
findLine(java.lang.String sAttrKey,
java.lang.Object oAttrValue)
Get the first line that contains an attribute with a given value
|
Address |
getAddress(int nIndex)
Get Address by index
The Address index is the value of ix_address column of k_addresses table
|
Address |
getAddress(java.lang.String sType)
Get Address by type
The Address type is the value of tp_location column of k_addresses table
|
Address[] |
getAddresses()
Get Addresses
The Address type is the value of tp_location column of k_addresses table
|
java.lang.String |
getCustomer()
Get customer identification
|
java.util.HashMap |
getLine(int nLine)
Get order line
|
java.lang.Object |
getLineAttribute(int nLine,
java.lang.String sKey)
Get attribute of a given line
|
java.math.BigDecimal |
getLineBigDecimal(int nLine,
java.lang.String sKey)
Get attribute of a given line casted to java.math.BigDecimal
|
int |
getLineCount()
Count of lines on this basket
|
java.util.Date |
getLineDate(int nLine,
java.lang.String sKey)
Get attribute of a given line casted to java.util.Date
|
java.lang.Integer |
getLineInteger(int nLine,
java.lang.String sKey)
Get attribute of a given line casted to java.lang.Integer
|
java.lang.String |
getLineString(int nLine,
java.lang.String sKey)
Get attribute of a given line casted to String
|
java.lang.Object |
getProperty(java.lang.String sKey)
Get a global property of this basket
|
void |
parse(java.io.File oXMLData,
java.lang.String sEncoding) |
void |
parse(java.lang.String sXMLData) |
void |
putAddress(Address oAddr)
Put an Address into the Shopping basket
If a previous Address of same type or index is already present then it is silently replaced.
|
void |
removeLine(int nLine)
Remove order line from this basket
|
void |
removeProperty(java.lang.String sKey)
Remove a single global property
|
void |
setCustomer(java.lang.String sIdCustomer)
Set customer identification
Customer Id. can be any arbitrary string that uniquely identifies current customer
|
void |
setLineAttribute(int nLine,
java.lang.String sKey,
java.lang.Object oAttr)
Set attribute for a given line
|
void |
setLineAttributes(int nLine,
java.lang.String sInputStr,
java.lang.String sDelimiter)
Set attributes for a given line
|
void |
setProperties(java.util.Map oPropertiesMap)
Set global properties for this basket
|
void |
setProperty(java.lang.String sKey,
java.lang.Object oProperty)
Set global property for this basket
|
void |
startDocument()
Start document.
|
void |
startElement(java.lang.String uri,
java.lang.String local,
java.lang.String raw,
org.xml.sax.Attributes attrs) |
java.math.BigDecimal |
sum(java.lang.String sAttrKey)
Get sum of all line attributes of a given name
|
void |
warning(org.xml.sax.SAXParseException ex)
Warning.
|
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
public Address getAddress(int nIndex)
Get Address by index
The Address index is the value of ix_address column of k_addresses tablepublic Address getAddress(java.lang.String sType)
Get Address by type
The Address type is the value of tp_location column of k_addresses tablepublic Address[] getAddresses()
Get Addresses
The Address type is the value of tp_location column of k_addresses tablepublic int countAddresses()
public void putAddress(Address oAddr) throws java.lang.NullPointerException
Put an Address into the Shopping basket
If a previous Address of same type or index is already present then it is silently replaced.java.lang.NullPointerException
public java.lang.String getCustomer()
public void setCustomer(java.lang.String sIdCustomer)
Set customer identification
Customer Id. can be any arbitrary string that uniquely identifies current customersIdCustomer
- String uniquely identifying the customer owner of this shopping basketpublic java.lang.Object getProperty(java.lang.String sKey)
sKey
- String property namepublic boolean containsProperty(java.lang.String sKey)
sKey
- String property namepublic void setProperty(java.lang.String sKey, java.lang.Object oProperty)
sKey
- String property nameoProperty
- Objectpublic void setProperties(java.util.Map oPropertiesMap)
oPropertiesMap
- Map containing property names as map keys and property values as map valuespublic void clearProperties()
public void removeProperty(java.lang.String sKey)
sKey
- String property namepublic void addLine()
public void addLine(java.util.Map oLine)
Add order line to this basket
Each line has an arbitrary number of named attributes given in the Map passed as parameteroLine
- Map with line attributespublic void addLine(java.lang.String sInputStr, java.lang.String sDelimiter)
Add order line to this basket
This method adds a line from a string of the form: "attribute1=value1,attribute2=value2,attribute3=value3"sInputStr
- StringsDelimiter
- String Delimiter to be used between attribute, in the examle above, a commapublic int getLineCount()
public void removeLine(int nLine)
nLine
- int Line number [0..getLineCount()-1)]public void clearLine(int nLine) throws java.lang.ArrayIndexOutOfBoundsException
nLine
- int Line number [0..getLineCount()-1)]java.lang.ArrayIndexOutOfBoundsException
public java.util.HashMap getLine(int nLine) throws java.lang.ArrayIndexOutOfBoundsException
nLine
- int Line number [0..getLineCount()-1)]java.lang.ArrayIndexOutOfBoundsException
public java.lang.Object getLineAttribute(int nLine, java.lang.String sKey) throws java.lang.ArrayIndexOutOfBoundsException
nLine
- int Line number [0..getLineCount()-1)]sKey
- String attribute namejava.lang.ArrayIndexOutOfBoundsException
public java.lang.String getLineString(int nLine, java.lang.String sKey) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
nLine
- int Line number [0..getLineCount()-1)]sKey
- String attribute namejava.lang.ArrayIndexOutOfBoundsException
java.lang.ClassCastException
public java.math.BigDecimal getLineBigDecimal(int nLine, java.lang.String sKey) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
nLine
- int Line number [0..getLineCount()-1)]sKey
- String attribute namejava.lang.ArrayIndexOutOfBoundsException
java.lang.ClassCastException
public java.util.Date getLineDate(int nLine, java.lang.String sKey) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
nLine
- int Line number [0..getLineCount()-1)]sKey
- String attribute namejava.lang.ArrayIndexOutOfBoundsException
java.lang.ClassCastException
public java.lang.Integer getLineInteger(int nLine, java.lang.String sKey) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.ClassCastException
nLine
- int Line number [0..getLineCount()-1)]sKey
- String attribute namejava.lang.ArrayIndexOutOfBoundsException
java.lang.ClassCastException
public void setLineAttribute(int nLine, java.lang.String sKey, java.lang.Object oAttr) throws java.lang.ArrayIndexOutOfBoundsException
nLine
- int Line number [0..getLineCount()-1)]sKey
- String attribute nameoAttr
- Object attribute valuejava.lang.ArrayIndexOutOfBoundsException
public void setLineAttributes(int nLine, java.lang.String sInputStr, java.lang.String sDelimiter) throws java.lang.ArrayIndexOutOfBoundsException
nLine
- int Line number [0..getLineCount()-1)]sInputStr
- String of the form "attr1=value1,attr2=value2,attr3=value3"sDelimiter
- String Delimiter between pairs of attribute=value (comma in the previous example)java.lang.ArrayIndexOutOfBoundsException
public int findLine(java.lang.String sAttrKey, java.lang.Object oAttrValue)
sKey
- String Attribute keyoAttr
- Object Attribute valuepublic java.math.BigDecimal sum(java.lang.String sAttrKey) throws java.lang.ClassCastException
Get sum of all line attributes of a given name
sAttrKey
- String Atrributes common namejava.lang.ClassCastException
- Attribute values must be of type BigDecimal
or else a ClassCastException is raisedpublic void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void startElement(java.lang.String uri, java.lang.String local, java.lang.String raw, org.xml.sax.Attributes attrs) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String local, java.lang.String qname) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void warning(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
warning
in interface org.xml.sax.ErrorHandler
warning
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
error
in interface org.xml.sax.ErrorHandler
error
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException ex) throws org.xml.sax.SAXException
fatalError
in interface org.xml.sax.ErrorHandler
fatalError
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void parse(java.io.File oXMLData, java.lang.String sEncoding) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
java.io.IOException
org.xml.sax.SAXException
public void parse(java.lang.String sXMLData) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException, java.io.IOException, org.xml.sax.SAXException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
java.io.IOException
org.xml.sax.SAXException