Package org.eclipse.birt.core.archive

# Class FolderArchive

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

All Implemented Interfaces:
  `IDocArchiveReader`, `IDocArchiveWriter`

public class FolderArchive extends Object implements IDocArchiveWriter, IDocArchiveReader

## Constructor Summary

Constructors
Constructor
Description
`FolderArchive(String folderName)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
This function must be called after the reader is used.
`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.
`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)`
`RAInputStream`
`getStream(String relativePath)`
returns a sequential access file.
`void`
`initialize()`
This function must be called before the writer is used.
`boolean`
`isOpen()`
`List<String>`
`listAllStreams()`
get all the stream in the archive file.
`List<String>`
`listStreams(String relativeStoragePath)`
`Object`
`lock(String stream)`
try to lock the stream
`void`
`open()`
This functiona must be called before the reader is used.
`RAOutputStream`
`openRandomAccessStream(String relativePath)`
`void`
`setStreamSorter(IStreamSorter streamSorter)`
Set the stream sorter (if needed).
`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

### FolderArchive

public FolderArchive(String folderName) throws IOException

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

## Method Details

### initialize

public void initialize() throws IOException
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`
Throws:
  `IOException`

### getName

public String getName()

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

### 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 `IDocArchiveReader`
Specified by:
  `getInputStream` in interface `IDocArchiveWriter`
Throws:
  `IOException`

### dropStream

public boolean dropStream(String relativePath)
Description copied from interface: `IDocArchiveWriter`
Delete a stream from the archive. Note: Not all of the derived classes support this function. E.g. FileArchiveWriter doesn't support it.

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

### exists

public boolean exists(String relativePath)

Specified by:
  `exists` in interface `IDocArchiveReader`
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`

### open

public void open() throws IOException
Description copied from interface: `IDocArchiveReader`
This functiona must be called before the reader is used. initialize the document archive. For example, the index stream mey be read into memory.

Specified by:
  `open` in interface `IDocArchiveReader`
Throws:
  `IOException`

### getStream

public RAInputStream getStream(String relativePath) throws IOException
Description copied from interface: `IDocArchiveReader`
returns a sequential access file.

Specified by:
  `getStream` in interface `IDocArchiveReader`
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. Used mainly for sequential streams in report.
Returns:
  RAInputStream
Throws:
  `IOException`

### listStreams

public List<String> listStreams(String relativeStoragePath) throws IOException

Specified by:
  `listStreams` in interface `IDocArchiveReader`
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 `IDocArchiveReader`
Specified by:
  `listAllStreams` in interface `IDocArchiveWriter`
Returns:
Throws:
  `IOException`

### close

public void close() throws IOException
Description copied from interface: `IDocArchiveReader`
This function must be called after the reader is used. close the archive.

Specified by:
  `close` in interface `IDocArchiveReader`
Throws:
  `IOException`

### isOpen

public boolean isOpen()

### 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 `IDocArchiveReader`
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 `IDocArchiveReader`
Specified by:
  `unlock` in interface `IDocArchiveWriter`
Parameters:
  `lock` - object returned by the lock().

### getArchiveFile

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

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