jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/ContentType.java
changeset 43852 93a527059d8a
parent 33547 e4c76ac38b12
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   134     }
   134     }
   135 
   135 
   136     /**
   136     /**
   137      * Return the specified parameter value. Returns <code>null</code>
   137      * Return the specified parameter value. Returns <code>null</code>
   138      * if this parameter is absent.
   138      * if this parameter is absent.
       
   139      * @param name parameter name
   139      * @return  parameter value
   140      * @return  parameter value
   140      */
   141      */
   141     public String getParameter(String name) {
   142     public String getParameter(String name) {
   142         if (list == null)
   143         if (list == null)
   143             return null;
   144             return null;
   198      * this Content-Type. Returns <code>null</code> if
   199      * this Content-Type. Returns <code>null</code> if
   199      * the conversion failed.
   200      * the conversion failed.
   200      *
   201      *
   201      * @return  RFC2045 style string
   202      * @return  RFC2045 style string
   202      */
   203      */
       
   204     @Override
   203     public String toString() {
   205     public String toString() {
   204         if (primaryType == null || subType == null) // need both
   206         if (primaryType == null || subType == null) // need both
   205             return null;
   207             return null;
   206 
   208 
   207         StringBuilder sb = new StringBuilder();
   209         StringBuilder sb = new StringBuilder();
   216     }
   218     }
   217 
   219 
   218     /**
   220     /**
   219      * Match with the specified ContentType object. This method
   221      * Match with the specified ContentType object. This method
   220      * compares <strong>only the <code>primaryType</code> and
   222      * compares <strong>only the <code>primaryType</code> and
   221      * <code>subType</code> </strong>. The parameters of both operands
   223      * <code>primaryType</code> </strong>. The parameters of both operands
   222      * are ignored. <p>
   224      * are ignored. <p>
   223      *
   225      *
   224      * For example, this method will return <code>true</code> when
   226      * For example, this method will return <code>true</code> when
   225      * comparing the ContentTypes for <strong>"text/plain"</strong>
   227      * comparing the ContentTypes for <strong>"text/plain"</strong>
   226      * and <strong>"text/plain; charset=foobar"</strong>.
   228      * and <strong>"text/plain; charset=foobar"</strong>.
   230      * For example, this method will return <code>true</code> when
   232      * For example, this method will return <code>true</code> when
   231      * comparing the ContentTypes for <strong>"text/plain"</strong>
   233      * comparing the ContentTypes for <strong>"text/plain"</strong>
   232      * and <strong>"text/*" </strong>
   234      * and <strong>"text/*" </strong>
   233      *
   235      *
   234      * @param   cType to compare this against
   236      * @param   cType to compare this against
       
   237      * @return true if <code>primaryType</code> and <code>subType</code>
       
   238      * match specified content type.
   235      */
   239      */
   236     public boolean match(ContentType cType) {
   240     public boolean match(ContentType cType) {
   237         // Match primaryType
   241         // Match primaryType
   238         if (!primaryType.equalsIgnoreCase(cType.getPrimaryType()))
   242         if (!primaryType.equalsIgnoreCase(cType.getPrimaryType()))
   239             return false;
   243             return false;
   264      * If the <code>subType</code> of either operand is the special
   268      * If the <code>subType</code> of either operand is the special
   265      * character '*', then the subtype is ignored during the match.
   269      * character '*', then the subtype is ignored during the match.
   266      * For example, this method will return <code>true</code> when
   270      * For example, this method will return <code>true</code> when
   267      * comparing the ContentType for <strong>"text/plain"</strong>
   271      * comparing the ContentType for <strong>"text/plain"</strong>
   268      * with <strong>"text/*" </strong>
   272      * with <strong>"text/*" </strong>
       
   273      *
       
   274      * @param s content type
       
   275      * @return true if <code>primaryType</code> and <code>subType</code>
       
   276      * match specified content type.
   269      */
   277      */
   270     public boolean match(String s) {
   278     public boolean match(String s) {
   271         try {
   279         try {
   272             return match(new ContentType(s));
   280             return match(new ContentType(s));
   273         } catch (ParseException pex) {
   281         } catch (ParseException pex) {