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

com.budjb.httprequests.converter.EntityWriter Maven / Gradle / Ivy

/*
 * Copyright 2016-2018 the original author or authors.
 *
 * Licensed 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 com.budjb.httprequests.converter;

import java.io.IOException;
import java.io.InputStream;

public interface EntityWriter extends EntityConverter {
    /**
     * Returns a Content-Type of the converted object that will be set in the HTTP request.
     * 

* If no Content-Type is known, null is returned. * * @return Content-Type of the converted object, or null if unknown. */ String getContentType(); /** * Determines whether the given class type is supported by the writer. * * @param type Type to convert. * @return Whether the type is supported. */ boolean supports(Class type); /** * Convert the given entity. *

* If an error occurs, null may be returned so that another converter may attempt conversion. * * @param entity Entity object to convert into a byte array. * @param characterSet The character set of the request. * @return An {@link InputStream} containing the converted entity. * @throws Exception when an unexpected error occurs. */ InputStream write(Object entity, String characterSet) throws Exception; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy