org.eclipse.mofscript.runtime
Class BlockOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.eclipse.mofscript.runtime.BlockOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class BlockOutputStream
extends java.io.OutputStream

Class to handle files and containing blocks

Author:
jol, gko

Nested Class Summary
 class BlockOutputStream.FileBlock
           
 class BlockOutputStream.ProtectedFileBlock
           
 class BlockOutputStream.UnprotectedFileBlock
           
 
Field Summary
(package private)  int _endLine
           
(package private)  BlockOutputStream.FileBlock _existingFile
           
(package private)  BlockOutputStream.FileBlock _fileBlock
           
(package private)  java.lang.String _fileUri
           
(package private)  int _startLine
           
(package private)  int _unprotectedIdCounter
           
(package private)  boolean appendMode
           
 
Constructor Summary
BlockOutputStream(java.lang.String fileUri)
           
BlockOutputStream(java.lang.String fileUri, boolean append)
           
 
Method Summary
protected  void append()
          Appends _fileBlock to the end of _existingFile Then sets the _fileBlock to reference the beginning of _existingFile
 BlockOutputStream.FileBlock get_fileBlock()
           
 java.lang.String get_fileUri()
           
 BlockOutputStream.FileBlock getBlockWithId(java.lang.String id)
           
 int getIdBlockCounter(java.lang.String objectId)
           
 int getLineDifference(java.lang.String blockId)
          Gets the difference in lines between a new block an an existing (pre-read) block
 void increaseIdCounter(java.lang.String objectId)
           
protected  void merge()
           
 void newBlock(boolean isProtected, java.lang.String id)
           
 int position()
           
protected  void preReadFile()
           
 void write(int b)
           
 void writeToFile()
           
 
Methods inherited from class java.io.OutputStream
close, flush, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_fileBlock

BlockOutputStream.FileBlock _fileBlock

_existingFile

BlockOutputStream.FileBlock _existingFile

_fileUri

java.lang.String _fileUri

_unprotectedIdCounter

int _unprotectedIdCounter

_startLine

int _startLine

_endLine

int _endLine

appendMode

boolean appendMode
Constructor Detail

BlockOutputStream

public BlockOutputStream(java.lang.String fileUri)
Parameters:
fileUri -

BlockOutputStream

public BlockOutputStream(java.lang.String fileUri,
                         boolean append)
Method Detail

getIdBlockCounter

public int getIdBlockCounter(java.lang.String objectId)
Parameters:
objectId -
Returns:

increaseIdCounter

public void increaseIdCounter(java.lang.String objectId)
Parameters:
objectId -

getBlockWithId

public BlockOutputStream.FileBlock getBlockWithId(java.lang.String id)
Parameters:
id -
Returns:

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

newBlock

public void newBlock(boolean isProtected,
                     java.lang.String id)
Parameters:
isProtected -
id -

getLineDifference

public int getLineDifference(java.lang.String blockId)
Gets the difference in lines between a new block an an existing (pre-read) block


writeToFile

public void writeToFile()

merge

protected void merge()

append

protected void append()
Appends _fileBlock to the end of _existingFile Then sets the _fileBlock to reference the beginning of _existingFile


position

public int position()

preReadFile

protected void preReadFile()

get_fileUri

public java.lang.String get_fileUri()
Returns:

get_fileBlock

public BlockOutputStream.FileBlock get_fileBlock()
Returns: