org.objectweb.jac.lib
Class Attachment

java.lang.Object
  |
  +--org.objectweb.jac.lib.Attachment

public class Attachment
extends Object

This class represents a file attachment. The data field is the content of the file.


Constructor Summary
Attachment(byte[] data, String mimeType, String name)
          Creates a new Attachement object.
 
Method Summary
 byte[] getData()
          Returns the content of the attachment.
 String getMimeType()
           
 String getName()
           
static Object getType(FieldItem field, Attachment attachment)
           
 void guessMimeType()
           
 void setData(byte[] data)
          Set the content of the file
 void setMimeType(String mimeType)
          Sets the mime type of the file.
 void setName(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Attachment

public Attachment(byte[] data,
                  String mimeType,
                  String name)
Creates a new Attachement object. If the mimeType is null, it will be initialized from the name's extension.

Method Detail

guessMimeType

public void guessMimeType()

getData

public byte[] getData()
Returns the content of the attachment.

Returns:
the file's content.
See Also:
setData(byte[])

setData

public void setData(byte[] data)
Set the content of the file

Parameters:
data - the content of the file
See Also:
getData()

getMimeType

public String getMimeType()
Returns:
the mime type of the file (text/plain, text/html, application/msword, ...)
See Also:
setMimeType(String)

setMimeType

public void setMimeType(String mimeType)
Sets the mime type of the file.

Parameters:
mimeType - the mime type of the file.
See Also:
getMimeType()

getName

public String getName()
Returns:
the name of the file
See Also:
setName(String)

setName

public void setName(String name)
Parameters:
name - the name of the file
See Also:
getName()

getType

public static Object getType(FieldItem field,
                             Attachment attachment)