All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.axiom.attachments.ConfigurableDataHandler Maven / Gradle / Ivy

There is a newer version: 5.0.22
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.axiom.attachments;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import java.net.URL;

/**
 * This Axiom DataHandler inplementation allows the user to set custom values for the following MIME
 * body part headers. 
  • content-transfer-encoding
  • content-type

Data * written to the MIME part gets encoded by content-transfer-encoding specified as above

*

* Usage is Similar to the javax.activation.DataHandler except for the setting of the above * properties.

eg:

dataHandler = new ConfigurableDataHandler(new * ByteArrayDataSource(byteArray));

dataHandler.setTransferEncoding("quoted-printable");

*

dataHandler.setContentType("image/jpg");

* * @see javax.activation.DataHandler */ public class ConfigurableDataHandler extends DataHandler { private String transferEncoding; private String contentType; public ConfigurableDataHandler(DataSource ds) { super(ds); } public ConfigurableDataHandler(Object data, String type) { super(data, type); } public ConfigurableDataHandler(URL url) { super(url); } // public String getContentID() { // return contentID; // } // // public void setContentID(String contentID) { // this.contentID = contentID; // } @Override public String getContentType() { if (contentType != null) { return contentType; } else { return super.getContentType(); } } public void setContentType(String contentType) { this.contentType = contentType; } public String getTransferEncoding() { return transferEncoding; } public void setTransferEncoding(String transferEncoding) { this.transferEncoding = transferEncoding; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy