Methods Summary |
---|
public java.lang.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.
return primaryType + '/" + subType;
|
public java.lang.String | getParameter(java.lang.String name)Return the specified parameter value. Returns null
if this parameter is absent.
if (list == null)
return null;
return list.get(name);
|
public javax.mail.internet.ParameterList | getParameterList()Return a ParameterList object that holds all the available
parameters. Returns null if no parameters are available.
return list;
|
public java.lang.String | getPrimaryType()Return the primary type.
return primaryType;
|
public java.lang.String | getSubType()Return the subType.
return subType;
|
public boolean | match(javax.mail.internet.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/*"
// 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;
|
public boolean | match(java.lang.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/*"
try {
return match(new ContentType(s));
} catch (ParseException pex) {
return false;
}
|
public void | setParameter(java.lang.String name, java.lang.String value)Set the specified parameter. If this parameter already exists,
it is replaced by this new value.
if (list == null)
list = new ParameterList();
list.set(name, value);
|
public void | setParameterList(javax.mail.internet.ParameterList list)Set a new ParameterList.
this.list = list;
|
public void | setPrimaryType(java.lang.String primaryType)Set the primary type. Overrides existing primary type.
this.primaryType = primaryType;
|
public void | setSubType(java.lang.String subType)Set the subType. Replaces the existing subType.
this.subType = subType;
|
public java.lang.String | toString()Retrieve a RFC2045 style string representation of
this Content-Type. Returns null if
the conversion failed.
if (primaryType == null || subType == null) // need both
return null;
StringBuffer sb = new StringBuffer();
sb.append(primaryType).append('/").append(subType);
if (list != null)
// append the parameter list
// use the length of the string buffer + the length of
// the header name formatted as follows "Content-Type: "
sb.append(list.toString(sb.length() + 14));
return sb.toString();
|