Package org.eclipse.birt.core.archive

# Class FolderArchiveWriter

java.lang.Object
org.eclipse.birt.core.archive.FolderArchiveWriter

All Implemented Interfaces:
  `IDocArchiveWriter`

public class FolderArchiveWriter extends Object implements IDocArchiveWriter

## Constructor Summary

Constructors
Constructor
Description
`FolderArchiveWriter(String folderName)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
`RAOutputStream`
`createOutputStream(String relativePath)`
`RAOutputStream`
`createRandomAccessStream(String relativePath)`
Create a random access stream in the archive and return it.
`boolean`
`dropStream(String relativePath)`
Delete a stream from the archive and make sure the stream has been closed.
`boolean`
`exists(String relativePath)`
`void`
`finish()`
This function must be called after the writer is used.
`void`
`flush()`
This function flushs all the buffers in the writer
`IArchiveFile`
`getArchiveFile()`
Get archive file
`RAInputStream`
`getInputStream(String relativePath)`
`String`
`getName()`
`RAOutputStream`
`getOutputStream(String relativePath)`
`void`
`initialize()`
This function must be called before the writer is used.
`List<String>`
`listAllStreams()`
get all the stream in the archive file.
`List<String>`
`listStreams(String relativeStoragePath)`
return a list of strings which are the relative path of streams
`Object`
`lock(String stream)`
try to lock the stream
`RAOutputStream`
`openRandomAccessStream(String relativePath)`
`void`
`setStreamSorter(IStreamSorter streamSorter)`
Set the stream sorter (if needed).
`void`
`toFileArchive(String fileArchiveName)`
Convert the current folder archive to file archive.
`void`
`unlock(Object lock)`
unlock the stream locked by the object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FolderArchiveWriter

public FolderArchiveWriter(String folderName) throws IOException

Parameters:
  `absolute` - fileName the archive file name
Throws:
  `IOException`

## Method Details

### initialize

public void initialize()
Description copied from interface: `IDocArchiveWriter`
This function must be called before the writer is used. initialize the document archive.

Specified by:
  `initialize` in interface `IDocArchiveWriter`

### createRandomAccessStream

public RAOutputStream createRandomAccessStream(String relativePath) throws IOException
Description copied from interface: `IDocArchiveWriter`
Create a random access stream in the archive and return it.

Specified by:
  `createRandomAccessStream` in interface `IDocArchiveWriter`
Parameters:
  `relativePath` - - relative path to report archive path. The path is based on Unix syntax, with the root of the archive denoted by "/". The initial "/" character can be skipped.
Returns:
  RAOutputStream
Throws:
  `IOException`

### openRandomAccessStream

public RAOutputStream openRandomAccessStream(String relativePath) throws IOException

Specified by:
  `openRandomAccessStream` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### createOutputStream

public RAOutputStream createOutputStream(String relativePath) throws IOException

Specified by:
  `createOutputStream` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### getOutputStream

public RAOutputStream getOutputStream(String relativePath) throws IOException

Specified by:
  `getOutputStream` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### getInputStream

public RAInputStream getInputStream(String relativePath) throws IOException

Specified by:
  `getInputStream` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### dropStream

public boolean dropStream(String relativePath)
Delete a stream from the archive and make sure the stream has been closed.

Specified by:
  `dropStream` in interface `IDocArchiveWriter`
Parameters:
  `relativePath` - - the relative path of the stream
Returns:
  whether the delete operation was successful
Throws:
  `IOException`

### getName

public String getName()

Specified by:
  `getName` in interface `IDocArchiveWriter`
Returns:
  the archive name

### exists

public boolean exists(String relativePath)

Specified by:
  `exists` in interface `IDocArchiveWriter`
Parameters:
  `relativePath` - - the relative stream path in the archive. The relative path is based on Unix syntax, with the root of the archive denoted by "/". The initial "/" character can be skipped.
Returns:
  a list of strings representing the underlying stream names. The return values are in the relative path format too.

### setStreamSorter

public void setStreamSorter(IStreamSorter streamSorter)
Description copied from interface: `IDocArchiveWriter`
Set the stream sorter (if needed). The stream sorter will be used to sort the streams. If no stream sorter is set, the streams will be written in random order.

Specified by:
  `setStreamSorter` in interface `IDocArchiveWriter`
Parameters:
  `streamSorter` - - the stream sorter

### finish

public void finish() throws IOException
Description copied from interface: `IDocArchiveWriter`
This function must be called after the writer is used. finalizes the socument archive. This may involve compressing the archive to a single file. This also closes and finishes using the archive.

Specified by:
  `finish` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### close

public void close() throws IOException

Throws:
  `IOException`

### toFileArchive

public void toFileArchive(String fileArchiveName) throws IOException
Convert the current folder archive to file archive. The original folder archive will NOT be removed.

Parameters:
  `fileArchiveName` -
Throws:
  `IOException`

### flush

public void flush() throws IOException
Description copied from interface: `IDocArchiveWriter`
This function flushs all the buffers in the writer

Specified by:
  `flush` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### lock

public Object lock(String stream) throws IOException
Description copied from interface: `IDocArchiveWriter`
try to lock the stream

Specified by:
  `lock` in interface `IDocArchiveWriter`
Parameters:
  `stream` -
Returns:
  the locker.
Throws:
  `IOException`

### unlock

public void unlock(Object lock)
Description copied from interface: `IDocArchiveWriter`
unlock the stream locked by the object.

Specified by:
  `unlock` in interface `IDocArchiveWriter`
Parameters:
  `lock` - object returned by the lock().

### listStreams

public List<String> listStreams(String relativeStoragePath) throws IOException
return a list of strings which are the relative path of streams

Specified by:
  `listStreams` in interface `IDocArchiveWriter`
Parameters:
  `relativeStoragePath` - - the relative stream path in the archive. The relative path is based on Unix syntax, with the root of the archive denoted by "/". The initial "/" character can be skipped.
Returns:
  a list of strings representing the underlying stream names. The return values are in the relative path format too.
Throws:
  `IOException`

### listAllStreams

public List<String> listAllStreams() throws IOException
Description copied from interface: `IDocArchiveWriter`
get all the stream in the archive file.

Specified by:
  `listAllStreams` in interface `IDocArchiveWriter`
Returns:
Throws:
  `IOException`

### getArchiveFile

public IArchiveFile getArchiveFile()
Description copied from interface: `IDocArchiveWriter`
Get archive file

Specified by:
  `getArchiveFile` in interface `IDocArchiveWriter`
Returns: