/** * Set the primary type for this object to the given String. * * @param primary the primary MIME type * @exception MimeTypeParseException if the primary type * is not a valid token */ public void setPrimaryType(String primary) throws MimeTypeParseException { // check to see if primary is valid if (!isValidToken(primaryType)) throw new MimeTypeParseException("Primary type is invalid."); primaryType = primary.toLowerCase(Locale.ENGLISH); }
/** * Set the subtype for this object to the given String. * * @param sub the MIME subtype * @exception MimeTypeParseException if the subtype * is not a valid token */ public void setSubType(String sub) throws MimeTypeParseException { // check to see if sub is valid if (!isValidToken(subType)) throw new MimeTypeParseException("Sub type is invalid."); subType = sub.toLowerCase(Locale.ENGLISH); }
/** * Constructor that builds a MimeType with the given primary and sub type * but has an empty parameter list. * * @param primary the primary MIME type * @param sub the MIME sub-type * @exception MimeTypeParseException if the primary type or subtype * is not a valid token */ public MimeType(String primary, String sub) throws MimeTypeParseException { // check to see if primary is valid if (isValidToken(primary)) { primaryType = primary.toLowerCase(Locale.ENGLISH); } else { throw new MimeTypeParseException("Primary type is invalid."); } // check to see if sub is valid if (isValidToken(sub)) { subType = sub.toLowerCase(Locale.ENGLISH); } else { throw new MimeTypeParseException("Sub type is invalid."); } parameters = new MimeTypeParameterList(); }
throw new MimeTypeParseException("Unable to find a sub type."); } else if ((slashIndex < 0) && (semIndex >= 0)) { throw new MimeTypeParseException("Unable to find a sub type."); } else if ((slashIndex >= 0) && (semIndex < 0)) { throw new MimeTypeParseException("Unable to find a sub type."); throw new MimeTypeParseException("Primary type is invalid."); throw new MimeTypeParseException("Sub type is invalid.");
throw new MimeTypeParseException( "Couldn't find the '=' that separates a " + "parameter name from its value."); throw new MimeTypeParseException( "Couldn't find a value for parameter named " + name); throw new MimeTypeParseException( "Encountered unterminated quoted parameter value."); throw new MimeTypeParseException( "Encountered unterminated quoted parameter value."); } else { throw new MimeTypeParseException( "Unexpected character encountered at index " + i); throw new MimeTypeParseException( "More characters encountered in input than expected.");
/** * Set the primary type for this object to the given String. * * @param primary the primary MIME type * @exception MimeTypeParseException if the primary type * is not a valid token */ public void setPrimaryType(String primary) throws MimeTypeParseException { // check to see if primary is valid if (!isValidToken(primaryType)) throw new MimeTypeParseException("Primary type is invalid."); primaryType = primary.toLowerCase(); }
/** * Set the subtype for this object to the given String. * * @param sub the MIME subtype * @exception MimeTypeParseException if the subtype * is not a valid token */ public void setSubType(String sub) throws MimeTypeParseException { // check to see if sub is valid if (!isValidToken(subType)) throw new MimeTypeParseException("Sub type is invalid."); subType = sub.toLowerCase(); }
throw new MimeTypeParseException("Unable to find a sub type."); } else if ((slashIndex < 0) && (semIndex >= 0)) { throw new MimeTypeParseException("Unable to find a sub type."); } else if ((slashIndex >= 0) && (semIndex < 0)) { throw new MimeTypeParseException("Unable to find a sub type."); throw new MimeTypeParseException("Primary type is invalid."); throw new MimeTypeParseException("Sub type is invalid.");
/** * Constructor that builds a MimeType with the given primary and sub type * but has an empty parameter list. * * @param primary the primary MIME type * @param sub the MIME sub-type * @exception MimeTypeParseException if the primary type or subtype * is not a valid token */ public MimeType(String primary, String sub) throws MimeTypeParseException { // check to see if primary is valid if (isValidToken(primary)) { primaryType = primary.toLowerCase(); } else { throw new MimeTypeParseException("Primary type is invalid."); } // check to see if sub is valid if (isValidToken(sub)) { subType = sub.toLowerCase(); } else { throw new MimeTypeParseException("Sub type is invalid."); } parameters = new MimeTypeParameterList(); }
throw new MimeTypeParseException( "Couldn't find the '=' that separates a " + "parameter name from its value."); throw new MimeTypeParseException( "Couldn't find a value for parameter named " + name); throw new MimeTypeParseException( "Encountered unterminated quoted parameter value."); throw new MimeTypeParseException( "Encountered unterminated quoted parameter value."); } else { throw new MimeTypeParseException( "Unexpected character encountered at index " + i); throw new MimeTypeParseException( "More characters encountered in input than expected.");
private void expectEquals() throws MimeTypeParseException { char c; do { if (index == text.length()) { throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text); } c = text.charAt(index++); } while (Character.isWhitespace(c)); if (c != '=') { throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text); } }
private void expectEquals() throws MimeTypeParseException { char c; do { if (index == text.length()) { throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text); } c = text.charAt(index++); } while (Character.isWhitespace(c)); if (c != '=') { throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text); } }
private void expectEquals() throws MimeTypeParseException { char c; do { if (index == text.length()) { throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text); } c = text.charAt(index++); } while (Character.isWhitespace(c)); if (c != '=') { throw new MimeTypeParseException("Expected \"=\" at " + (index - 1) + " in " + text); } }
protected void parse(String parameterList) throws MimeTypeParseException { if (parameterList == null) { throw new MimeTypeParseException("parameterList is null"); } RFC2045Parser parser = new RFC2045Parser(parameterList); while (parser.hasMoreParams()) { String attribute = parser.expectAttribute(); parser.expectEquals(); String value = parser.expectValue(); params.put(attribute.toLowerCase(), value); } }
/** * Set the subtype for this object to the given String. * * @param sub the MIME subtype * @exception MimeTypeParseException if the subtype * is not a valid token */ public void setSubType(String sub) throws MimeTypeParseException { // check to see if sub is valid if (!isValidToken(subType)) throw new MimeTypeParseException("Sub type is invalid."); subType = sub.toLowerCase(Locale.ENGLISH); }
protected void parse(String parameterList) throws MimeTypeParseException { if (parameterList == null) { throw new MimeTypeParseException("parameterList is null"); } RFC2045Parser parser = new RFC2045Parser(parameterList); while (parser.hasMoreParams()) { String attribute = parser.expectAttribute(); parser.expectEquals(); String value = parser.expectValue(); params.put(attribute.toLowerCase(), value); } }
private static String parseToken(String tokenString) throws MimeTypeParseException { tokenString = tokenString.trim(); for (int i=0; i < tokenString.length(); i++) { char c = tokenString.charAt(i); if (isSpecial(c)) { throw new MimeTypeParseException("Special '" + c + "' not allowed in token"); } } return tokenString; } }
private static String parseToken(String tokenString) throws MimeTypeParseException { tokenString = tokenString.trim(); for (int i=0; i < tokenString.length(); i++) { char c = tokenString.charAt(i); if (isSpecial(c)) { throw new MimeTypeParseException("Special '" + c + "' not allowed in token"); } } return tokenString; } }
/** * Set the primary type for this object to the given String. * * @param primary the primary MIME type * @exception MimeTypeParseException if the primary type * is not a valid token */ public void setPrimaryType(String primary) throws MimeTypeParseException { // check to see if primary is valid if (!isValidToken(primaryType)) throw new MimeTypeParseException("Primary type is invalid."); primaryType = primary.toLowerCase(Locale.ENGLISH); }
/** * Set the subtype for this object to the given String. * * @param sub the MIME subtype * @exception MimeTypeParseException if the subtype * is not a valid token */ public void setSubType(String sub) throws MimeTypeParseException { // check to see if sub is valid if (!isValidToken(subType)) throw new MimeTypeParseException("Sub type is invalid."); subType = sub.toLowerCase(Locale.ENGLISH); }