|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.util.ContentType
public class ContentType
Represents a Content Type (MIME type) string. Most of the work is done by the {link #parseContentType} factory method.
This takes care of things like optional whitespace and case folding,
so for instance if ctypeTxt
has the value
APPLICATION / X-VOTABLE+XML ; content=datalink; CHARSET="iso\-8859\-1"then
ContentType ctype = CointentType.parse(ctypeTxt); assert ctype.matches("application", "x-votable+xml"); assert ctype.getParameter("charset").equals("iso-8859-1");
Constructor Summary | |
---|---|
ContentType(java.lang.String type,
java.lang.String subtype)
Constructs a ContentType from type and subtype strings. |
|
ContentType(java.lang.String type,
java.lang.String subtype,
java.util.Map<java.lang.String,java.lang.String> params)
Constructs a ContentType from its constituent parts. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object o)
|
java.lang.String |
getParameter(java.lang.String paramName)
Returns the value of a parameter of this content type. |
java.util.Map<java.lang.String,java.lang.String> |
getParameters()
Returns the parameter name/value pairs of this content type. |
java.lang.String |
getSubtype()
Returns the Subtype part of this content type. |
java.lang.String |
getType()
Returns the Type part of this content type. |
int |
hashCode()
|
static void |
main(java.lang.String[] args)
Parses a single content-type string supplied on the command line, and prints a representation of the parsed form on standard output. |
boolean |
matches(java.lang.String type,
java.lang.String subtype)
Indicates whether the type and subtype match a given pair. |
static ContentType |
parseContentType(java.lang.String txt)
Parses a Content-Type (MIME type) string in accordance with the syntax rules in RFC2045. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ContentType(java.lang.String type, java.lang.String subtype)
type
- type partsubtype
- subtype partpublic ContentType(java.lang.String type, java.lang.String subtype, java.util.Map<java.lang.String,java.lang.String> params)
type
- type partsubtype
- subtype partparams
- map of parametersMethod Detail |
---|
public java.lang.String getType()
public java.lang.String getSubtype()
public java.util.Map<java.lang.String,java.lang.String> getParameters()
public boolean matches(java.lang.String type, java.lang.String subtype)
type
- required type part (case-insensitive)subtype
- required subtype part (case-insensitive)
public java.lang.String getParameter(java.lang.String paramName)
paramName
- parameter name (case-insensitive)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static ContentType parseContentType(java.lang.String txt)
type/subtype[;p1=v1;p2=v2...]
".
It may not be completely bulletproof, but should do a fairly
good job of the parse. However, it makes no attempt to
restrict the type or subtype to IANA-approved values,
and it may parse some strings which are not strictly legal.
Null is returned if the string cannot be parsed.
txt
- content-type string of the approximate form
type/subtype(;param=value)*
txt
can be parsed,
otherwise nullpublic static void main(java.lang.String[] args)
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |