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    
020    package org.apache.james.mime4j.descriptor;
021    
022    import java.util.Map;
023    
024    /**
025     * Represents common content properties. 
026     */
027    public interface ContentDescriptor {
028    
029        /**
030         * Returns the body descriptors MIME type.
031         * @see #getMediaType()
032         * @see #getSubType()
033         * @return The MIME type, which has been parsed from the
034         *   content-type definition. Must not be null, but
035         *   "text/plain", if no content-type was specified.
036         */
037        String getMimeType();
038        
039        /**
040         * Gets the defaulted MIME media type for this content.
041         * For example <code>TEXT</code>, <code>IMAGE</code>, <code>MULTIPART</code>
042         * @see #getMimeType()
043         * @return the MIME media type when content-type specified,
044         * otherwise the correct default (<code>TEXT</code>)
045         */
046        String getMediaType();
047    
048        /**
049         * Gets the defaulted MIME sub type for this content.
050         * @see #getMimeType()
051         * @return the MIME media type when content-type is specified,
052         * otherwise the correct default (<code>PLAIN</code>)
053         */
054        String getSubType();
055        
056        /**
057         * <p>The body descriptors character set, defaulted appropriately for the MIME type.</p>
058         * <p>
059         * For <code>TEXT</code> types, this will be defaulted to <code>us-ascii</code>.
060         * For other types, when the charset parameter is missing this property will be null.
061         * </p>
062         * @return Character set, which has been parsed from the
063         *   content-type definition. Not null for <code>TEXT</code> types, when unset will
064         *   be set to default <code>us-ascii</code>. For other types, when unset,
065         *   null will be returned.
066         */
067        String getCharset();
068    
069        /**
070         * Returns the body descriptors transfer encoding.
071         * @return The transfer encoding. Must not be null, but "7bit",
072         *   if no transfer-encoding was specified.
073         */
074        String getTransferEncoding();
075    
076        /**
077         * Returns the map of parameters of the content-type header.
078         */
079        Map<String, String> getContentTypeParameters();
080    
081        /**
082         * Returns the body descriptors content-length.
083         * @return Content length, if known, or -1, to indicate the absence of a
084         *   content-length header.
085         */
086        long getContentLength();
087    
088    }