com.sun.slamd.server
Class UploadedFile

java.lang.Object
  extended bycom.sun.slamd.server.UploadedFile

public class UploadedFile
extends java.lang.Object

This class defines a data type to hold information about a file that has been uploaded and stored in the SLAMD configuration directory.


Field Summary
static java.lang.String ELEMENT_DATA
          The name of the enocded element that holds the uploaded file data.
static java.lang.String ELEMENT_DESCRIPTION
          The name of the enocded element that holds the description for the uploaded file.
static java.lang.String ELEMENT_NAME
          The name of the enocded element that holds the name of the uploaded file.
static java.lang.String ELEMENT_SIZE
          The name of the enocded element that holds the size of the uploaded file.
static java.lang.String ELEMENT_TYPE
          The name of the enocded element that holds the type of the uploaded file.
 
Constructor Summary
UploadedFile(java.lang.String fileName, java.lang.String fileType, int fileSize, java.lang.String fileDescription)
          Creates a new uploaded file with just summary information (no actual file data).
UploadedFile(java.lang.String fileName, java.lang.String fileType, int fileSize, java.lang.String fileDescription, byte[] fileData)
          Creates a new uploaded file including the file data.
 
Method Summary
static UploadedFile decode(byte[] encodedFile)
          Decodes the provided byte array as an uploaded file.
static UploadedFile decodeWithoutData(byte[] encodedFile)
          Decodes the provided byte array as an uploaded file, but excluding the actual file data.
 byte[] encode()
          Encodes information about this uploaded file into a byte array.
 byte[] getFileData()
          Retrieves the actual file data.
 java.lang.String getFileDescription()
          Retrieves the description for the file.
 java.lang.String getFileName()
          Retrieves the name of the uploaded file.
 int getFileSize()
          Retrieves the size of the file in bytes.
 java.lang.String getFileType()
          Retrieves the MIME type for the uploaded file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_NAME

public static final java.lang.String ELEMENT_NAME
The name of the enocded element that holds the name of the uploaded file.

See Also:
Constant Field Values

ELEMENT_SIZE

public static final java.lang.String ELEMENT_SIZE
The name of the enocded element that holds the size of the uploaded file.

See Also:
Constant Field Values

ELEMENT_TYPE

public static final java.lang.String ELEMENT_TYPE
The name of the enocded element that holds the type of the uploaded file.

See Also:
Constant Field Values

ELEMENT_DESCRIPTION

public static final java.lang.String ELEMENT_DESCRIPTION
The name of the enocded element that holds the description for the uploaded file.

See Also:
Constant Field Values

ELEMENT_DATA

public static final java.lang.String ELEMENT_DATA
The name of the enocded element that holds the uploaded file data.

See Also:
Constant Field Values
Constructor Detail

UploadedFile

public UploadedFile(java.lang.String fileName,
                    java.lang.String fileType,
                    int fileSize,
                    java.lang.String fileDescription)
Creates a new uploaded file with just summary information (no actual file data).

Parameters:
fileName - The name of the file.
fileType - The MIME type for the file.
fileSize - The size of the file in bytes.
fileDescription - A brief description of the file.

UploadedFile

public UploadedFile(java.lang.String fileName,
                    java.lang.String fileType,
                    int fileSize,
                    java.lang.String fileDescription,
                    byte[] fileData)
Creates a new uploaded file including the file data.

Parameters:
fileName - The name of the file.
fileType - The MIME type for the file.
fileSize - The size of the file in bytes.
fileDescription - A brief description of the file.
fileData - The actual data contained in the file.
Method Detail

getFileName

public java.lang.String getFileName()
Retrieves the name of the uploaded file.

Returns:
The name of the uploaded file.

getFileType

public java.lang.String getFileType()
Retrieves the MIME type for the uploaded file.

Returns:
The MIME type for the uploaded file.

getFileSize

public int getFileSize()
Retrieves the size of the file in bytes.

Returns:
The size of the file in bytes.

getFileDescription

public java.lang.String getFileDescription()
Retrieves the description for the file.

Returns:
The description for the file.

getFileData

public byte[] getFileData()
Retrieves the actual file data.

Returns:
The actual file data, or null if no file data has been provided.

encode

public byte[] encode()
Encodes information about this uploaded file into a byte array.

Returns:
The byte array containing the encoded file data.

decode

public static UploadedFile decode(byte[] encodedFile)
                           throws DecodeException
Decodes the provided byte array as an uploaded file.

Parameters:
encodedFile - The byte array containing the deata to decode.
Returns:
The decoded file.
Throws:
DecodeException - If a problem occurs while trying to decode the provided byte array as an uploaded file.

decodeWithoutData

public static UploadedFile decodeWithoutData(byte[] encodedFile)
                                      throws DecodeException
Decodes the provided byte array as an uploaded file, but excluding the actual file data.

Parameters:
encodedFile - The byte array containing the deata to decode.
Returns:
The decoded file, excluding the file data.
Throws:
DecodeException - If a problem occurs while trying to decode the provided byte array as an uploaded file.