Class XMLBinaryDataCollectionMapping

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​Session,​XMLUnmarshaller,​XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping, org.eclipse.persistence.internal.oxm.mappings.XMLConverterMapping<XMLMarshaller,​Session,​XMLUnmarshaller>, ContainerMapping, ArrayCollectionMapping, XMLMapping, XMLNillableMapping

    public class XMLBinaryDataCollectionMapping
    extends XMLCompositeDirectCollectionMapping
    implements org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>

    Purpose:Provide a mapping for a collection of binary data values that can be treated as either inline binary values or as an attachment.

    Responsibilities:

    • Handle converting binary types (byte[], Image etc) to base64
    • Make callbacks to AttachmentMarshaller/AttachmentUnmarshaller
    • Write out approriate attachment information (xop:include)

    XMLBinaryDataCollectionMapping represents a mapping of a collection of binary data in the object model to XML. This can either be written directly as inline binary data (base64) or passed through as an MTOM or SWAREF attachment.

    The following types are allowable to be mapped using an XMLBinaryDataMapping:

    • java.awt.Image
    • byte[]
    • javax.activation.DataHandler
    • javax.xml.transform.Source
    • javax.mail.internet.MimeMultipart

    Setting the XPath: TopLink XML mappings make use of XPath statements to find the relevant data in an XML document. The XPath statement is relative to the context node specified in the descriptor. The XPath may contain path and positional information; the last node in the XPath forms the local node for the binary mapping. The XPath is specified on the mapping using the setXPath method.

    Inline Binary Data: Set this flag if you want to always inline binary data for this mapping. This will disable consideration for attachment handling for this mapping.

    SwaRef: Set this flag in order to specify that the target node of this mapping is of type xs:swaref

    See Also:
    XMLAttachmentMarshaller, XMLAttachmentUnmarshaller, MimeTypePolicy, Serialized Form
    Since:
    TopLink 11.1.1.0.0g
    • Constructor Detail

      • XMLBinaryDataCollectionMapping

        public XMLBinaryDataCollectionMapping()
    • Method Detail

      • shouldInlineBinaryData

        public boolean shouldInlineBinaryData()
        Specified by:
        shouldInlineBinaryData in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>
      • setShouldInlineBinaryData

        public void setShouldInlineBinaryData​(boolean b)
        Specified by:
        setShouldInlineBinaryData in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>
      • getMimeType

        public java.lang.String getMimeType​(java.lang.Object anObject)
        INTERNAL
        Specified by:
        getMimeType in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>
      • setMimeTypePolicy

        public void setMimeTypePolicy​(MimeTypePolicy mimeTypePolicy)
        Allow implementer to set the MimeTypePolicy class FixedMimeTypePolicy or AttributeMimeTypePolicy (dynamic)
        Specified by:
        setMimeTypePolicy in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>
        Parameters:
        mimeTypePolicy - MimeTypePolicy
      • setMimeType

        public void setMimeType​(java.lang.String mimeTypeString)
        Force mapping to set default FixedMimeTypePolicy using the MimeType string as argument
        Parameters:
        mimeTypeString -
      • getValueToWrite

        public java.lang.Object getValueToWrite​(java.lang.Object value,
                                                java.lang.Object parent,
                                                XMLRecord record,
                                                XMLField field,
                                                XMLField includeField,
                                                org.eclipse.persistence.internal.sessions.AbstractSession session)
      • writeSingleValue

        public void writeSingleValue​(java.lang.Object value,
                                     java.lang.Object parent,
                                     XMLRecord record,
                                     org.eclipse.persistence.internal.sessions.AbstractSession session)
        Description copied from interface: XMLMapping
        INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath. Used for Sequenced marshalling.
        Specified by:
        writeSingleValue in interface org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLRecord>
        Specified by:
        writeSingleValue in interface XMLMapping
        Overrides:
        writeSingleValue in class XMLCompositeDirectCollectionMapping
        Parameters:
        value - - The value to be marshalled
        record - - The Record the value is being marshalled too.
      • valueFromRow

        public java.lang.Object valueFromRow​(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                             org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
                                             ObjectBuildingQuery query,
                                             org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey,
                                             org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
                                             boolean isTargetProtected,
                                             java.lang.Boolean[] wasCacheUsed)
        Description copied from class: XMLCompositeDirectCollectionMapping
        INTERNAL: Build the nested collection from the database row.
        Overrides:
        valueFromRow in class XMLCompositeDirectCollectionMapping
      • setCollectionContentType

        public void setCollectionContentType​(java.lang.Class javaClass)
      • getCollectionContentType

        public java.lang.Class getCollectionContentType()
      • setAttributeElementClass

        public void setAttributeElementClass​(java.lang.Class attributeElementClass)
        PUBLIC: Set the class each element in the object's collection should be converted to, before the collection is inserted into the object. This is optional - if left null, the elements will be added to the object's collection unconverted.
        Specified by:
        setAttributeElementClass in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​MimeTypePolicy,​Session,​XMLUnmarshaller,​XMLRecord>
        Specified by:
        setAttributeElementClass in interface org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​Session,​XMLUnmarshaller,​XMLRecord>
        Overrides:
        setAttributeElementClass in class AbstractCompositeDirectCollectionMapping