@NotThreadSafe public class MimeType extends Object implements IMimeType, Comparable<MimeType>
| Constructor and Description |
|---|
MimeType(EMimeContentType eContentType,
String sContentSubType)
Constructor without parameters.
|
MimeType(EMimeContentType eContentType,
String sContentSubType,
Collection<? extends MimeTypeParameter> aParameters)
Constructor without parameters.
|
MimeType(IMimeType aOther)
Kind of a copy constructor
|
| Modifier and Type | Method and Description |
|---|---|
MimeType |
addParameter(MimeTypeParameter aParameter)
Add a parameter.
|
MimeType |
addParameter(String sAttribute,
String sValue)
Add a parameter.
|
int |
compareTo(MimeType o) |
boolean |
equals(Object o) |
List<MimeTypeParameter> |
getAllParameters() |
String |
getAsString()
Get the MIME type including all parameters as a single string.
|
String |
getAsString(EMimeQuoting eQuotingAlgorithm)
Get the MIME type including all parameters as a single string.
|
String |
getAsStringWithoutParameters() |
MimeType |
getClone() |
String |
getContentSubType() |
EMimeContentType |
getContentType() |
MimeType |
getCopyWithoutParameters() |
MimeTypeParameter |
getParameterAtIndex(int nIndex)
Get the parameter at the specified index.
|
int |
getParameterCount() |
String |
getParametersAsString(EMimeQuoting eQuotingAlgorithm)
Get all MIME type parameters as a single string but without the leading
content and sub type.
|
String |
getParameterValueWithName(String sParamName)
Get the value of the parameter with the specified name.
|
MimeTypeParameter |
getParameterWithName(String sParamName)
Get the parameter with the specified name.
|
boolean |
hasAnyParameters() |
int |
hashCode() |
boolean |
hasParameterWithName(String sParamName)
Check if a parameter with the specified name is present.
|
EChange |
removeAllParameters()
Remove all existing parameters.
|
EChange |
removeParameter(MimeTypeParameter aParameter)
Remove the specified parameter from this MIME type.
|
EChange |
removeParameterAtIndex(int nIndex)
Remove the parameter at the specified index.
|
EChange |
removeParameterWithName(String sParamName)
Remove the parameter with the specified name.
|
String |
toString() |
public MimeType(@Nonnull IMimeType aOther)
aOther - The other object to copy the data frompublic MimeType(@Nonnull EMimeContentType eContentType, @Nonnull @Nonempty String sContentSubType)
EMimeContentType.TEXT and the String "xml" to this
constructor.eContentType - MIME content type. May not be null.sContentSubType - MIME content sub type. May neither be null nor empty.public MimeType(@Nonnull EMimeContentType eContentType, @Nonnull @Nonempty String sContentSubType, @Nullable Collection<? extends MimeTypeParameter> aParameters)
EMimeContentType.TEXT and the String "xml" to this
constructor.eContentType - MIME content type. May not be null.sContentSubType - MIME content sub type. May neither be null nor empty.aParameters - MIME type parameters. May be null or empty.@Nonnull public EMimeContentType getContentType()
getContentType in interface IMimeTypenull.@Nonnull @Nonempty public String getContentSubType()
getContentSubType in interface IMimeTypenull.@Nonnull @Nonempty public String getAsString()
IMimeTypeCMimeType.DEFAULT_QUOTING quoting algorithm is used.getAsString in interface IHasStringRepresentationgetAsString in interface IMimeTypecontentType '/' subType ( ';' parameterName '=' parameterValue )*IMimeType.getAsString(EMimeQuoting),
IMimeType.getAsStringWithoutParameters()@Nonnull @Nonempty public String getAsString(@Nonnull EMimeQuoting eQuotingAlgorithm)
IMimeTypegetAsString in interface IMimeTypeeQuotingAlgorithm - Quoting algorithm to be usedcontentType '/' subType ( ';' parameterName '=' parameterValue )*IMimeType.getAsStringWithoutParameters(),
IMimeType.getParametersAsString(EMimeQuoting)@Nonnull public String getAsStringWithoutParameters()
getAsStringWithoutParameters in interface IMimeTypecontentType '/' subTypeIMimeType.getAsString()@Nonnull public String getParametersAsString(@Nonnull EMimeQuoting eQuotingAlgorithm)
IMimeTypegetParametersAsString in interface IMimeTypeeQuotingAlgorithm - Quoting algorithm to be used(';' parameterName '=' parameterValue )*
. If no parameters are present, an empty String is returned!IMimeType.getAsString(EMimeQuoting),
IMimeType.getAsStringWithoutParameters()@Nonnull public MimeType addParameter(@Nonnull @Nonempty String sAttribute, @Nonnull @Nonempty String sValue)
sAttribute - Parameter name. Must neither be null nor empty and must
match MimeTypeParser.isToken(String).sValue - The value to use. May neither be null nor empty. Must
not be a valid MIME token.@Nonnull public MimeType addParameter(@Nonnull MimeTypeParameter aParameter)
aParameter - The parameter to be added. May not be null.@Nonnull public EChange removeParameter(@Nullable MimeTypeParameter aParameter)
aParameter - The parameter to be removed. May be null.EChange.CHANGED if removal was successful@Nonnull public EChange removeParameterAtIndex(int nIndex)
nIndex - The index to remove. Should be ≥ 0.EChange.CHANGED if removal was successful@Nonnull public EChange removeAllParameters()
EChange.CHANGED if at least one parameter was present@Nonnull public EChange removeParameterWithName(@Nullable String sParamName)
sParamName - The name of the parameter to remove. May be null.EChange.CHANGED if the parameter was removed,
EChange.UNCHANGED otherwise.public boolean hasAnyParameters()
hasAnyParameters in interface IMimeTypetrue if at least one parameter is present,
false if no parameter is present.@Nonnegative public int getParameterCount()
getParameterCount in interface IMimeType@Nonnull @ReturnsMutableCopy public List<MimeTypeParameter> getAllParameters()
getAllParameters in interface IMimeTypenull but empty.@Nullable public MimeTypeParameter getParameterAtIndex(@Nonnegative int nIndex)
IMimeTypegetParameterAtIndex in interface IMimeTypenIndex - The index to use. Should be ≥ 0.null if the provided index is illegal.public boolean hasParameterWithName(@Nullable String sParamName)
IMimeTypehasParameterWithName in interface IMimeTypesParamName - The parameter name to search. May be null.true if such a parameter exists.@Nullable public MimeTypeParameter getParameterWithName(@Nullable String sParamName)
IMimeTypegetParameterWithName in interface IMimeTypesParamName - The parameter name to search. May be null.null if no such parameter exists.@Nullable public String getParameterValueWithName(@Nullable String sParamName)
IMimeTypegetParameterValueWithName in interface IMimeTypesParamName - The parameter name to search. May be null.null if no such parameter exists.@Nonnull public MimeType getClone()
getClone in interface ICloneable<IMimeType>@Nonnull public MimeType getCopyWithoutParameters()
getCopyWithoutParameters in interface IMimeTypenull.public int compareTo(MimeType o)
compareTo in interface Comparable<MimeType>Copyright © 2014–2016 Philip Helger. All rights reserved.