001/**************************************************************** 002 * Licensed to the Apache Software Foundation (ASF) under one * 003 * or more contributor license agreements. See the NOTICE file * 004 * distributed with this work for additional information * 005 * regarding copyright ownership. The ASF licenses this file * 006 * to you under the Apache License, Version 2.0 (the * 007 * "License"); you may not use this file except in compliance * 008 * with the License. You may obtain a copy of the License at * 009 * * 010 * http://www.apache.org/licenses/LICENSE-2.0 * 011 * * 012 * Unless required by applicable law or agreed to in writing, * 013 * software distributed under the License is distributed on an * 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * 015 * KIND, either express or implied. See the License for the * 016 * specific language governing permissions and limitations * 017 * under the License. * 018 ****************************************************************/ 019 020package org.apache.james.mime4j.stream; 021 022/** 023 * A descriptor containing common MIME content properties. 024 */ 025public interface ContentDescriptor { 026 027 /** 028 * Returns the body descriptors MIME type. 029 * @see #getMediaType() 030 * @see #getSubType() 031 * @return The MIME type, which has been parsed from the 032 * content-type definition. Must not be null, but 033 * "text/plain", if no content-type was specified. 034 */ 035 String getMimeType(); 036 037 /** 038 * Gets the defaulted MIME media type for this content. 039 * For example <code>TEXT</code>, <code>IMAGE</code>, <code>MULTIPART</code> 040 * @see #getMimeType() 041 * @return the MIME media type when content-type specified, 042 * otherwise the correct default (<code>TEXT</code>) 043 */ 044 String getMediaType(); 045 046 /** 047 * Gets the defaulted MIME sub type for this content. 048 * @see #getMimeType() 049 * @return the MIME media type when content-type is specified, 050 * otherwise the correct default (<code>PLAIN</code>) 051 */ 052 String getSubType(); 053 054 /** 055 * <p>The body descriptors character set, defaulted appropriately for the MIME type.</p> 056 * <p> 057 * For <code>TEXT</code> types, this will be defaulted to <code>us-ascii</code>. 058 * For other types, when the charset parameter is missing this property will be null. 059 * </p> 060 * @return Character set, which has been parsed from the 061 * content-type definition. Not null for <code>TEXT</code> types, when unset will 062 * be set to default <code>us-ascii</code>. For other types, when unset, 063 * null will be returned. 064 */ 065 String getCharset(); 066 067 /** 068 * Returns the body descriptors transfer encoding. 069 * @return The transfer encoding. Must not be null, but "7bit", 070 * if no transfer-encoding was specified. 071 */ 072 String getTransferEncoding(); 073 074 /** 075 * Returns the body descriptors content-length. 076 * @return Content length, if known, or -1, to indicate the absence of a 077 * content-length header. 078 */ 079 long getContentLength(); 080 081}