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 java.lang.Object implements IDocArchiveWriter, IDocArchiveReader
-
-
Constructor Summary
Constructors Constructor Description FolderArchive(java.lang.String folderName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This function must be called after the reader is used.RAOutputStream
createOutputStream(java.lang.String relativePath)
RAOutputStream
createRandomAccessStream(java.lang.String relativePath)
Create a random access stream in the archive and return it.boolean
dropStream(java.lang.String relativePath)
Delete a stream from the archive.boolean
exists(java.lang.String relativePath)
void
finish()
This function must be called after the writer is used.void
flush()
This function flushs all the buffers in the writerIArchiveFile
getArchiveFile()
Get archive fileRAInputStream
getInputStream(java.lang.String relativePath)
java.lang.String
getName()
RAOutputStream
getOutputStream(java.lang.String relativePath)
RAInputStream
getStream(java.lang.String relativePath)
returns a sequential access file.void
initialize()
This function must be called before the writer is used.boolean
isOpen()
java.util.List<java.lang.String>
listAllStreams()
get all the stream in the archive file.java.util.List<java.lang.String>
listStreams(java.lang.String relativeStoragePath)
java.lang.Object
lock(java.lang.String stream)
try to lock the streamvoid
open()
This functiona must be called before the reader is used.RAOutputStream
openRandomAccessStream(java.lang.String relativePath)
void
setStreamSorter(IStreamSorter streamSorter)
Set the stream sorter (if needed).void
unlock(java.lang.Object lock)
unlock the stream locked by the object.
-
-
-
Method Detail
-
initialize
public void initialize() throws java.io.IOException
Description copied from interface:IDocArchiveWriter
This function must be called before the writer is used. initialize the document archive.- Specified by:
initialize
in interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceIDocArchiveReader
- Specified by:
getName
in interfaceIDocArchiveWriter
- Returns:
- the archive name
-
createRandomAccessStream
public RAOutputStream createRandomAccessStream(java.lang.String relativePath) throws java.io.IOException
Description copied from interface:IDocArchiveWriter
Create a random access stream in the archive and return it.- Specified by:
createRandomAccessStream
in interfaceIDocArchiveWriter
- 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:
java.io.IOException
-
openRandomAccessStream
public RAOutputStream openRandomAccessStream(java.lang.String relativePath) throws java.io.IOException
- Specified by:
openRandomAccessStream
in interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
createOutputStream
public RAOutputStream createOutputStream(java.lang.String relativePath) throws java.io.IOException
- Specified by:
createOutputStream
in interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
getOutputStream
public RAOutputStream getOutputStream(java.lang.String relativePath) throws java.io.IOException
- Specified by:
getOutputStream
in interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
getInputStream
public RAInputStream getInputStream(java.lang.String relativePath) throws java.io.IOException
- Specified by:
getInputStream
in interfaceIDocArchiveReader
- Specified by:
getInputStream
in interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
dropStream
public boolean dropStream(java.lang.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 interfaceIDocArchiveWriter
- Parameters:
relativePath
- - the relative path of the stream- Returns:
- whether the operation was successful
-
exists
public boolean exists(java.lang.String relativePath)
- Specified by:
exists
in interfaceIDocArchiveReader
- Specified by:
exists
in interfaceIDocArchiveWriter
- 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 interfaceIDocArchiveWriter
- Parameters:
streamSorter
- - the stream sorter
-
finish
public void finish() throws java.io.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 interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
open
public void open() throws java.io.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 interfaceIDocArchiveReader
- Throws:
java.io.IOException
-
getStream
public RAInputStream getStream(java.lang.String relativePath) throws java.io.IOException
Description copied from interface:IDocArchiveReader
returns a sequential access file.- Specified by:
getStream
in interfaceIDocArchiveReader
- 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:
java.io.IOException
-
listStreams
public java.util.List<java.lang.String> listStreams(java.lang.String relativeStoragePath) throws java.io.IOException
- Specified by:
listStreams
in interfaceIDocArchiveReader
- Specified by:
listStreams
in interfaceIDocArchiveWriter
- 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:
java.io.IOException
-
listAllStreams
public java.util.List<java.lang.String> listAllStreams() throws java.io.IOException
Description copied from interface:IDocArchiveWriter
get all the stream in the archive file.- Specified by:
listAllStreams
in interfaceIDocArchiveReader
- Specified by:
listAllStreams
in interfaceIDocArchiveWriter
- Returns:
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Description copied from interface:IDocArchiveReader
This function must be called after the reader is used. close the archive.- Specified by:
close
in interfaceIDocArchiveReader
- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
-
flush
public void flush() throws java.io.IOException
Description copied from interface:IDocArchiveWriter
This function flushs all the buffers in the writer- Specified by:
flush
in interfaceIDocArchiveWriter
- Throws:
java.io.IOException
-
lock
public java.lang.Object lock(java.lang.String stream) throws java.io.IOException
Description copied from interface:IDocArchiveWriter
try to lock the stream- Specified by:
lock
in interfaceIDocArchiveReader
- Specified by:
lock
in interfaceIDocArchiveWriter
- Returns:
- the locker.
- Throws:
java.io.IOException
-
unlock
public void unlock(java.lang.Object lock)
Description copied from interface:IDocArchiveWriter
unlock the stream locked by the object.- Specified by:
unlock
in interfaceIDocArchiveReader
- Specified by:
unlock
in interfaceIDocArchiveWriter
- Parameters:
lock
- object returned by the lock().
-
getArchiveFile
public IArchiveFile getArchiveFile()
Description copied from interface:IDocArchiveWriter
Get archive file- Specified by:
getArchiveFile
in interfaceIDocArchiveWriter
- Returns:
-
-