simple.util.net
Interface ContentType

All Known Implementing Classes:
ContentParser

public interface ContentType

This provides access to the MIME type parts, that is the type subtype and an optional charset parameter. The charset parameter is one of many parameters that can be assiciated with a MIME type. This however only provides access to the charset value.

The getCharset will return val if the MIME type represented is type/subtype; charset=val. The type and subtype are set to the String value null if the setPrimary or setSecondary are given a null String.

Author:
Niall Gallagher

Method Summary
 java.lang.String getCharset()
          This is used to retrive the charset of this MIME type.
 java.lang.String getPrimary()
          This is used to retrive the type of this MIME type.
 java.lang.String getSecondary()
          This is used to retrive the subtype of this MIME type.
 void setCharset(java.lang.String charset)
          This will set the charset to whatever value is in the String object.
 void setPrimary(java.lang.String type)
          This sets the type to whatever value is in the String object.
 void setSecondary(java.lang.String type)
          Sets the subtype to whatever value is in the String object.
 java.lang.String toString()
          This will return the String value of the MIME type.
 

Method Detail

setPrimary

void setPrimary(java.lang.String type)
This sets the type to whatever value is in the String object. If the String object is null the this object's toString method will contain the value null.

If type is null then the toString method will be null/subtype;param=value. If the type is non-null this will contain the value of the String.

Parameters:
type - the type to add to the MIME type

getPrimary

java.lang.String getPrimary()
This is used to retrive the type of this MIME type. The type part within the MIME type defines the generic type. For example type/subtype;param1=value1. This will return the value of the type part. If there is no type part then this will return null otherwise the type String.

Returns:
the type part of the MIME type

setSecondary

void setSecondary(java.lang.String type)
Sets the subtype to whatever value is in the String object. If the String object is null the this object's toString method will contain the value null.

If subtype is null then the toString method will be type/null;param=value. If the type is non-null this will contain the value of the String.

Parameters:
type - the type to add to the MIME type

getSecondary

java.lang.String getSecondary()
This is used to retrive the subtype of this MIME type. The subtype part within the MIME type defines the specific type. For example type/subtype;param1=value1. This will return the value of the subtype part. If there is no subtype part then this will return null otherwise the type String.

Returns:
the subtype part of the MIME type

setCharset

void setCharset(java.lang.String charset)
This will set the charset to whatever value is in the String object. If the String object is null then this toString method will not contain the charset.

If charset is null then the toString method will be type/subtype. If the charset value is non-null this will contain the charset parameter with that value.

Parameters:
charset - the value to add to the MIME type

getCharset

java.lang.String getCharset()
This is used to retrive the charset of this MIME type. The charset part within the MIME type is an optional parameter. For example type/subtype;charset=value . This will return the value of the charset value. If there is no charset param then this will return null otherwise the type String.

Returns:
the charset value for the MIME type

toString

java.lang.String toString()
This will return the String value of the MIME type. This will return the MIME type with the type, subtype and if there is a charset value specified then a charset parameter.

The charset parameter is an optional parameter to the MIME type. An example a MIME type is type/subtype; charset=value. If the type or subtype is null then the MIME type will be wither null/subtype, type/null or if both are null null/null.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of the MIME type