/** * Match with the specified ContentType object. This method compares <strong>only the <code> * primaryType</code> and <code>subType</code> </strong>. The parameters of both operands are * ignored. * * <p>For example, this method will return <code>true</code> when comparing the ContentTypes for * <strong>"text/plain"</strong> and <strong>"text/plain; charset=foobar"</strong>. * * <p>If the <code>subType</code> of either operand is the special character '*', then the subtype * is ignored during the match. For example, this method will return <code>true</code> when * comparing the ContentTypes for <strong>"text/plain"</strong> and <strong>"text/*" </strong> * * @param cType to compare this against */ public boolean match(ContentType cType) { // Match primaryType if (!primaryType.equalsIgnoreCase(cType.getPrimaryType())) return false; String sType = cType.getSubType(); // If either one of the subTypes is wildcarded, return true if ((subType.charAt(0) == '*') || (sType.charAt(0) == '*')) return true; // Match subType if (!subType.equalsIgnoreCase(sType)) return false; return true; }