Class BlockImpl<T,​C>

  • All Implemented Interfaces:
    org.apache.axiom.om.OMDataSource, org.apache.axiom.om.OMDataSourceExt, Block<T,​C>
    Direct Known Subclasses:
    DataSourceBlockImpl, JAXBBlockImpl, OMBlockImpl, SOAPEnvelopeBlockImpl, SourceBlockImpl, XMLStringBlockImpl

    public abstract class BlockImpl<T,​C>
    extends org.apache.axiom.om.ds.AbstractOMDataSource
    implements Block<T,​C>
    BlockImpl Abstract Base class for various Block Implementations.

    The base class takes care of controlling the transformations between BusinessObject, XMLStreamReader and SOAPElement A derived class must minimally define the following: _getBOFromReader _getReaderFromBO _outputFromBO

    In addtion, the derived class may want to override the following: _getBOFromBO ...if the BusinessObject is consumed when read (i.e. it is an InputSource)

    The derived classes don't have direct access to the instance data. This ensures that BlockImpl controls the transformations.

    • Field Detail

      • busObject

        protected T busObject
      • busContext

        protected C busContext
      • omElement

        protected org.apache.axiom.om.OMElement omElement
      • qName

        protected QName qName
      • consumed

        protected boolean consumed
    • Constructor Detail

      • BlockImpl

        protected BlockImpl​(T busObject,
                            C busContext,
                            QName qName,
                            BlockFactory factory)
        A Block has the following components
        Parameters:
        busObject -
        busContext - or null
        qName - or null if unknown
        factory - that creates the Block
      • BlockImpl

        protected BlockImpl​(org.apache.axiom.om.OMElement omElement,
                            C busContext,
                            QName qName,
                            BlockFactory factory)
        A Block has the following components
        Parameters:
        reader -
        busContext - or null
        qName - or null if unknown
        factory - that creates the Block
      • BlockImpl

        protected BlockImpl​(C busContext,
                            org.apache.axiom.om.OMElement omElement,
                            QName qName,
                            BlockFactory factory)
    • Method Detail

      • getBlockFactory

        public final BlockFactory getBlockFactory()
        Description copied from interface: Block
        Get BlockFactory
        Specified by:
        getBlockFactory in interface Block<T,​C>
        Returns:
        BlockFactory that created the Block
      • getBusinessContext

        public final Object getBusinessContext()
        Description copied from interface: Block
        GetBusinesContext Some business objects have an associated context object (i.e. JAXBContext)
        Specified by:
        getBusinessContext in interface Block<T,​C>
        Returns:
        Context Object or null
      • getParent

        public final Message getParent()
        Description copied from interface: Block
        Get the Message associated with this block
        Specified by:
        getParent in interface Block<T,​C>
        Returns:
        Message
      • setParent

        public void setParent​(Message p)
        Description copied from interface: Block
        Set the Message associated with this block (This method is intended to be called by the Message Implementation only)
        Specified by:
        setParent in interface Block<T,​C>
      • setQName

        protected final void setQName​(QName qName)
        This method is intended for derived objects to set the qName
        Parameters:
        qName -
      • isConsumed

        public final boolean isConsumed()
        Description copied from interface: Block
        isConsumed Return true if the block is consumed. Once consumed, the information in the block is no longer available.
        Specified by:
        isConsumed in interface Block<T,​C>
        Returns:
        true if the block is consumed (a method was called with consume=true)
      • setConsumed

        public final void setConsumed​(boolean consume)
        Once consumed, all instance data objects are nullified to prevent subsequent access
        Parameters:
        consume -
      • isQNameAvailable

        public final boolean isQNameAvailable()
        Specified by:
        isQNameAvailable in interface Block<T,​C>
        Returns:
        If QName is available without doing an expensive parse of the business object, then return true Otherwise return false Note: This method should be used in situations where it would be nice to know the qname (like logging or a special check) but we don't want to cause an ill-performant parse.
      • isBusinessObject

        protected final boolean isBusinessObject()
        Returns:
        true if the representation of the block is currently a business object. Derived classes may use this information to get information in a performant way.
      • traceString

        public final String traceString​(String indent)
        Description copied from interface: Block
        Get a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.
        Specified by:
        traceString in interface Block<T,​C>
        Returns:
        String containing trace information
      • _getBOFromBO

        protected T _getBOFromBO​(T busObject,
                                 C busContext,
                                 boolean consume)
        The default implementation is to return the business object. A derived block may want to override this class if the business object is consumed when read (thus the dervived block may want to make a buffered copy) (An example use case for overriding this method is the businessObject is an InputSource)
        Parameters:
        busObject -
        busContext -
        consume -
        Returns:
      • _getBOFromOM

        protected abstract T _getBOFromOM​(org.apache.axiom.om.OMElement omElement,
                                          C busContext)
                                   throws XMLStreamException,
                                          WebServiceException
        Default method for getting business object from OM. Derived classes may override this method to get the business object from a data source.
        Parameters:
        om -
        busContext -
        Returns:
        Business Object
        Throws:
        XMLStreamException
        WebServiceException
      • _outputFromOM

        protected final void _outputFromOM​(org.apache.axiom.om.OMElement omElement,
                                           XMLStreamWriter writer,
                                           boolean consume)
                                    throws XMLStreamException
        Output OMElement contents to a Writer. The default implementation is probably sufficient for most derived classes.
        Parameters:
        om -
        writer -
        Throws:
        XMLStreamException
      • copy

        public org.apache.axiom.om.OMDataSourceExt copy()
                                                 throws org.apache.axiom.om.OMException
        Specified by:
        copy in interface org.apache.axiom.om.OMDataSourceExt
        Overrides:
        copy in class org.apache.axiom.om.ds.AbstractOMDataSource
        Throws:
        org.apache.axiom.om.OMException