Package org.eclipse.birt.core.archive.compound

# Class ArchiveWriter

java.lang.Object
org.eclipse.birt.core.archive.compound.ArchiveWriter

All Implemented Interfaces:
  `IDocArchiveWriter`

Direct Known Subclasses:
  `FileArchiveWriter`

public class ArchiveWriter extends Object implements IDocArchiveWriter

## Constructor Summary

Constructors
Constructor
Description
`ArchiveWriter(String archiveName)`
`ArchiveWriter(IArchiveFile archive)`

## Method Summary

Modifier and Type
Method
Description
`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`
`getArchive()`
Deprecated.
use getArchiveFile instead
`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 namePattern)`
`Object`
`lock(String relativePath)`
try to lock the stream
`RAOutputStream`
`openRandomAccessStream(String relativePath)`
`void`
`setStreamSorter(IStreamSorter streamSorter)`
Set the stream sorter (if needed).
`void`
`unlock(Object locker)`
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

### ArchiveWriter

public ArchiveWriter(String archiveName) throws IOException

Throws:
  `IOException`

### ArchiveWriter

public ArchiveWriter(IArchiveFile archive) throws IOException

Throws:
  `IOException`

## Method Details

### getArchive

@Deprecated public IArchiveFile getArchive()
Deprecated.
use getArchiveFile instead

Returns:

### getArchiveFile

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

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

### 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)
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 `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.

### 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`

### 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`

### getName

public String getName()

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

### 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`

### 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

### lock

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

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

### unlock

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

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

### 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`

### listStreams

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

Specified by:
  `listStreams` in interface `IDocArchiveWriter`
Parameters:
  `namePattern` - - 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`