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

# Class ArchiveFileV2

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

All Implemented Interfaces:
  `IArchiveFile`

public class ArchiveFileV2 extends Object implements IArchiveFile
the archive file contains following mode:
- "r" open the file for read only.
- "rw" create the file for read/write
- "rw+" open file is open for read/write
- "rwt" create the transient file, it will be removed after closing.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ALLOC_TABLE_BLOCK`
the first block of allocation table
`protected org.eclipse.birt.core.archive.compound.AllocTable`
`allocTbl`
allocation table of the archive file
`protected String`
`archiveName`
the archive file name.
`protected int`
`BLOCK_SIZE`
`protected org.eclipse.birt.core.archive.cache.FileCacheManager`
`caches`
cache manager of the archive file.
`static final int`
`DEFAULT_BLOCK_SIZE`
Size of a physical block, counted in bytes.
`static final int`
`DEFAULT_BUFFER_POOL_SIZE`
default size of buffer pool - number of buffer blocks in buffer pool
`protected String`
`dependId`
`static final long`
`DOCUMENT_TAG`
The magic tag of the archive file: "RPTDOC"
`static final long`
`DOCUMENT_VERSION_0`
After support system id in archive file, DOCUMENT_VERSION_1 is writen into header.
`static final long`
`DOCUMENT_VERSION_1`
`protected HashMap<String,org.eclipse.birt.core.archive.compound.NameEntry>`
`entries`
archive entries in the table
`static final int`
`ENTRY_ITEM_SIZE`
the size of a entry in the entry table, counted in bytes
`static final int`
`ENTRY_TABLE_BLOCK`
the first block of entry table
`protected org.eclipse.birt.core.archive.compound.NameTable`
`entryTbl`
entry table of the archive file
`static final int`
`FILE_STATUS_FINISHED`
File status value: finished
`protected org.eclipse.birt.core.archive.compound.ArchiveHeader`
`head`
header status
`static final int`
`HEADER_BLOCK`
the block of archive header
`protected boolean`
`isAppend`
the archive file is appended.
`protected boolean`
`isClosed`
if the file is closed.
`protected boolean`
`isTransient`
the archive file is transient.
`protected boolean`
`isWritable`
the archive file is writable.
`static final int`
`MIN_BUFFER_POOL_SIZE`
Min size of buffer pool - number of buffer blocks in buffer pool
`static final String`
`PROPERTY_DEFAULT_BLOCK_SIZE`
the system property defines the block size, it should be times of 1024.
`protected RandomAccessFile`
`rf`
the physical file correspond to this compound file system
`protected String`
`systemId`
`protected int`
`totalBlocks`
the total blocks exits in this file
`protected int`
`totalDiskBlocks`
the total blocks exits in the disk

## Constructor Summary

Constructors
Constructor
Description
`ArchiveFileV2(String fileName, RandomAccessFile rf, String mode)`
create the archive file.
`ArchiveFileV2(String fileName, String mode)`
`ArchiveFileV2(String systemId, String fileName, String mode)`
`ArchiveFileV2(String systemId, String dependId, String fileName, RandomAccessFile rf, String mode)`
create the archive file.
`ArchiveFileV2(String systemId, String dependId, String fileName, String mode)`

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
close the archive.
`protected Block`
`createBlock()`
`ArchiveEntry`
`createEntry(String name)`
`boolean`
`exists(String name)`
`void`
`flush()`
`String`
`getDependId()`
`long`
`getLength()`
`String`
`getName()`
get the archive name.
`String`
`getSystemId()`
`long`
`getUsedCache()`
`List<String>`
`listEntries(String namePattern)`
`Object`
`lockEntry(String name)`
`ArchiveEntry`
`openEntry(String name)`
`void`
`refresh()`
`boolean`
`removeEntry(String name)`
`void`
`save()`
`void`
`setCacheSize(long cacheSize)`
set up the cache size.
`protected void`
`unloadBlock(Block block)`
`void`
`unlockEntry(Object locker)`

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

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

## Field Details

### rf

protected RandomAccessFile rf
the physical file correspond to this compound file system

### isClosed

protected boolean isClosed
if the file is closed.

### isWritable

protected boolean isWritable
the archive file is writable.

### isTransient

protected boolean isTransient
the archive file is transient.

### isAppend

protected boolean isAppend
the archive file is appended.

### archiveName

protected String archiveName
the archive file name.

### systemId

protected String systemId

### dependId

protected String dependId

### BLOCK_SIZE

protected int BLOCK_SIZE

### head

protected org.eclipse.birt.core.archive.compound.ArchiveHeader head
header status

### allocTbl

protected org.eclipse.birt.core.archive.compound.AllocTable allocTbl
allocation table of the archive file

### entryTbl

protected org.eclipse.birt.core.archive.compound.NameTable entryTbl
entry table of the archive file

### entries

protected HashMap<String,org.eclipse.birt.core.archive.compound.NameEntry> entries
archive entries in the table

### caches

protected org.eclipse.birt.core.archive.cache.FileCacheManager caches
cache manager of the archive file.

### totalBlocks

protected int totalBlocks
the total blocks exits in this file

### totalDiskBlocks

protected int totalDiskBlocks
the total blocks exits in the disk

### DOCUMENT_TAG

static final long DOCUMENT_TAG
The magic tag of the archive file: "RPTDOC"

See Also:
  - Constant Field Values

### DOCUMENT_VERSION_0

static final long DOCUMENT_VERSION_0
After support system id in archive file, DOCUMENT_VERSION_1 is writen into header.

See Also:
  - Constant Field Values

### DOCUMENT_VERSION_1

static final long DOCUMENT_VERSION_1

See Also:
  - Constant Field Values

### PROPERTY_DEFAULT_BLOCK_SIZE

static final String PROPERTY_DEFAULT_BLOCK_SIZE
the system property defines the block size, it should be times of 1024.

See Also:
  - Constant Field Values

### DEFAULT_BLOCK_SIZE

static final int DEFAULT_BLOCK_SIZE
Size of a physical block, counted in bytes.

See Also:
  - Constant Field Values

### HEADER_BLOCK

static final int HEADER_BLOCK
the block of archive header

See Also:
  - Constant Field Values

### ALLOC_TABLE_BLOCK

static final int ALLOC_TABLE_BLOCK
the first block of allocation table

See Also:
  - Constant Field Values

### ENTRY_TABLE_BLOCK

static final int ENTRY_TABLE_BLOCK
the first block of entry table

See Also:
  - Constant Field Values

### ENTRY_ITEM_SIZE

static final int ENTRY_ITEM_SIZE
the size of a entry in the entry table, counted in bytes

See Also:
  - Constant Field Values

### FILE_STATUS_FINISHED

static final int FILE_STATUS_FINISHED
File status value: finished

See Also:
  - Constant Field Values

### DEFAULT_BUFFER_POOL_SIZE

static final int DEFAULT_BUFFER_POOL_SIZE
default size of buffer pool - number of buffer blocks in buffer pool

See Also:
  - Constant Field Values

### MIN_BUFFER_POOL_SIZE

static final int MIN_BUFFER_POOL_SIZE
Min size of buffer pool - number of buffer blocks in buffer pool

See Also:
  - Constant Field Values

## Constructor Details

### ArchiveFileV2

public ArchiveFileV2(String fileName, RandomAccessFile rf, String mode) throws IOException
create the archive file.

Parameters:
  `fileName` - file name.
  `rf` - the random access file
  `mode` - open mode.
Throws:
  `IOException`

### ArchiveFileV2

public ArchiveFileV2(String fileName, String mode) throws IOException

Throws:
  `IOException`

### ArchiveFileV2

public ArchiveFileV2(String systemId, String fileName, String mode) throws IOException

Throws:
  `IOException`

### ArchiveFileV2

public ArchiveFileV2(String systemId, String dependId, String fileName, String mode) throws IOException

Throws:
  `IOException`

### ArchiveFileV2

public ArchiveFileV2(String systemId, String dependId, String fileName, RandomAccessFile rf, String mode) throws IOException
create the archive file.

Parameters:
  `fileName` - file name.
  `mode` - open mode.
Throws:
  `IOException`

## Method Details

### setCacheSize

public void setCacheSize(long cacheSize)
set up the cache size. the actually cache size is round to block size.

Specified by:
  `setCacheSize` in interface `IArchiveFile`
Parameters:
  `cacheSize` - cache size in bytes

### getUsedCache

public long getUsedCache()

Specified by:
  `getUsedCache` in interface `IArchiveFile`

### getDependId

public String getDependId()

Specified by:
  `getDependId` in interface `IArchiveFile`

### getSystemId

public String getSystemId()

Specified by:
  `getSystemId` in interface `IArchiveFile`

### getName

public String getName()
get the archive name. the archive name is the file name used to create the archive instance.

Specified by:
  `getName` in interface `IArchiveFile`
Returns:
  archive name.

### close

public void close() throws IOException
close the archive. all changed data will be flushed into disk if the file is opened for write. the file will be removed if it is opend as transient. after close, the instance can't be used any more.

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

### flush

public void flush() throws IOException

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

### save

public void save() throws IOException

Specified by:
  `save` in interface `IArchiveFile`
Throws:
  `IOException`

### refresh

public void refresh() throws IOException

Specified by:
  `refresh` in interface `IArchiveFile`
Throws:
  `IOException`

### exists

public boolean exists(String name)

Specified by:
  `exists` in interface `IArchiveFile`

### getLength

public long getLength()

Specified by:
  `getLength` in interface `IArchiveFile`

### openEntry

public ArchiveEntry openEntry(String name) throws IOException

Specified by:
  `openEntry` in interface `IArchiveFile`
Throws:
  `IOException`

### listEntries

public List<String> listEntries(String namePattern)

Specified by:
  `listEntries` in interface `IArchiveFile`

### createEntry

public ArchiveEntry createEntry(String name) throws IOException

Specified by:
  `createEntry` in interface `IArchiveFile`
Throws:
  `IOException`

### removeEntry

public boolean removeEntry(String name) throws IOException

Specified by:
  `removeEntry` in interface `IArchiveFile`
Throws:
  `IOException`

### lockEntry

public Object lockEntry(String name) throws IOException

Specified by:
  `lockEntry` in interface `IArchiveFile`
Throws:
  `IOException`

### unlockEntry

public void unlockEntry(Object locker) throws IOException

Specified by:
  `unlockEntry` in interface `IArchiveFile`
Throws:
  `IOException`

### createBlock

protected Block createBlock() throws IOException

Throws:
  `IOException`

### unloadBlock

protected void unloadBlock(Block block) throws IOException

Throws:
  `IOException`