Class ArchiveFileV2
- java.lang.Object
-
- org.eclipse.birt.core.archive.compound.ArchiveFileV2
-
- All Implemented Interfaces:
IArchiveFile
public class ArchiveFileV2 extends java.lang.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 intALLOC_TABLE_BLOCKthe first block of allocation tableprotected org.eclipse.birt.core.archive.compound.AllocTableallocTblallocation table of the archive fileprotected java.lang.StringarchiveNamethe archive file name.protected intBLOCK_SIZEprotected org.eclipse.birt.core.archive.cache.FileCacheManagercachescache manager of the archive file.static intDEFAULT_BLOCK_SIZESize of a physical block, counted in bytes.static intDEFAULT_BUFFER_POOL_SIZEdefault size of buffer pool - number of buffer blocks in buffer poolprotected java.lang.StringdependIdstatic longDOCUMENT_TAGThe magic tag of the archive file: "RPTDOC"static longDOCUMENT_VERSION_0After support system id in archive file, DOCUMENT_VERSION_1 is writen into header.static longDOCUMENT_VERSION_1protected java.util.HashMap<java.lang.String,org.eclipse.birt.core.archive.compound.NameEntry>entriesarchive entries in the tablestatic intENTRY_ITEM_SIZEthe size of a entry in the entry table, counted in bytesstatic intENTRY_TABLE_BLOCKthe first block of entry tableprotected org.eclipse.birt.core.archive.compound.NameTableentryTblentry table of the archive filestatic intFILE_STATUS_FINISHEDFile status value: finishedprotected org.eclipse.birt.core.archive.compound.ArchiveHeaderheadheader statusstatic intHEADER_BLOCKthe block of archive headerprotected booleanisAppendthe archive file is appended.protected booleanisClosedif the file is closed.protected booleanisTransientthe archive file is transient.protected booleanisWritablethe archive file is writable.static intMIN_BUFFER_POOL_SIZEMin size of buffer pool - number of buffer blocks in buffer poolstatic java.lang.StringPROPERTY_DEFAULT_BLOCK_SIZEthe system property defines the block size, it should be times of 1024.protected java.io.RandomAccessFilerfthe physical file correspond to this compound file systemprotected java.lang.StringsystemIdprotected inttotalBlocksthe total blocks exits in this fileprotected inttotalDiskBlocksthe total blocks exits in the disk
-
Constructor Summary
Constructors Constructor Description ArchiveFileV2(java.lang.String fileName, java.io.RandomAccessFile rf, java.lang.String mode)create the archive file.ArchiveFileV2(java.lang.String fileName, java.lang.String mode)ArchiveFileV2(java.lang.String systemId, java.lang.String fileName, java.lang.String mode)ArchiveFileV2(java.lang.String systemId, java.lang.String dependId, java.lang.String fileName, java.io.RandomAccessFile rf, java.lang.String mode)create the archive file.ArchiveFileV2(java.lang.String systemId, java.lang.String dependId, java.lang.String fileName, java.lang.String mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()close the archive.protected BlockcreateBlock()ArchiveEntrycreateEntry(java.lang.String name)booleanexists(java.lang.String name)voidflush()java.lang.StringgetDependId()longgetLength()java.lang.StringgetName()get the archive name.java.lang.StringgetSystemId()longgetUsedCache()java.util.List<java.lang.String>listEntries(java.lang.String namePattern)java.lang.ObjectlockEntry(java.lang.String name)ArchiveEntryopenEntry(java.lang.String name)voidrefresh()booleanremoveEntry(java.lang.String name)voidsave()voidsetCacheSize(long cacheSize)set up the cache size.protected voidunloadBlock(Block block)voidunlockEntry(java.lang.Object locker)
-
-
-
Field Detail
-
rf
protected java.io.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 java.lang.String archiveName
the archive file name.
-
systemId
protected java.lang.String systemId
-
dependId
protected java.lang.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 java.util.HashMap<java.lang.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
public static final long DOCUMENT_TAG
The magic tag of the archive file: "RPTDOC"- See Also:
- Constant Field Values
-
DOCUMENT_VERSION_0
public 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
public static final long DOCUMENT_VERSION_1
- See Also:
- Constant Field Values
-
PROPERTY_DEFAULT_BLOCK_SIZE
public static final java.lang.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
public static final int DEFAULT_BLOCK_SIZE
Size of a physical block, counted in bytes.- See Also:
- Constant Field Values
-
HEADER_BLOCK
public static final int HEADER_BLOCK
the block of archive header- See Also:
- Constant Field Values
-
ALLOC_TABLE_BLOCK
public static final int ALLOC_TABLE_BLOCK
the first block of allocation table- See Also:
- Constant Field Values
-
ENTRY_TABLE_BLOCK
public static final int ENTRY_TABLE_BLOCK
the first block of entry table- See Also:
- Constant Field Values
-
ENTRY_ITEM_SIZE
public 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
public static final int FILE_STATUS_FINISHED
File status value: finished- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_POOL_SIZE
public 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
public 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 Detail
-
ArchiveFileV2
public ArchiveFileV2(java.lang.String fileName, java.io.RandomAccessFile rf, java.lang.String mode) throws java.io.IOExceptioncreate the archive file.- Parameters:
fileName- file name.rf- the random access filemode- open mode.- Throws:
java.io.IOException
-
ArchiveFileV2
public ArchiveFileV2(java.lang.String fileName, java.lang.String mode) throws java.io.IOException- Throws:
java.io.IOException
-
ArchiveFileV2
public ArchiveFileV2(java.lang.String systemId, java.lang.String fileName, java.lang.String mode) throws java.io.IOException- Throws:
java.io.IOException
-
ArchiveFileV2
public ArchiveFileV2(java.lang.String systemId, java.lang.String dependId, java.lang.String fileName, java.lang.String mode) throws java.io.IOException- Throws:
java.io.IOException
-
ArchiveFileV2
public ArchiveFileV2(java.lang.String systemId, java.lang.String dependId, java.lang.String fileName, java.io.RandomAccessFile rf, java.lang.String mode) throws java.io.IOExceptioncreate the archive file.- Parameters:
fileName- file name.mode- open mode.- Throws:
java.io.IOException
-
-
Method Detail
-
setCacheSize
public void setCacheSize(long cacheSize)
set up the cache size. the actually cache size is round to block size.- Specified by:
setCacheSizein interfaceIArchiveFile- Parameters:
cacheSize- cache size in bytes
-
getUsedCache
public long getUsedCache()
- Specified by:
getUsedCachein interfaceIArchiveFile
-
getDependId
public java.lang.String getDependId()
- Specified by:
getDependIdin interfaceIArchiveFile
-
getSystemId
public java.lang.String getSystemId()
- Specified by:
getSystemIdin interfaceIArchiveFile
-
getName
public java.lang.String getName()
get the archive name. the archive name is the file name used to create the archive instance.- Specified by:
getNamein interfaceIArchiveFile- Returns:
- archive name.
-
close
public void close() throws java.io.IOExceptionclose 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:
closein interfaceIArchiveFile- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfaceIArchiveFile- Throws:
java.io.IOException
-
save
public void save() throws java.io.IOException- Specified by:
savein interfaceIArchiveFile- Throws:
java.io.IOException
-
refresh
public void refresh() throws java.io.IOException- Specified by:
refreshin interfaceIArchiveFile- Throws:
java.io.IOException
-
exists
public boolean exists(java.lang.String name)
- Specified by:
existsin interfaceIArchiveFile
-
getLength
public long getLength()
- Specified by:
getLengthin interfaceIArchiveFile
-
openEntry
public ArchiveEntry openEntry(java.lang.String name) throws java.io.IOException
- Specified by:
openEntryin interfaceIArchiveFile- Throws:
java.io.IOException
-
listEntries
public java.util.List<java.lang.String> listEntries(java.lang.String namePattern)
- Specified by:
listEntriesin interfaceIArchiveFile
-
createEntry
public ArchiveEntry createEntry(java.lang.String name) throws java.io.IOException
- Specified by:
createEntryin interfaceIArchiveFile- Throws:
java.io.IOException
-
removeEntry
public boolean removeEntry(java.lang.String name) throws java.io.IOException- Specified by:
removeEntryin interfaceIArchiveFile- Throws:
java.io.IOException
-
lockEntry
public java.lang.Object lockEntry(java.lang.String name) throws java.io.IOException- Specified by:
lockEntryin interfaceIArchiveFile- Throws:
java.io.IOException
-
unlockEntry
public void unlockEntry(java.lang.Object locker) throws java.io.IOException- Specified by:
unlockEntryin interfaceIArchiveFile- Throws:
java.io.IOException
-
createBlock
protected Block createBlock() throws java.io.IOException
- Throws:
java.io.IOException
-
unloadBlock
protected void unloadBlock(Block block) throws java.io.IOException
- Throws:
java.io.IOException
-
-