|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.util.parse.Parser
simple.util.parse.ContentParser
public class ContentParser
ContentParser
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
. If the String
that is being parsed does not contain a type or subtype then the
toString
will return the value null/null otherwise
it will recreate the MIME type.
Field Summary |
---|
Fields inherited from class simple.util.parse.Parser |
---|
buf, count, off |
Constructor Summary | |
---|---|
ContentParser()
The default constructor will create a ContentParser
that contains no charset, type or subtype. |
|
ContentParser(java.lang.String header)
This is primarily a convineance constructor. |
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. |
protected void |
init()
This will initialize the parser when it is ready to parse a new String . |
protected void |
parse()
Reads and parses the MIME type from the given String
object. |
void |
setCharset(java.lang.String enc)
This will set the charset to whatever value is in the
String object. |
void |
setPrimary(java.lang.String primary)
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. |
Methods inherited from class simple.util.parse.Parser |
---|
digit, ensureCapacity, parse, skip, space, toLower |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ContentParser()
ContentParser
that contains no charset, type or subtype. This can be used to
extract the type, subtype and the optional charset
parameter by using the parser's parse(String)
method.
public ContentParser(java.lang.String header)
String
given to extract the MIME type. This
could be achived by calling the default no-arg constructor
and then using the instance to invoke the parse
method on that String
.
header
- String
containing a MIME type valueMethod Detail |
---|
public void setPrimary(java.lang.String primary)
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
.
setPrimary
in interface ContentType
primary
- the type to add to the MIME typepublic java.lang.String getPrimary()
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
.
getPrimary
in interface ContentType
public void setSecondary(java.lang.String type)
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
.
setSecondary
in interface ContentType
type
- the type to add to the MIME typepublic java.lang.String getSecondary()
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
.
getSecondary
in interface ContentType
public void setCharset(java.lang.String enc)
charset
to whatever value is in the
String
object. If the String
object is
null
the this object's 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.
setCharset
in interface ContentType
enc
- the charset
value to add to the MIME typepublic java.lang.String getCharset()
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
.
getCharset
in interface ContentType
charset
value for the MIME typeprotected void init()
String
. This will reset the parser to a
ready state. The init method is invoked by the parser when
the Parser.parse
method is invoked.
init
in class Parser
protected void parse()
String
object. This uses the syntax defined by RFC 2616 for the media-type
syntax. This parser is only concerned with one parameter, the
charset
parameter. The syntax for thhe media type is
media-type = token "/" token *( ";" parameter ) parameter = token | literal
parse
in class Parser
public java.lang.String toString()
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.
toString
in interface ContentType
toString
in class java.lang.Object
String
representation of the MIME type
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |