|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.at4j.comp.bzip2.BZip2WritableFile
public class BZip2WritableFile
This is a WritableFile
that transparently compresses the data written
to a file using bzip2 compression.
The bzip2 output stream is opened on a buffered output stream on the backing file. The size of that buffer can be configured.
This file cannot be appended to. The openForAppend
methods throw an
UnsupportedOperationException
.
BZip2ReadableFile
,
GZipWritableFile
,
LzmaWritableFile
,
BZip2OutputStream
Constructor Summary | |
---|---|
BZip2WritableFile(WritableFile adapted)
Create a new adapter using the default bzip2 block size (900kb). |
|
BZip2WritableFile(WritableFile adapted,
BZip2WritableFileSettings settings)
Create a new adapter using the supplied bzip2 buffer size. |
|
BZip2WritableFile(WritableFile adapted,
CompressionLevel level)
Create a new adapter using the supplied compression level. |
|
BZip2WritableFile(WritableFile adapted,
CompressionLevel level,
boolean writeMagicBytes)
Deprecated. The magic bytes are always written starting from At4J 1.1. |
|
BZip2WritableFile(WritableFile adapted,
int blockSize,
boolean writeMagicBytes,
int bufferSize)
Deprecated. The magic bytes are always written starting from At4J 1.1. |
Method Summary | |
---|---|
EntityLock |
getWriteLock()
Get the write lock without locking it. |
boolean |
isWriteLockedByCurrentThread()
Does the calling thread hold a write lock for the lockable object (this)? |
EntityLock |
lockForWriting()
Lock the object for writing and return the lock. |
WritableByteChannel |
openChannelForAppend()
This method always throws an UnsupportedOperationException . |
WritableByteChannel |
openChannelForWrite()
Open a WritableByteChannel for writing on the file. |
OutputStream |
openForAppend()
This method always throws an UnsupportedOperationException . |
OutputStream |
openForWrite()
Opens the file for writing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BZip2WritableFile(WritableFile adapted)
Note: Starting with At4J 1.1, the written bzip2 data will be prefixed with the bzip2 stream header "BZ".
adapted
- The writable file to adapt.public BZip2WritableFile(WritableFile adapted, CompressionLevel level)
Note: Starting with At4J 1.1, the written bzip2 data will be prefixed with the bzip2 stream header "BZ".
adapted
- The writable file to adapt.level
- The compression level.@Deprecated public BZip2WritableFile(WritableFile adapted, CompressionLevel level, boolean writeMagicBytes)
adapted
- The writable file to adapt.level
- The compression level.writeMagicBytes
- Should the written data be prefixed by the two
magic bytes, "BZ"? Starting with At4J 1.1, this property must be
true
.@Deprecated public BZip2WritableFile(WritableFile adapted, int blockSize, boolean writeMagicBytes, int bufferSize) throws IllegalArgumentException
adapted
- The writable file to adapt.blockSize
- The size of bzip2 dictionary in 100k units. This must be
a value between 1
and 9
(inclusive). A higher value gives
a higher compression, but it will also make the compression and future
decompressions use more memory.writeMagicBytes
- Should the written data be prefixed by the two
magic bytes, "BZ"? Starting with At4J 1.1, this property must be
true
.bufferSize
- The size of the memory buffer used for buffering the
written output before it is compressed.
IllegalArgumentException
- If the block size is less than 1
or greater than 10
, or if the buffer size is less than 1
.public BZip2WritableFile(WritableFile adapted, BZip2WritableFileSettings settings) throws IllegalArgumentException
adapted
- The writable file to adapt.settings
- Settings. A clone of the settings object is stored in the
created object.
IllegalArgumentException
- If the block size is less than 1
or greater than 10
, or if the buffer size is less than 1
.Method Detail |
---|
public WritableByteChannel openChannelForAppend() throws UnsupportedOperationException
UnsupportedOperationException
.
openChannelForAppend
in interface WritableFile
WritableByteChannel
. The channel must be closed
by the caller. The returned channel may be a
GatheringByteChannel
, but that is not required.
UnsupportedOperationException
- Always.public WritableByteChannel openChannelForWrite() throws WriteLockRequiredException, AccessDeniedException, ReadOnlyException
WritableFile
WritableByteChannel
for writing on the file. The semantics
of this method is the same as for WritableFile.openForWrite()
.
openChannelForWrite
in interface WritableFile
WritableByteChannel
. The channel must be closed
by the caller. The returned channel may be a
GatheringByteChannel
, but that is not required.
WriteLockRequiredException
- If the client does not have a write
lock for the file.
AccessDeniedException
- If the client does not have write access to
the file.
ReadOnlyException
- If the file system is read-only.WritableFile.openForWrite()
,
WritableFile.openChannelForAppend()
public OutputStream openForAppend() throws UnsupportedOperationException
UnsupportedOperationException
.
openForAppend
in interface WritableFile
OutputStream
to write to. The stream must be closed by
the caller.
UnsupportedOperationException
- Always.WritableFile.openForWrite()
,
WritableFile.openChannelForAppend()
public OutputStream openForWrite() throws WriteLockRequiredException, AccessDeniedException, ReadOnlyException
WritableFile
WritableFile.openForAppend()
to append to the file.
The caller is responsible for closing the stream.
When two output streams, one writing and one appending are open on the same file, the stream opened for write will ignore the contents written by the other stream and the content written by the other stream will be overwritten. When two or more appending streams are opened on a file, a stream will not overwrite the content written by the other streams.
Although a write lock on the file is required for the execution thread
opening the stream, the stream itself is not protected from access by
other threads. It can be protected by wrapping it in a
LockAwareOutputStream
.
openForWrite
in interface WritableFile
OutputStream
to write to. The stream must be closed by
the caller.
WriteLockRequiredException
- If the client does not have a write
lock for the file.
AccessDeniedException
- If the client does not have write access to
the file.
ReadOnlyException
- If the file system is read-only.WritableFile.openForAppend()
,
WritableFile.openChannelForWrite()
public EntityLock getWriteLock()
WriteLockable
This method always returns a lock, even if the object's file system is not locking or if the object is read only.
getWriteLock
in interface WriteLockable
public boolean isWriteLockedByCurrentThread()
WriteLockable
isWriteLockedByCurrentThread
in interface WriteLockable
true
if the lockable object is write locked by the
current thread.public EntityLock lockForWriting() throws LockTimeoutException
WriteLockable
EntityLockAdapterFactory
and
LockAcquiringStrategy
used. If this is called on an object that
is somehow connected to an Entity
object, that entity's file
systems' lock adapter factory and lock acquiring strategy is used. A
write lock can be downgraded to a read lock (by calling
ReadLockable.lockForReading()
and then releasing the write lock).
An entity in a locking read only file system may still be locked for writing.
For more discussions on locks and locking, see Entity
and
FileSystem
.
This method always returns a lock, even if the file system is not locking.
lockForWriting
in interface WriteLockable
LockTimeoutException
- If the lock acquiring timed out. (It is up
to the LockAcquiringStrategy
to decide if lock acquiring can time
out.)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |