Class ByteArrayCustomBuilder
- java.lang.Object
-
- org.apache.axiom.om.ds.custombuilder.ByteArrayCustomBuilder
-
- All Implemented Interfaces:
CustomBuilder
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
Constructors Constructor Description ByteArrayCustomBuilder(String encoding)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OMElementcreate(String namespace, String localPart, OMContainer parent, XMLStreamReader reader, OMFactory factory)Create an OMElement for this whole subtree.
-
-
-
Constructor Detail
-
ByteArrayCustomBuilder
public ByteArrayCustomBuilder(String encoding)
Constructor- Parameters:
encoding-
-
-
Method Detail
-
create
public OMElement create(String namespace, String localPart, OMContainer parent, XMLStreamReader reader, OMFactory factory) throws OMException
Description copied from interface:CustomBuilderCreate an OMElement for this whole subtree. A null is returned if the default StAXBuilder behavior should be used.- Specified by:
createin interfaceCustomBuilderreader- 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 theDataHandlerReaderextension to give the custom builder access to optimized binary data. This is appropriate for custom builders that supportDataHandlerReaderor 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 theOMAttachmentAccessorthat may be implemented by the builder (because this wouldn't work if the builder was created from anXMLStreamReaderimplementing theDataHandlerReaderextension).The implementation MUST NOT assume that
readeris the original reader returned by the StAX implementation. In general, it will be a wrapper around the original reader, e.g. one added by theStAXDialectimplementation. If the method requires access to the original parser (e.g. to pass theXMLStreamReaderobject to another library that uses some special optimizations for particular parser implementations), it SHOULD useXMLStreamReaderUtils.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)afterXOPUtils.getXOPEncodedStream(XMLStreamReader).- Returns:
- null or OMElement
- Throws:
OMException
-
-