[6785] | 1 | /**************************************************************** |
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one * |
---|
| 3 | * or more contributor license agreements. See the NOTICE file * |
---|
| 4 | * distributed with this work for additional information * |
---|
| 5 | * regarding copyright ownership. The ASF licenses this file * |
---|
| 6 | * to you under the Apache License, Version 2.0 (the * |
---|
| 7 | * "License"); you may not use this file except in compliance * |
---|
| 8 | * with the License. You may obtain a copy of the License at * |
---|
| 9 | * * |
---|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 * |
---|
| 11 | * * |
---|
| 12 | * Unless required by applicable law or agreed to in writing, * |
---|
| 13 | * software distributed under the License is distributed on an * |
---|
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * |
---|
| 15 | * KIND, either express or implied. See the License for the * |
---|
| 16 | * specific language governing permissions and limitations * |
---|
| 17 | * under the License. * |
---|
| 18 | ****************************************************************/ |
---|
| 19 | |
---|
| 20 | package org.apache.james.mime4j.message; |
---|
| 21 | |
---|
| 22 | import java.io.IOException; |
---|
| 23 | import java.io.InputStream; |
---|
| 24 | |
---|
| 25 | import org.apache.james.mime4j.dom.BinaryBody; |
---|
| 26 | import org.apache.james.mime4j.dom.TextBody; |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * Factory for creating message bodies. |
---|
| 30 | */ |
---|
| 31 | public interface BodyFactory { |
---|
| 32 | |
---|
| 33 | /** |
---|
| 34 | * Creates a {@link BinaryBody} that holds the content of the given input |
---|
| 35 | * stream. |
---|
| 36 | * |
---|
| 37 | * @param is |
---|
| 38 | * input stream to create a message body from. |
---|
| 39 | * @return a binary body. |
---|
| 40 | * @throws IOException |
---|
| 41 | * if an I/O error occurs. |
---|
| 42 | */ |
---|
| 43 | BinaryBody binaryBody(InputStream is) throws IOException; |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * Creates a {@link TextBody} that holds the content of the given input |
---|
| 47 | * stream. |
---|
| 48 | * <p> |
---|
| 49 | * The charset corresponding to the given MIME charset name is used to |
---|
| 50 | * decode the byte content of the input stream into a character stream when |
---|
| 51 | * calling {@link TextBody#getReader() getReader()} on the returned object. |
---|
| 52 | * If the MIME charset has no corresponding Java charset or the Java charset |
---|
| 53 | * cannot be used for decoding then "us-ascii" is used instead. |
---|
| 54 | * |
---|
| 55 | * @param is |
---|
| 56 | * input stream to create a message body from. |
---|
| 57 | * @param mimeCharset |
---|
| 58 | * name of a MIME charset. |
---|
| 59 | * @return a text body. |
---|
| 60 | * @throws IOException |
---|
| 61 | * if an I/O error occurs. |
---|
| 62 | */ |
---|
| 63 | TextBody textBody(InputStream is, String mimeCharset) throws IOException; |
---|
| 64 | |
---|
| 65 | } |
---|