Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.knowgate.hipergate
Class ShoppingBasket

    java.lang.Object
      org.xml.sax.helpers.DefaultHandler
          com.knowgate.hipergate.ShoppingBasket

All Implemented Interfaces:
  java.io.Serializable, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

    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 website
Shopping baskets have 3 main elements:

- Customer identification
- Global properties
- Lines

See Also:
  Serialized Form

Field Summary
`protected static boolean` | `DEFAULT_DYNAMIC_VALIDATION`
`protected static boolean` | `DEFAULT_MEMORY_USAGE`
`protected static boolean` | `DEFAULT_NAMESPACE_PREFIXES`
`protected static boolean` | `DEFAULT_NAMESPACES`
`protected static java.lang.String` | `DEFAULT_PARSER_NAME`
`protected static int` | `DEFAULT_REPETITION`
`protected static boolean` | `DEFAULT_SCHEMA_FULL_CHECKING`
`protected static boolean` | `DEFAULT_SCHEMA_VALIDATION`
`protected static boolean` | `DEFAULT_TAGGINESS`
`protected static boolean` | `DEFAULT_VALIDATION`
`protected static java.lang.String` | `DYNAMIC_VALIDATION_FEATURE_ID`
`protected static java.lang.String` | `NAMESPACE_PREFIXES_FEATURE_ID`
`protected static java.lang.String` | `NAMESPACES_FEATURE_ID`
`protected static java.lang.String` | `SCHEMA_FULL_CHECKING_FEATURE_ID`
`protected static java.lang.String` | `SCHEMA_VALIDATION_FEATURE_ID`
`protected static java.lang.String` | `VALIDATION_FEATURE_ID`

Constructor Summary
`ShoppingBasket()` Default constructor

Method Summary
`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
`protected java.lang.String` | `composeError(java.lang.String type, org.xml.sax.SAXParseException ex)` Compose the error message.
`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.

