org.eclipse.persistence.internal.oxm.XMLBinaryDataHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eclipselink Show documentation
Show all versions of eclipselink Show documentation
EclipseLink build based upon Git transaction f2b9fc5
/*
* Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.internal.oxm;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.activation.DataHandler;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.mail.internet.ContentType;
import javax.mail.internet.MimeMultipart;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.eclipse.persistence.exceptions.ConversionException;
import org.eclipse.persistence.exceptions.XMLMarshalException;
import org.eclipse.persistence.internal.core.helper.CoreClassConstants;
import org.eclipse.persistence.internal.core.queries.CoreContainerPolicy;
import org.eclipse.persistence.internal.core.sessions.CoreAbstractSession;
public class XMLBinaryDataHelper {
protected static XMLBinaryDataHelper binaryDataHelper;
public Class DATA_HANDLER;
public Class IMAGE;
public Class SOURCE;
public Class MULTIPART;
public XMLBinaryDataHelper() {
if (DATA_HANDLER == null) {
initializeDataTypes();
}
}
public static XMLBinaryDataHelper getXMLBinaryDataHelper() {
if (binaryDataHelper == null) {
setXMLBinaryDataHelper(new XMLBinaryDataHelper());
}
return binaryDataHelper;
}
public static void setXMLBinaryDataHelper(XMLBinaryDataHelper helper) {
binaryDataHelper = helper;
}
public void initializeDataTypes() {
//initialize types in this method to avoid loading them when the class is loaded
DATA_HANDLER = javax.activation.DataHandler.class;
IMAGE = java.awt.Image.class;
SOURCE = javax.xml.transform.Source.class;
MULTIPART = javax.mail.internet.MimeMultipart.class;
}
public Object convertObject(Object obj, Class classification, CoreAbstractSession session, CoreContainerPolicy cp) {
if( obj instanceof List && cp != null){
List theList = (List)obj;
Object container = cp.containerInstance(theList.size());
for(int i=0; i getBytesListForBinaryValues(List attributeValue, Marshaller marshaller, String mimeType){
List returnList = new ArrayList(attributeValue.size());
for(int i=0;i