
org.eclipse.persistence.internal.oxm.XMLBinaryDataHelper Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 1998, 2015 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 v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* 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
© 2015 - 2025 Weber Informatics LLC | Privacy Policy