Methods inherited from class org.xml.sax.helpers.DefaultHandler
`endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.xml.sax.ContentHandler
`endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startPrefixMapping`

Field Detail

### NAMESPACES_FEATURE_ID

    protected static final java.lang.String NAMESPACES_FEATURE_ID

See Also:
  Constant Field Values

### NAMESPACE_PREFIXES_FEATURE_ID

    protected static final java.lang.String NAMESPACE_PREFIXES_FEATURE_ID

See Also:
  Constant Field Values

### VALIDATION_FEATURE_ID

    protected static final java.lang.String VALIDATION_FEATURE_ID

See Also:
  Constant Field Values

### SCHEMA_VALIDATION_FEATURE_ID

    protected static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID

See Also:
  Constant Field Values

### SCHEMA_FULL_CHECKING_FEATURE_ID

    protected static final java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID

See Also:
  Constant Field Values

### DYNAMIC_VALIDATION_FEATURE_ID

    protected static final java.lang.String DYNAMIC_VALIDATION_FEATURE_ID

See Also:
  Constant Field Values

### DEFAULT_PARSER_NAME

    protected static final java.lang.String DEFAULT_PARSER_NAME

See Also:
  Constant Field Values

### DEFAULT_REPETITION

    protected static final int DEFAULT_REPETITION

See Also:
  Constant Field Values

### DEFAULT_NAMESPACES

    protected static final boolean DEFAULT_NAMESPACES

See Also:
  Constant Field Values

### DEFAULT_NAMESPACE_PREFIXES

    protected static final boolean DEFAULT_NAMESPACE_PREFIXES

See Also:
  Constant Field Values

### DEFAULT_VALIDATION

    protected static final boolean DEFAULT_VALIDATION

See Also:
  Constant Field Values

### DEFAULT_SCHEMA_VALIDATION

    protected static final boolean DEFAULT_SCHEMA_VALIDATION

See Also:
  Constant Field Values

### DEFAULT_SCHEMA_FULL_CHECKING

    protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING

See Also:
  Constant Field Values

### DEFAULT_DYNAMIC_VALIDATION

    protected static final boolean DEFAULT_DYNAMIC_VALIDATION

See Also:
  Constant Field Values

### DEFAULT_MEMORY_USAGE

    protected static final boolean DEFAULT_MEMORY_USAGE

See Also:
  Constant Field Values

### DEFAULT_TAGGINESS

    protected static final boolean DEFAULT_TAGGINESS

See Also:
  Constant Field Values

Constructor Detail

### ShoppingBasket

    public ShoppingBasket()

  Default constructor

Method Detail

### getAddress

    public Address getAddress(int nIndex)

  Get Address by index

  The Address index is the value of ix_address column of k_addresses table

  Returns:
    Address object or null if no Address with such index was found
  Since:
    4.0

### getAddress

    public Address getAddress(java.lang.String sType)

  Get Address by type

  The Address type is the value of tp_location column of k_addresses table

  Returns:
    Address object or null if no Address with such type was found
  Since:
    4.0

### getAddresses

    public Address[] getAddresses()

  Get Addresses

  The Address type is the value of tp_location column of k_addresses table

  Returns:
    Array of addresses loaded at ShoppingBasket or null if ShoppingBasket contains no addresses
  Since:
    4.0

### countAddresses

    public int countAddresses()

### putAddress

    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.

  Throws:
    `java.lang.NullPointerException`
  Since:
    4.0

### getCustomer

    public java.lang.String getCustomer()

  Get customer identification

  Returns:
    String uniquely identifying the customer owner of this shopping basket

### setCustomer

    public void setCustomer(java.lang.String sIdCustomer)

  Set customer identification

  Customer Id. can be any arbitrary string that uniquely identifies current customer

  Parameters:
    `sIdCustomer` - String uniquely identifying the customer owner of this shopping basket

### getProperty

    public java.lang.Object getProperty(java.lang.String sKey)

  Get a global property of this basket

  Parameters:
    `sKey` - String property name
  Returns:
    Object or null if there is no property with such name

### containsProperty

    public boolean containsProperty(java.lang.String sKey)

  Whether or not this shopping basket contains a given global property

  Parameters:
    `sKey` - String property name
  Returns:
    boolean

### setProperty

    public void setProperty(java.lang.String sKey,
                            java.lang.Object oProperty)

  Set global property for this basket

  Parameters:
    `sKey` - String property name
    `oProperty` - Object

### setProperties

    public void setProperties(java.util.Map oPropertiesMap)

  Set global properties for this basket

  Parameters:
    `oPropertiesMap` - Map containing property names as map keys and property values as map values

### clearProperties

    public void clearProperties()

  Clear all global properties

### removeProperty

    public void removeProperty(java.lang.String sKey)

  Remove a single global property

  Parameters:
    `sKey` - String property name

### addLine

    public void addLine()

  Add empty order line to this basket

### 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 parameter

  Parameters:
    `oLine` - Map with line attributes

### addLine

    public 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"

  Parameters:
    `sInputStr` - String
    `sDelimiter` - String Delimiter to be used between attribute, in the examle above, a comma

### getLineCount

    public int getLineCount()

  Count of lines on this basket

  Returns:
    int

### removeLine

    public void removeLine(int nLine)

  Remove order line from this basket

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]

### clearLine

    public void clearLine(int nLine)
                   throws java.lang.ArrayIndexOutOfBoundsException

  Clear all attributes for a line

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`

### getLine

    public java.util.HashMap getLine(int nLine)
                              throws java.lang.ArrayIndexOutOfBoundsException

  Get order line

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
  Returns:
    HashMap Line attributes
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`

### getLineAttribute

    public java.lang.Object getLineAttribute(int nLine,
                                             java.lang.String sKey)
                                      throws java.lang.ArrayIndexOutOfBoundsException

  Get attribute of a given line

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
    `sKey` - String attribute name
  Returns:
    Object
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`

### getLineString

    public java.lang.String getLineString(int nLine,
                                          java.lang.String sKey)
                                   throws java.lang.ArrayIndexOutOfBoundsException,
                                          java.lang.ClassCastException

  Get attribute of a given line casted to String

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
    `sKey` - String attribute name
  Returns:
    String
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`
    `java.lang.ClassCastException`

### getLineBigDecimal

    public java.math.BigDecimal getLineBigDecimal(int nLine,
                                                  java.lang.String sKey)
                                           throws java.lang.ArrayIndexOutOfBoundsException,
                                                  java.lang.ClassCastException

  Get attribute of a given line casted to java.math.BigDecimal

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
    `sKey` - String attribute name
  Returns:
    BigDecimal
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`
    `java.lang.ClassCastException`

