Class XMLBinaryDataMapping

java.lang.Object
org.eclipse.persistence.core.mappings.CoreMapping<AttributeAccessor,org.eclipse.persistence.internal.sessions.AbstractSession,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
All Implemented Interfaces:
Serializable, Cloneable, org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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.DirectMapping<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.XMLConverterMapping<XMLMarshaller,Session,XMLUnmarshaller>, MapComponentMapping, MapKeyMapping, XMLMapping, XMLNillableMapping

public class XMLBinaryDataMapping extends XMLDirectMapping implements org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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 binary data that can be treated as either inline 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)

XMLBinaryDataMapping represents a mapping 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 typed are allowable to be mapped using an XMLBinaryDataMapping:

  • java.awt.Image
  • byte[]
  • jakarta.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:
  • Constructor Details

    • XMLBinaryDataMapping

      public XMLBinaryDataMapping()
  • Method Details

    • shouldInlineBinaryData

      public boolean shouldInlineBinaryData()
      Specified by:
      shouldInlineBinaryData in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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.BinaryDataMapping<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 String getMimeType(Object anObject)
      INTERNAL
      Specified by:
      getMimeType in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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 String getMimeType()
      INTERNAL
      Specified by:
      getMimeType in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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>
    • getMimeTypePolicy

      public MimeTypePolicy getMimeTypePolicy()
    • setMimeTypePolicy

      public void setMimeTypePolicy(MimeTypePolicy aPolicy)
      Allow implementer to set the MimeTypePolicy class FixedMimeTypePolicy or AttributeMimeTypePolicy (dynamic)
      Specified by:
      setMimeTypePolicy in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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:
      aPolicy - MimeTypePolicy
    • setMimeType

      public void setMimeType(String mimeTypeString)
      Force mapping to set default FixedMimeTypePolicy using the MimeType string as argument
      Specified by:
      setMimeType in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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:
      mimeTypeString -
    • isSwaRef

      public boolean isSwaRef()
      Specified by:
      isSwaRef in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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>
    • setSwaRef

      public void setSwaRef(boolean swaRef)
      Specified by:
      setSwaRef in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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>
    • setXPath

      public void setXPath(String xpathString)
      Set the Mapping field name attribute to the given XPath String
      Specified by:
      setXPath in interface org.eclipse.persistence.internal.oxm.mappings.BinaryDataMapping<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:
      setXPath in interface org.eclipse.persistence.internal.oxm.mappings.DirectMapping<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:
      setXPath in class XMLDirectMapping
      Parameters:
      xpathString - String
    • writeFromObjectIntoRow

      public void writeFromObjectIntoRow(Object object, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session, DatabaseMapping.WriteType writeType)
      Description copied from class: XMLDirectMapping
      INTERNAL: Get a value from the object and set that in the respective field of the row.
      Overrides:
      writeFromObjectIntoRow in class XMLDirectMapping
    • writeSingleValue

      public void writeSingleValue(Object attributeValue, 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 XMLDirectMapping
      Parameters:
      attributeValue - - The value to be marshalled
      record - - The Record the value is being marshalled too.
    • valueFromRow

      public 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, Boolean[] wasCacheUsed)
      Description copied from class: XMLDirectMapping
      INTERNAL: Return the mapping's attribute value from the row. The execution session is passed for the case of building a UnitOfWork clone directly from a row, the session set in the query will not know which platform to use for converting the value. Allows the correct session to be passed in.
      Overrides:
      valueFromRow in class XMLDirectMapping
    • isAbstractDirectMapping

      public boolean isAbstractDirectMapping()
      Description copied from class: AbstractDirectMapping
      INTERNAL:
      Specified by:
      isAbstractDirectMapping 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>
      Overrides:
      isAbstractDirectMapping in class AbstractDirectMapping
    • isAbstractColumnMapping

      public boolean isAbstractColumnMapping()
      Description copied from class: AbstractColumnMapping
      INTERNAL:
      Overrides:
      isAbstractColumnMapping in class AbstractColumnMapping