javax.mail.internet

Class ContentType


  • public class ContentType
    extends Object
    This class represents a MIME Content-Type value. It provides methods to parse a Content-Type string into individual components and to generate a MIME style Content-Type string.
    Author:
    John Mani
    • Constructor Detail

      • ContentType

        public ContentType()
        No-arg Constructor.
      • ContentType

        public ContentType(String primaryType,
                           String subType,
                           ParameterList list)
        Constructor.
        Parameters:
        primaryType - primary type
        subType - subType
        list - ParameterList
      • ContentType

        public ContentType(String s)
                    throws ParseException
        Constructor that takes a Content-Type string. The String is parsed into its constituents: primaryType, subType and parameters. A ParseException is thrown if the parse fails.
        Parameters:
        s - the Content-Type string.
        Throws:
        ParseException - if the parse fails.
    • Method Detail

      • getPrimaryType

        public String getPrimaryType()
        Return the primary type.
        Returns:
        the primary type
      • getSubType

        public String getSubType()
        Return the subType.
        Returns:
        the subType
      • getBaseType

        public String getBaseType()
        Return the MIME type string, without the parameters. The returned value is basically the concatenation of the primaryType, the '/' character and the secondaryType.
        Returns:
        the type
      • getParameter

        public String getParameter(String name)
        Return the specified parameter value. Returns null if this parameter is absent.
        Returns:
        parameter value
      • getParameterList

        public ParameterList getParameterList()
        Return a ParameterList object that holds all the available parameters. Returns null if no parameters are available.
        Returns:
        ParameterList
      • setPrimaryType

        public void setPrimaryType(String primaryType)
        Set the primary type. Overrides existing primary type.
        Parameters:
        primaryType - primary type
      • setSubType

        public void setSubType(String subType)
        Set the subType. Replaces the existing subType.
        Parameters:
        subType - the subType
      • setParameter

        public void setParameter(String name,
                                 String value)
        Set the specified parameter. If this parameter already exists, it is replaced by this new value.
        Parameters:
        name - parameter name
        value - parameter value
      • setParameterList

        public void setParameterList(ParameterList list)
        Set a new ParameterList.
        Parameters:
        list - ParameterList
      • toString

        public String toString()
        Retrieve a RFC2045 style string representation of this Content-Type. Returns an empty string if the conversion failed.
        Overrides:
        toString in class Object
        Returns:
        RFC2045 style string
      • match

        public boolean match(ContentType cType)
        Match with the specified ContentType object. This method compares only the primaryType and subType . The parameters of both operands are ignored.

        For example, this method will return true when comparing the ContentTypes for "text/plain" and "text/plain; charset=foobar". If the subType of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will return true when comparing the ContentTypes for "text/plain" and "text/*"

        Parameters:
        cType - ContentType to compare this against
      • match

        public boolean match(String s)
        Match with the specified content-type string. This method compares only the primaryType and subType . The parameters of both operands are ignored.

        For example, this method will return true when comparing the ContentType for "text/plain" with "text/plain; charset=foobar". If the subType of either operand is the special character '*', then the subtype is ignored during the match. For example, this method will return true when comparing the ContentType for "text/plain" with "text/*"

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 20:47:45 Cette version de la page est en cache (à la date du 21/08/2025 20:47:45) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 14/04/2008, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/mail/internet/ContentType.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, ContentType

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.