Class ByteArrayCustomBuilder

  extended by
All Implemented Interfaces:

public class ByteArrayCustomBuilder
extends Object
implements CustomBuilder

CustomBuilder that creates an OMSourcedElement backed by a ByteArrayDataSource. If you have a payload or header that will consume a lot of space, it may be beneficial to plug in this CustomBuilder. Use this CustomBuilder as a pattern for other CustomBuilders.

Constructor Summary
ByteArrayCustomBuilder(String encoding)
Method Summary
 OMElement create(String namespace, String localPart, OMContainer parent, XMLStreamReader reader, OMFactory factory)
          Create an OMElement for this whole subtree.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ByteArrayCustomBuilder(String encoding)

encoding -
Method Detail


public OMElement create(String namespace,
                        String localPart,
                        OMContainer parent,
                        XMLStreamReader reader,
                        OMFactory factory)
                 throws OMException
Description copied from interface: CustomBuilder
Create an OMElement for this whole subtree. A null is returned if the default StAXBuilder behavior should be used.

Specified by:
create in interface CustomBuilder
reader - The stream reader to read the StAX events from. The data read from this reader always represents plain XML, even if the original document was XOP encoded. The reader optionally implements the DataHandlerReader extension to give the custom builder access to optimized binary data. This is appropriate for custom builders that support DataHandlerReader or in cases where there is no other option than to transfer binary data as base64 encoded character data.

However, if the custom builder interacts with a third party library that supports XOP, it may want to use that encoding to optimize the transfer of binary data. To do so, the custom builder MUST use XOPUtils.getXOPEncodedStream(XMLStreamReader) to get an XOP encoded stream. This guarantees that the original reader is wrapped or unwrapped properly and also that the custom builder correctly gets access to the attachments, regardless of the type of the original reader. In particular, the custom builder MUST NOT attempt to retrieve attachments through the OMAttachmentAccessor that may be implemented by the builder (because this wouldn't work if the builder was created from an XMLStreamReader implementing the DataHandlerReader extension).

The implementation MUST NOT assume that reader is the original reader returned by the StAX implementation. In general, it will be a wrapper around the original reader, e.g. one added by the StAXDialect implementation. If the method requires access to the original parser (e.g. to pass the XMLStreamReader object to another library that uses some special optimizations for particular parser implementations), it SHOULD use XMLStreamReaderUtils.getOriginalXMLStreamReader(XMLStreamReader) to unwrap the reader. If the method solely relies on the conformance of the reader to the StAX specification, it SHOULD NOT attempt to unwrap it.

If the implementation requires both an XOP encoded stream and wants to get access to the original reader, it should invoke XMLStreamReaderUtils.getOriginalXMLStreamReader(XMLStreamReader) after XOPUtils.getXOPEncodedStream(XMLStreamReader).

null or OMElement

Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.