|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.hunnysoft.jmime.Node
com.hunnysoft.jmime.FieldBody
com.hunnysoft.jmime.MediaType
Class that represents a MIME media-type.
MediaType represents a field body for the
Content-Type header field as described in RFC 2045. This
field body identifies the kind of data contained in the body of a
message or body part. A media type is described by two keywords: a
primary type (or just type) and a subtype. RFC 2046
specifies the seven primary types text, multipart,
message, image, audio,
video, and application. RFC 2077 adds the
new primary type model.
MediaType has methods that allow you to set or get the
type and subtype as byte strings. It also contains a list of Parameter objects that represent the parameters of the field body.
| Field Summary | |
static int |
APPLICATION
Enumerated value for application type |
static int |
AUDIO
Enumerated value for audio type |
static int |
IMAGE
Enumerated value for image type |
static int |
MESSAGE
Enumerated value for message type |
static int |
MODEL
Enumerated value for model type |
static int |
MULTIPART
Enumerated value for multipart type |
static int |
NULL
Enumerated value for unset type |
static int |
TEXT
Enumerated value for text type |
static int |
UNKNOWN
Enumerated value for unknown type |
static int |
VIDEO
Enumerated value for video type |
| Fields inherited from class com.hunnysoft.jmime.FieldBody |
mText |
| Fields inherited from class com.hunnysoft.jmime.Node |
mIsModified, mParent, mString |
| Constructor Summary | |
MediaType()
Default constructor. |
|
MediaType(ByteString bstr)
Constructor that takes an initial byte string argument. |
|
MediaType(MediaType other)
Copy constructor. |
|
| Method Summary | |
void |
addParameter(Parameter param)
Adds a parameter to the end of the list. |
void |
assemble()
Assembles the string representation. |
java.lang.String |
boundary()
Gets the value of the boundary parameter, if present. |
java.lang.String |
charset()
Gets the value of the charset parameter, if present. |
java.lang.Object |
clone()
Creates a copy of this object. |
java.lang.String |
createBoundary(int level)
Creates a string suitable for use as a boundary parameter. |
void |
deleteAllParameters()
Deletes all parameters in the list. |
void |
insertParameterAt(int index,
Parameter param)
Inserts a parameter at the specified position. |
java.lang.String |
name()
Gets the value of the name parameter, if present. |
int |
numParameters()
Gets the number of parameters in the list. |
Parameter |
parameterAt(int index)
Gets the parameter at the specified position. |
void |
parse()
Parses the string representation. |
Parameter |
removeParameterAt(int index)
Removes the parameter at the specified position. |
void |
setBoundary(java.lang.String str)
Sets the value of the boundary parameter. |
void |
setCharset(java.lang.String str)
Sets the value of the charset parameter. |
void |
setName(java.lang.String str)
Sets the value of the name parameter. |
void |
setSubtype(java.lang.String subtype)
Sets the subtype. |
void |
setType(java.lang.String type)
Sets the primary type. |
java.lang.String |
subtype()
Gets the subtype. |
java.lang.String |
type()
Gets the primary type. |
int |
typeAsEnum()
Gets the primary type as an enumerated value. |
void |
typeFromEnum(int type)
Sets the primary type from an enumerated value. |
| Methods inherited from class com.hunnysoft.jmime.FieldBody |
fold, isFoldingEnabled, maybeFold, setFoldingEnabled, setText, text, unfold |
| Methods inherited from class com.hunnysoft.jmime.Node |
_setString, isModified, parent, setModified, setParent, setString, string, toString |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int NULL
public static final int UNKNOWN
public static final int TEXT
public static final int IMAGE
public static final int AUDIO
public static final int VIDEO
public static final int APPLICATION
public static final int MESSAGE
public static final int MULTIPART
public static final int MODEL
| Constructor Detail |
public MediaType()
This constructor sets the MediaType object's string
representation to the empty string and sets its parent node to
null. The list of Parameter objects is
initially empty.
public MediaType(MediaType other)
This constructor performs a deep copy of its argument. The
parent node of the new MediaType object is set to
null.
other - MediaType instance to copypublic MediaType(ByteString bstr)
This constructor sets the MediaType object's string
representation to bstr and sets its parent node to
null.
Normally, you call the parse() method immediately after
this constructor to create the broken-down representation.
bstr - initial value for the string representation| Method Detail |
public java.lang.Object clone()
This method, inherited from Object, creates a new
MediaType object that has the same value as this
MediaType object. The parent node of the new
MediaType object is set to null.
clone in class FieldBodypublic java.lang.String type()
public void setType(java.lang.String type)
type - primary typepublic java.lang.String subtype()
public void setSubtype(java.lang.String subtype)
subtype - subtypepublic int typeAsEnum()
public void typeFromEnum(int type)
type - primary type enumerated valuepublic java.lang.String boundary()
The boundary parameter is required if the primary type is multipart. If there is no boundary parameter, this method returns an empty string.
This method is a convenience method that searches the list of
Parameter objects.
public void setBoundary(java.lang.String str)
The boundary parameter is required if the primary type is multipart. If no boundary parameter exists when you call this method, the method creates a new boundary parameter and adds it to the list.
This method is a convenience method that accesses the list of
Parameter objects.
str - value of the boundary parameterpublic java.lang.String createBoundary(int level)
This method is a convenience method that creates a random string suitable for use as a multipart boundary. The method sets newly created string as the value of the boundary field.
level - indicates the level of nesting
public java.lang.String name()
The name parameter is often found in several media types, including the application/octet-stream media type. It suggests a file name for saving the content to a disk file. (The filename parameter in the content-disposition header field is an alternative way to indicate a file name.)
If there is no name parameter, the method returns an empty string.
This method is a convenience method that searches the list of
Parameter objects.
public void setName(java.lang.String str)
The name parameter is often found in several media types, including the application/octet-stream media type. It suggests a file name for saving the content to a disk file. (The filename parameter in the content-disposition header field is an alternative way to indicate a file name.)
If a name parameter is not already present, this method adds it.
This method is a convenience method that accesses the list of
Parameter objects.
str - value of the name parameterpublic java.lang.String charset()
The charset parameter is often found in text media types. It indicates the character encoding of the text content.
If there is no charset parameter, the method returns an empty string.
This method is a convenience method that searches the list of
Parameter objects.
public void setCharset(java.lang.String str)
The charset parameter is often found in text media types. It indicates the character encoding of the text content.
If a charset parameter is not already present, this method adds it.
This method is a convenience method that accesses the list of
Parameter objects.
str - value of the charset parameterpublic void parse()
This method, inherited from Node, executes the parse
operation for MediaType objects. The parse operation
creates or updates the broken-down representation from the string
representation. For MediaType objects, the parse
operation parses the string representation to extract the type,
subtype, and the list of Parameter objects. This
method also calls the parse() method of each
Parameter object in its list.
You should call this method after you set or modify the string
representation, and before you access the type, subtype, or any of
the contained Parameter objects.
This method clears the is-modified flag.
parse in class FieldBodypublic void assemble()
This method, inherited from Node, executes the assemble
operation for MediaType objects. The assemble
operation creates or updates the string representation from the
broken-down representation. For MediaType objects, the
assemble operation builds the string representation from the type,
subtype, and list of Parameter objects. Before it builds
the string representation for the MediaType object,
this method first calls the assemble() method of each
Parameter object in its list.
You should call this method after you set or modify the type,
subtype, or any of the contained Parameter objects, and
before you retrieve the string representation.
This method clears the is-modified flag.
assemble in class FieldBodypublic int numParameters()
public void addParameter(Parameter param)
param - Parameter object to addpublic void deleteAllParameters()
public Parameter parameterAt(int index)
index - position of the Parameter object to get
(0 <= index < numParameters())
Parameter object at the specified position
java.lang.IndexOutOfBoundsException - if index is out of range
public void insertParameterAt(int index,
Parameter param)
Inserting at position 0 inserts the parameter at the beginning.
Inserting at position numParameters() appends the
parameter to the end.
index - position in the list to insert the
Parameter object
(0 <= index <= numParameters())param - Parameter object to insert
java.lang.IndexOutOfBoundsException - if index is out of rangepublic Parameter removeParameterAt(int index)
index - position of the Parameter object to remove
(0 <= index < numParameters())
Parameter object
java.lang.IndexOutOfBoundsException - if index is out of range
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||