*/
private class ParameterMapEntry implements Map.Entry {
private int myIndex;
public ParameterMapEntry(int theIndex) {
myIndex = theIndex;
}
public Object getKey(){
return myPieces[myIndex];
}
public Object getValue(){
return myPieces[myIndex+1];
}
public Object setValue (Object value) {
throw new UnsupportedOperationException();
}
public boolean equals(Object o) {
return (o != null &&
o instanceof Map.Entry &&
getKey().equals (((Map.Entry) o).getKey()) &&
getValue().equals(((Map.Entry) o).getValue()));
}
public int hashCode() {
return getKey().hashCode() ^ getValue().hashCode();
}
}
/**
* Parameter map entry set iterator.
*/
private class ParameterMapEntrySetIterator implements Iterator {
private int myIndex = 2;
public boolean hasNext() {
return myIndex < myPieces.length;
}
public Object next() {
if (hasNext()) {
ParameterMapEntry result = new ParameterMapEntry (myIndex);
myIndex += 2;
return result;
} else {
throw new NoSuchElementException();
}
}
public void remove() {
throw new UnsupportedOperationException();
}
}
/**
* Parameter map entry set.
*/
private class ParameterMapEntrySet extends AbstractSet {
public Iterator iterator() {
return new ParameterMapEntrySetIterator();
}
public int size() {
return (myPieces.length - 2) / 2;
}
}
/**
* Parameter map.
*/
private class ParameterMap extends AbstractMap {
public Set entrySet() {
if (myEntrySet == null) {
myEntrySet = new ParameterMapEntrySet();
}
return myEntrySet;
}
}
/**
* Construct a new MIME type object from the given string. The given
* string is converted into canonical form and stored internally.
*
* @param s MIME media type string.
*
* @exception NullPointerException
* (unchecked exception) Thrown if <CODE>s</CODE> is null.
* @exception IllegalArgumentException
* (unchecked exception) Thrown if <CODE>s</CODE> does not obey the
* syntax for a MIME media type string.
*/
public MimeType(String s) {
parse (s);
}
/**
* Returns this MIME type object's MIME type string based on the canonical
* form. Each parameter value is enclosed in quotes.
*/
public String getMimeType() {
return getStringValue();
}
/**
* Returns this MIME type object's media type.
*/
public String getMediaType() {
=2= |