jcontrol.storage
Class FlashStream

java.lang.Object
  extended byjcontrol.storage.FlashStream
All Implemented Interfaces:
jcontrol.io.BasicInputStream, jcontrol.io.BasicOutputStream

public class FlashStream
extends java.lang.Object
implements jcontrol.io.BasicInputStream, jcontrol.io.BasicOutputStream

This class FlashStream represents a memory cached data stream for reading and writing continuous data to the flash memory.

If the flash memory is full or some other error occurs, an IOException is thrown.

Author:
Wolfgang Klingauf
See Also:
Flash, FlashTlv
Available on JControl Devices:
lib

Field Summary
protected  byte[] cache
          sector cache for faster reads
protected  byte m_bank
          currently used flash bank (always starts at bank 0)
protected  int m_pos
          position in current sector (for the stream)
protected  int m_sector
          current sector
protected  int sectorcount
          flash sectorsize and -count
protected  int sectorsize
          flash sectorsize and -count
 
Constructor Summary
FlashStream()
          Create a new flash stream.
 
Method Summary
 void clearCache()
          Frees the flash memory.
 void close()
           
 int getSectorsize()
          Returns the sectorsize.
 char read()
          Read a single character from the flash stream.
 int read(byte[] buffer, int startindex, int length)
          Read data from the flash stream.
 int write(byte[] buffer, int startindex, int length)
          Write data to the flash stream.
 void write(char data)
          Write a single character to the flash stream.
 
Methods inherited from class java.lang.Object
clone, equals, notifyAll, wait
 

Field Detail

cache

protected byte[] cache
sector cache for faster reads


m_bank

protected byte m_bank
currently used flash bank (always starts at bank 0)


m_pos

protected int m_pos
position in current sector (for the stream)


m_sector

protected int m_sector
current sector


sectorcount

protected int sectorcount
flash sectorsize and -count


sectorsize

protected int sectorsize
flash sectorsize and -count

Constructor Detail

FlashStream

public FlashStream()
            throws java.io.IOException
Create a new flash stream.

Throws:
java.io.IOException
Method Detail

clearCache

public void clearCache()
Frees the flash memory.


close

public void close()
Specified by:
close in interface jcontrol.io.BasicInputStream
See Also:
BasicOutputStream.close()

getSectorsize

public int getSectorsize()
Returns the sectorsize.

Returns:
int

read

public char read()
          throws java.io.IOException
Read a single character from the flash stream.

Specified by:
read in interface jcontrol.io.BasicInputStream
Throws:
java.io.IOException
See Also:
BasicInputStream.read()

read

public int read(byte[] buffer,
                int startindex,
                int length)
         throws java.io.IOException
Read data from the flash stream.

Specified by:
read in interface jcontrol.io.BasicInputStream
Throws:
java.io.IOException
See Also:
BasicInputStream.read(byte[], int, int)

write

public int write(byte[] buffer,
                 int startindex,
                 int length)
          throws java.io.IOException

Write data to the flash stream.

Specified by:
write in interface jcontrol.io.BasicOutputStream
Throws:
java.io.IOException
See Also:
BasicOutputStream.write(byte[], int, int)

write

public void write(char data)
           throws java.io.IOException

Write a single character to the flash stream.

Specified by:
write in interface jcontrol.io.BasicOutputStream
Throws:
java.io.IOException
See Also:
BasicOutputStream.write(char)