org.eclipse.birt.core.archive.compound
Class ArchiveEntry

java.lang.Object
  extended by org.eclipse.birt.core.archive.compound.ArchiveEntry
Direct Known Subclasses:
ArchiveEntryAdapter

public abstract class ArchiveEntry
extends java.lang.Object

the user must close the archive


Field Summary
protected  byte[] buffer
          the read writer buffer
protected  boolean buffer_dirty
          if the buffer is write buffer
protected  int buffer_offset
          the current point in the buffer
protected  int buffer_size
          the data size in the buffer
protected  long offset
          the offset of the first byte of buffer in the file
 
Constructor Summary
ArchiveEntry()
           
 
Method Summary
protected abstract  void _flush()
           
protected abstract  long _getLength()
           
protected abstract  void _refresh()
           
protected abstract  void _setLength(long length)
           
abstract  void close()
           
protected  void discardBuffer()
          ignore the buffer by reset the buffer offset and buffer size
 void flush()
          flush the data into the disk
protected  void flushBuffer()
          flush the data into the buffer and move the buffer to next position.
 long getLength()
          get the length of the entry.
abstract  java.lang.String getName()
           
 long getPosition()
          return the file position.
 int read()
           
 int read(byte[] b, int off, int len)
           
abstract  int read(long offset, byte[] b, int off, int size)
           
 int readInt()
           
 long readLong()
           
 void refresh()
          reload the data from the disk.
protected  void refreshBuffer(int minSize)
           
protected  void saveBuffer()
          save the changed buffer into disk
 void seek(long off)
          set the file position to offset if the file position exceed the file length, the EOF exception is throw out in next read.
 void setLength(long length)
          set the length to the entry
 void write(byte[] b, int off, int len)
          write byte[] at the current position.
 void write(int b)
          write the data at the current position.
abstract  void write(long offset, byte[] b, int off, int size)
           
 void writeInt(int v)
          write a integer at the current position.
 void writeLong(long v)
          write a long at the current position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offset

protected long offset
the offset of the first byte of buffer in the file


buffer

protected byte[] buffer
the read writer buffer


buffer_dirty

protected boolean buffer_dirty
if the buffer is write buffer


buffer_offset

protected int buffer_offset
the current point in the buffer


buffer_size

protected int buffer_size
the data size in the buffer

Constructor Detail

ArchiveEntry

public ArchiveEntry()
Method Detail

getName

public abstract java.lang.String getName()
                                  throws java.io.IOException
Throws:
java.io.IOException

_getLength

protected abstract long _getLength()
                            throws java.io.IOException
Throws:
java.io.IOException

_setLength

protected abstract void _setLength(long length)
                            throws java.io.IOException
Throws:
java.io.IOException

_flush

protected abstract void _flush()
                        throws java.io.IOException
Throws:
java.io.IOException

_refresh

protected abstract void _refresh()
                          throws java.io.IOException
Throws:
java.io.IOException

read

public abstract int read(long offset,
                         byte[] b,
                         int off,
                         int size)
                  throws java.io.IOException
Throws:
java.io.IOException

write

public abstract void write(long offset,
                           byte[] b,
                           int off,
                           int size)
                    throws java.io.IOException
Throws:
java.io.IOException

close

public abstract void close()
                    throws java.io.IOException
Throws:
java.io.IOException

getLength

public final long getLength()
                     throws java.io.IOException
get the length of the entry.

Returns:
Throws:
java.io.IOException

setLength

public final void setLength(long length)
                     throws java.io.IOException
set the length to the entry

Parameters:
length -
Throws:
java.io.IOException

flush

public final void flush()
                 throws java.io.IOException
flush the data into the disk

Throws:
java.io.IOException

refresh

public final void refresh()
                   throws java.io.IOException
reload the data from the disk. It fails if there are any dirty data. Otherwise, it simply ignore the buffer

Throws:
java.io.IOException

seek

public final void seek(long off)
                throws java.io.IOException
set the file position to offset if the file position exceed the file length, the EOF exception is throw out in next read. It is OK for write.

Parameters:
off - the file position
Throws:
java.io.IOException

getPosition

public final long getPosition()
                       throws java.io.IOException
return the file position. as describe in the seek, the file position may be larger than the file length

Returns:
file position
Throws:
java.io.IOException

write

public final void write(int b)
                 throws java.io.IOException
write the data at the current position. the current position is move to next. If the file is opened in read only mode, the exception is throw out in next flush()

Parameters:
b -
Throws:
java.io.IOException

writeInt

public final void writeInt(int v)
                    throws java.io.IOException
write a integer at the current position. the current position is move by 4 bytes. The IO exception is throw out for next flush() if it is read only.

Parameters:
v -
Throws:
java.io.IOException

writeLong

public final void writeLong(long v)
                     throws java.io.IOException
write a long at the current position. the current position is move by 8 bytes. The IO exception is thrown out in next flush() for read only file

Parameters:
v -
Throws:
java.io.IOException

write

public final void write(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
write byte[] at the current position. the position is moved by len.

Parameters:
b -
off -
len -
Throws:
java.io.IOException

read

public final int read()
               throws java.io.IOException
Throws:
java.io.IOException

readInt

public final int readInt()
                  throws java.io.IOException
Throws:
java.io.IOException

readLong

public final long readLong()
                    throws java.io.IOException
Throws:
java.io.IOException

read

public final int read(byte[] b,
                      int off,
                      int len)
               throws java.io.IOException
Throws:
java.io.IOException

discardBuffer

protected void discardBuffer()
                      throws java.io.IOException
ignore the buffer by reset the buffer offset and buffer size

Throws:
java.io.IOException

saveBuffer

protected void saveBuffer()
                   throws java.io.IOException
save the changed buffer into disk

Throws:
java.io.IOException

flushBuffer

protected void flushBuffer()
                    throws java.io.IOException
flush the data into the buffer and move the buffer to next position.

Throws:
java.io.IOException

refreshBuffer

protected void refreshBuffer(int minSize)
                      throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2008 Actuate Corp. All rights reserved.