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.dom.field;
021
022import java.util.Map;
023
024public interface ContentTypeField extends ParsedField {
025
026    /** The prefix of all <code>multipart</code> MIME types. */
027    public static final String TYPE_MULTIPART_PREFIX = "multipart/";
028    /** The <code>multipart/digest</code> MIME type. */
029    public static final String TYPE_MULTIPART_DIGEST = "multipart/digest";
030    /** The <code>text/plain</code> MIME type. */
031    public static final String TYPE_TEXT_PLAIN = "text/plain";
032    /** The <code>message/rfc822</code> MIME type. */
033    public static final String TYPE_MESSAGE_RFC822 = "message/rfc822";
034    /** The name of the <code>boundary</code> parameter. */
035    public static final String PARAM_BOUNDARY = "boundary";
036    /** The name of the <code>charset</code> parameter. */
037    public static final String PARAM_CHARSET = "charset";
038
039    /**
040     * Gets the MIME type defined in this Content-Type field.
041     *
042     * @return the MIME type or an empty string if not set.
043     */
044    String getMimeType();
045
046    /**
047     * Gets the media type defined in this Content-Type field.
048     */
049    String getMediaType();
050
051    /**
052     * Gets the subtype defined in this Content-Type field.
053     */
054    String getSubType();
055
056    /**
057     * Gets the value of a parameter. Parameter names are case-insensitive.
058     *
059     * @param name
060     *            the name of the parameter to get.
061     * @return the parameter value or <code>null</code> if not set.
062     */
063    String getParameter(String name);
064
065    /**
066     * Gets all parameters.
067     *
068     * @return the parameters.
069     */
070    Map<String, String> getParameters();
071
072    /**
073     * Determines if the MIME type of this field matches the given one.
074     *
075     * @param mimeType
076     *            the MIME type to match against.
077     * @return <code>true</code> if the MIME type of this field matches,
078     *         <code>false</code> otherwise.
079     */
080    boolean isMimeType(String mimeType);
081
082    /**
083     * Determines if the MIME type of this field is <code>multipart/*</code>.
084     *
085     * @return <code>true</code> if this field is has a
086     *         <code>multipart/*</code> MIME type, <code>false</code>
087     *         otherwise.
088     */
089    boolean isMultipart();
090
091    /**
092     * Gets the value of the <code>boundary</code> parameter if set.
093     *
094     * @return the <code>boundary</code> parameter value or <code>null</code>
095     *         if not set.
096     */
097    String getBoundary();
098
099    /**
100     * Gets the value of the <code>charset</code> parameter if set.
101     *
102     * @return the <code>charset</code> parameter value or <code>null</code>
103     *         if not set.
104     */
105    String getCharset();
106
107}