net.sourceforge.saxadapter.examples.commerce
Class XCBLResponseWriter

java.lang.Object
  |
  +--net.sourceforge.saxadapter.examples.commerce.XCBLResponseWriter
All Implemented Interfaces:
SAXTagHandler

public class XCBLResponseWriter
extends java.lang.Object
implements SAXTagHandler

This class creates an XCBL OrderResponse document from the corresponding Order document presented in the form of a SAX event stream

Author:
Mark Priest

Inner Class Summary
(package private)  class XCBLResponseWriter.BuyerPartyTagHandler
          This class buffers the BuyerParty info since it appears in a different order in the response than in the Order
(package private)  class XCBLResponseWriter.IgnoreTagHandler
          This handler causes the OrderParty tag to be ignored, but not its child tags, which are the BuyerParety and SellerParty tags, that need to be in the response
(package private)  class XCBLResponseWriter.ItemDetailTagHandler
          This class writes out the original line item info along with a hard-coded approval response
(package private)  class XCBLResponseWriter.OrderDateHandler
          This handler writes out the response type after the date
(package private)  class XCBLResponseWriter.OrderHeaderTagHandler
          This handler adds the response type and response code values to the incoming order header info
(package private)  class XCBLResponseWriter.OrderResponseHandler
          This handlers takes care of adding the appropriate response references
(package private)  class XCBLResponseWriter.OrderSummaryTagHandler
          This class formats the correct OrderReponse summary section
(package private)  class XCBLResponseWriter.SellerPartyTagHandler
          This handler writes out the Seller info and then the buffered buyer info so that they are in the correct (but reversed) order in the response
 
Field Summary
(package private)  SAXAdapter m_adapter
           
 
Constructor Summary
XCBLResponseWriter(SAXAdapter argAdapter)
           
 
Method Summary
 java.lang.StringBuffer formatDate()
          This method returns a Date formatted according to the XCBL spec
 java.lang.String getMappedTagName(java.lang.String argTagName)
          Returns the name change that applies to tags that are copied to the response with a simple name change
 java.lang.StringBuffer getNextOrderNumber()
          This method returns a unique order number for each new order This implementation is overly simplistic and resets to zero each time the writer is instantiated
 void onEndTag(java.lang.String argTagNamespace, java.lang.String argLocalTagName, java.lang.String argQName, java.util.Map argContext, NamespaceContext argNamespaceContext)
          Called by the SAXAdapter when an end tag, for which this callback interface has been registered, has been encountered.
 void onStartTag(java.lang.String argTagNamespace, java.lang.String argLocalTagName, java.lang.String argQName, org.xml.sax.Attributes argAttributes, java.lang.StringBuffer argText, java.util.Map argContext, NamespaceContext argNamespaceContext)
          Called by the SAXAdapter when a start tag, for which this callback interface has been registered, has been encountered.
 void setWriter(java.io.Writer argOut)
          Sets the writer to be used to construct the response
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_adapter

SAXAdapter m_adapter
Constructor Detail

XCBLResponseWriter

public XCBLResponseWriter(SAXAdapter argAdapter)
Method Detail

getNextOrderNumber

public java.lang.StringBuffer getNextOrderNumber()
This method returns a unique order number for each new order This implementation is overly simplistic and resets to zero each time the writer is instantiated
Returns:
the next order number

formatDate

public java.lang.StringBuffer formatDate()
This method returns a Date formatted according to the XCBL spec
Returns:
the formatted date

setWriter

public void setWriter(java.io.Writer argOut)
Sets the writer to be used to construct the response
Parameters:
argOut - the Writer to which to write the response

getMappedTagName

public java.lang.String getMappedTagName(java.lang.String argTagName)
Returns the name change that applies to tags that are copied to the response with a simple name change
Parameters:
argTagName - the name of the original order tag
Returns:
the name of the corresponding element in the reponse

onStartTag

public void onStartTag(java.lang.String argTagNamespace,
                       java.lang.String argLocalTagName,
                       java.lang.String argQName,
                       org.xml.sax.Attributes argAttributes,
                       java.lang.StringBuffer argText,
                       java.util.Map argContext,
                       NamespaceContext argNamespaceContext)
                throws org.xml.sax.SAXException
Description copied from interface: SAXTagHandler
Called by the SAXAdapter when a start tag, for which this callback interface has been registered, has been encountered.
Specified by:
onStartTag in interface SAXTagHandler
Following copied from interface: net.sourceforge.saxadapter.SAXTagHandler
Parameters:
argTagNamespace - namespace URI of tag
argLocalTagName - unqualified tag name
argQName - qualified name of tag
argAttributes - tag attributes
argText - a StringBuffer that contains the text between the start and end tags.
argContext - the Map that represents parsing context. This context must be understood by each handler
argNamespaceContext - an interface that allows the handler to access namespace data associated with the current parsing state
Throws:
org.xml.sax.SAXException -  

onEndTag

public void onEndTag(java.lang.String argTagNamespace,
                     java.lang.String argLocalTagName,
                     java.lang.String argQName,
                     java.util.Map argContext,
                     NamespaceContext argNamespaceContext)
              throws org.xml.sax.SAXException
Description copied from interface: SAXTagHandler
Called by the SAXAdapter when an end tag, for which this callback interface has been registered, has been encountered.
Specified by:
onEndTag in interface SAXTagHandler
Following copied from interface: net.sourceforge.saxadapter.SAXTagHandler
Parameters:
argTagNamespace - namespace URI of tag
argLocalTagName - unqualified tag name
argQName - qualified tag name
argContext - the Map that represents parsing context. This context must be understood by each handler
argNamespaceContext - an interface that allows the handler to access namespace data associated with the current parsing state
Throws:
org.xml.sax.SAXException -