### getLineDate

    public java.util.Date getLineDate(int nLine,
                                      java.lang.String sKey)
                               throws java.lang.ArrayIndexOutOfBoundsException,
                                      java.lang.ClassCastException

  Get attribute of a given line casted to java.util.Date

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
    `sKey` - String attribute name
  Returns:
    Date
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`
    `java.lang.ClassCastException`

### getLineInteger

    public java.lang.Integer getLineInteger(int nLine,
                                            java.lang.String sKey)
                                     throws java.lang.ArrayIndexOutOfBoundsException,
                                            java.lang.ClassCastException

  Get attribute of a given line casted to java.lang.Integer

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
    `sKey` - String attribute name
  Returns:
    Date
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`
    `java.lang.ClassCastException`

### setLineAttribute

    public void setLineAttribute(int nLine,
                                 java.lang.String sKey,
                                 java.lang.Object oAttr)
                          throws java.lang.ArrayIndexOutOfBoundsException

  Set attribute for a given line

  Parameters:
    `nLine` - int Line number [0..getLineCount()-1)]
    `sKey` - String attribute name
    `oAttr` - Object attribute value
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`

### setLineAttributes

    public void setLineAttributes(int nLine,
                                  java.lang.String sInputStr,
                                  java.lang.String sDelimiter)
                           throws java.lang.ArrayIndexOutOfBoundsException

  Set attributes for a given line

  Parameters:
    `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)
  Throws:
    `java.lang.ArrayIndexOutOfBoundsException`

### findLine

    public int findLine(java.lang.String sAttrKey,
                        java.lang.Object oAttrValue)

  Get the first line that contains an attribute with a given value

  Parameters:
    `sKey` - String Attribute key
    `oAttr` - Object Attribute value
  Returns:
    int Number [0..getLineCount()-1)] of the first line that contains an attribute with the given name and value or -1 if no line attribute matches the given one.

### sum

    public java.math.BigDecimal sum(java.lang.String sAttrKey)
                             throws java.lang.ClassCastException

  Get sum of all line attributes of a given name

  Parameters:
    `sAttrKey` - String Atrributes common name
  Returns:
    BigDecimal Sum of values or zero if no attributes where found
  Throws:
    `java.lang.ClassCastException` - Attribute values must be of type BigDecimal or else a ClassCastException is raised

### startDocument

    public void startDocument()
                       throws org.xml.sax.SAXException

  Start document.

  Specified by:
    `startDocument` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `startDocument` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### characters

    public void characters(char[] ch,
                           int start,
                           int length)
                    throws org.xml.sax.SAXException

  Characters.

  Specified by:
    `characters` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `characters` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### startElement

    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

  Specified by:
    `startElement` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `startElement` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### endElement

    public void endElement(java.lang.String uri,
                           java.lang.String local,
                           java.lang.String qname)
                    throws org.xml.sax.SAXException

  Specified by:
    `endElement` in interface `org.xml.sax.ContentHandler`
  Overrides:
    `endElement` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### warning

    public void warning(org.xml.sax.SAXParseException ex)
                 throws org.xml.sax.SAXException

  Warning.

  Specified by:
    `warning` in interface `org.xml.sax.ErrorHandler`
  Overrides:
    `warning` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### error

    public void error(org.xml.sax.SAXParseException ex)
               throws org.xml.sax.SAXException

  Error.

  Specified by:
    `error` in interface `org.xml.sax.ErrorHandler`
  Overrides:
    `error` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### fatalError

    public void fatalError(org.xml.sax.SAXParseException ex)
                    throws org.xml.sax.SAXException

  Fatal error.

  Specified by:
    `fatalError` in interface `org.xml.sax.ErrorHandler`
  Overrides:
    `fatalError` in class `org.xml.sax.helpers.DefaultHandler`
  Throws:
    `org.xml.sax.SAXException`

### composeError

    protected java.lang.String composeError(java.lang.String type,
                                            org.xml.sax.SAXParseException ex)

  Compose the error message.

### parse

    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

  Throws:
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`
    `java.lang.ClassNotFoundException`
    `java.io.IOException`
    `org.xml.sax.SAXException`

### parse

    public void parse(java.lang.String sXMLData)
               throws java.lang.InstantiationException,
                      java.lang.IllegalAccessException,
                      java.lang.ClassNotFoundException,
                      java.io.IOException,
                      org.xml.sax.SAXException

  Throws:
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`
    `java.lang.ClassNotFoundException`
    `java.io.IOException`
    `org.xml.sax.SAXException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD