return myPieces[0];
}
/**
* Returns this MIME type object's media subtype.
*/
public String getMediaSubtype() {
return myPieces[1];
}
/**
* Returns an unmodifiable map view of the parameters in this MIME type
* object. Each entry in the parameter map view consists of a parameter
* name String (key) mapping to a parameter value String. If this MIME
* type object has no parameters, an empty map is returned.
*
* @return Parameter map for this MIME type object.
*/
public Map getParameterMap() {
if (myParameterMap == null) {
myParameterMap = new ParameterMap();
}
return myParameterMap;
}
/**
* Converts this MIME type object to a string.
*
* @return MIME type string based on the canonical form. Each parameter
* value is enclosed in quotes.
*/
public String toString() {
return getStringValue();
}
/**
* Returns a hash code for this MIME type object.
*/
public int hashCode() {
return getStringValue().hashCode();
}
/**
* Determine if this MIME type object is equal to the given object. The two
* are equal if the given object is not null, is an instance of class
* net.jini.print.data.MimeType, and has the same canonical form as this
* MIME type object (that is, has the same type, subtype, and parameters).
* Thus, if two MIME type objects are the same except for comments, they are
* considered equal. However, "text/plain" and "text/plain;
* charset=us-ascii" are not considered equal, even though they represent
* the same media type (because the default character set for plain text is
* US-ASCII).
*
* @param obj Object to test.
*
* @return True if this MIME type object equals <CODE>obj</CODE>, false
* otherwise.
*/
public boolean equals (Object obj) {
return(obj != null &&
obj instanceof MimeType &&
getStringValue().equals(((MimeType) obj).getStringValue()));
}
/**
* Returns this MIME type's string value in canonical form.
*/
private String getStringValue() {
if (myStringValue == null) {
StringBuffer result = new StringBuffer();
result.append (myPieces[0]);
result.append ('/');
result.append (myPieces[1]);
int n = myPieces.length;
for (int i = 2; i < n; i += 2) {
result.append(';');
result.append(' ');
result.append(myPieces[i]);
result.append('=');
result.append(addQuotes (myPieces[i+1]));
}
myStringValue = result.toString();
}
return myStringValue;
}
// Hidden classes, constants, and operations for parsing a MIME media type
// string.
// Lexeme types.
private static final int TOKEN_LEXEME = 0;
private static final int QUOTED_STRING_LEXEME = 1;
private static final int TSPECIAL_LEXEME = 2;
private static final int EOF_LEXEME = 3;
private static final int ILLEGAL_LEXEME = 4;
// Class for a lexical analyzer.
private static class LexicalAnalyzer {
protected String mySource;
protected int mySourceLength;
=3= |