public class ContentType
extends java.lang.Object
| Constructor and Description |
|---|
ContentType(java.lang.String type,
java.lang.String subtype,
java.lang.String extension)
Creates a new media type object from given types.
|
ContentType(java.lang.String type,
java.lang.String subtype,
java.lang.String extension,
java.lang.String[][] parameterPairs)
Creates a new media type object from given types.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(java.lang.String parameterKey,
java.lang.String parameterValue)
Adds a parameter and its associated value to the parameter table.
|
void |
addParameters(java.lang.String[][] parameterPairs)
Adds parameters and their associated values to the parameter table.
|
static ContentType |
cloneAndAddParameter(ContentType original,
java.lang.String parameterKey,
java.lang.String parameterValue)
Clones an ContentType instance and adds the passed parameter to the original ones.
|
static ContentType |
cloneAndAddParameters(ContentType original,
java.lang.String[][] parameterPairs)
Clones an ContentType instance and adds the passed parameters to the original ones.
|
static ContentType |
cloneAndSetParameter(ContentType original,
java.lang.String parameterKey,
java.lang.String parameterValue)
Clones an ContentType instance and replaces the original parameters with the passed one.
|
static ContentType |
cloneAndSetParameters(ContentType original,
java.lang.String[][] parameterPairsValues)
Clones an ContentType instance and replaces the original parameters with the passed ones.
|
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getExtension() |
java.lang.String |
getParameter(java.lang.String attributeName)
Returns the value of a given attribute.
|
Iterator |
getParameterEntries() |
java.lang.String |
getSubtype()
Returns the subtype.
|
java.lang.String |
getType()
Returns the main type.
|
int |
hashCode() |
boolean |
hasMainType(java.lang.String type)
Checks whether this media type has the given main type.
|
boolean |
hasParameter(java.lang.String attributeName)
Checks whether this parameter exists.
|
boolean |
hasSubType(java.lang.String subtype)
Checks whether this media type has the given sub type.
|
boolean |
hasType(java.lang.String type,
java.lang.String subtype)
Checks whether this media type has the given type.
|
java.lang.String |
toString()
Returns a string representation of this media type.
|
public ContentType(java.lang.String type,
java.lang.String subtype,
java.lang.String extension)
type - media type.subtype - media sub type.public ContentType(java.lang.String type,
java.lang.String subtype,
java.lang.String extension,
java.lang.String[][] parameterPairs)
type - media type.subtype - media sub type.parameterPairs - array of parameter key and value pairspublic static ContentType cloneAndSetParameters(ContentType original, java.lang.String[][] parameterPairsValues)
original - ContentType instance to clone.parameterPairs - array of parameter key and value pairspublic static ContentType cloneAndSetParameter(ContentType original, java.lang.String parameterKey, java.lang.String parameterValue)
original - ContentType instance to clone.parameterKey - key of the parameter.parameterValue - value of the parameters.public static ContentType cloneAndAddParameters(ContentType original, java.lang.String[][] parameterPairs)
original - ContentType instance to clone.parameterPairs - array of parameter key and value pairspublic static ContentType cloneAndAddParameter(ContentType original, java.lang.String parameterKey, java.lang.String parameterValue)
original - ContentType instance to clone.parameterKey - key of the parameter to add.parameterValue - value of the parameter to add.public void addParameter(java.lang.String parameterKey,
java.lang.String parameterValue)
parameterKey - key of the parameter.parameterValue - value of the parameter.public void addParameters(java.lang.String[][] parameterPairs)
parameterPairs - array of parameter key and value pairspublic java.lang.String getType()
public java.lang.String getSubtype()
public boolean hasType(java.lang.String type,
java.lang.String subtype)
type - the main type to check against. Case insensitive.subtype - the subtype to check against. Case insensitive.true if the object has the given type, false otherwise.public boolean hasMainType(java.lang.String type)
type - the main type to check against. Case insensitive.true if the object has the given type, false otherwise.public boolean hasSubType(java.lang.String subtype)
subtype - the sub type to check against. Case insensitive.true if the object has the given type, false otherwise.public java.lang.String getParameter(java.lang.String attributeName)
attributeName - the name of the attribute to get the value of. Case insensitive.public Iterator getParameterEntries()
public boolean hasParameter(java.lang.String attributeName)
attributeName - the parameter to check for.true if the object has the given parameter, false otherwise.public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String getExtension()