com.atlassian.crucible.spi.services
Interface FileData


public interface FileData

This interface is used by SPI users to feed a file to Crucible. It provides information about the file's content and gives access to its data by writing it to an OutputStream.

Author:
Erik van Zijst
See Also:
ReviewService.addFileToReview(com.atlassian.crucible.spi.PermId, FileData, FileData)

Method Summary
 void close()
          Releases all resources under this instance.
 java.lang.String getCharSet()
          Specifies the character set of the contents for text files (e.g.
 void getContents(java.io.OutputStream out)
          Writes the contents of the file data to the given OutputStream.
 java.lang.String getContentType()
          Returns the content type, e.g.
 java.lang.String getDescription()
          Returns a string describing the content, or null when not provided.
 java.lang.String getName()
          Returns the original name of the resource.
 

Method Detail

getContents

void getContents(java.io.OutputStream out)
                 throws java.io.IOException,
                        java.lang.IllegalStateException
Writes the contents of the file data to the given OutputStream.

The implementation does not close the given stream when finished and it is the responsibility of the caller to close the OutputStream when appropriate.

Note that the data represented by an instance of this interface may not be present as a file on disk, but may in fact be provided by a real-time stream. As a result, the data can be read only once and this method should not be called for a second time.

Parameters:
out -
Throws:
java.io.IOException - when an error occured while writing the contents to the specified OutputStream.
java.lang.IllegalStateException - when the content has already been written to a stream (this happens when this method is called for a second time).

getContentType

java.lang.String getContentType()
Returns the content type, e.g. "text/plain".

Returns:
the content type, e.g. "text/plain".

getName

java.lang.String getName()
Returns the original name of the resource. In cases where an instance of this interface represents a file, this method should return the original file name.

Returns:
the original name of the resource.

getCharSet

java.lang.String getCharSet()
Specifies the character set of the contents for text files (e.g. "UTF-8"). When returning null, Crucible will use the server's default character set.

Returns:

getDescription

java.lang.String getDescription()
Returns a string describing the content, or null when not provided.

Returns:
a string describing the content.

close

void close()
Releases all resources under this instance.