A Multipurpose Internet Mail Extension (MIME) type, as defined
in RFC 2045 and 2046.
Method from javax.activation.MimeType Detail: |
public String getBaseType() {
return primaryType + "/" + subType;
}
Return a String representation of this object
without the parameter list. |
public String getParameter(String name) {
return parameters.get(name);
}
Retrieve the value associated with the given name, or null if there
is no current association. |
public MimeTypeParameterList getParameters() {
return parameters;
}
Retrieve this object's parameter list. |
public String getPrimaryType() {
return primaryType;
}
Retrieve the primary type of this object. |
public String getSubType() {
return subType;
}
Retrieve the subtype of this object. |
public boolean match(MimeType type) {
return primaryType.equals(type.getPrimaryType())
&& (subType.equals("*")
|| type.getSubType().equals("*")
|| (subType.equals(type.getSubType())));
}
Determine if the primary and sub type of this object is
the same as what is in the given type. |
public boolean match(String rawdata) throws MimeTypeParseException {
return match(new MimeType(rawdata));
}
Determine if the primary and sub type of this object is
the same as the content type described in rawdata. |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
try {
parse(in.readUTF());
} catch (MimeTypeParseException e) {
throw new IOException(e.toString());
}
}
The object implements the readExternal method to restore its
contents by calling the methods of DataInput for primitive
types and readObject for objects, strings and arrays. The
readExternal method must read the values in the same sequence
and with the same types as were written by writeExternal. |
public void removeParameter(String name) {
parameters.remove(name);
}
Remove any value associated with the given name. |
public void setParameter(String name,
String value) {
parameters.set(name, value);
}
Set the value to be associated with the given name, replacing
any previous association. |
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 primary type for this object to the given String. |
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);
}
Set the subtype for this object to the given String. |
public String toString() {
return getBaseType() + parameters.toString();
}
Return the String representation of this object. |
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(toString());
out.flush();
}
The object implements the writeExternal method to save its contents
by calling the methods of DataOutput for its primitive values or
calling the writeObject method of ObjectOutput for objects, strings
and arrays. |