org.simantics.databoard.accessor.file
Interface FileAccessor

All Superinterfaces:
Accessor, CloseableAccessor
All Known Subinterfaces:
FileArrayAccessor, FileBooleanAccessor, FileByteAccessor, FileDoubleAccessor, FileFloatAccessor, FileIntegerAccessor, FileLongAccessor, FileMapAccessor, FileOptionalAccessor, FileRecordAccessor, FileStringAccessor, FileUnionAccessor, FileVariantAccessor, StreamAccessor
All Known Implementing Classes:
BinaryArray, BinaryBoolean, BinaryByte, BinaryDouble, BinaryFloat, BinaryInteger, BinaryLong, BinaryMap, BinaryObject, BinaryOptional, BinaryRecord, BinaryStreamArray, BinaryString, BinaryUnion, BinaryVariableWidthStreamArray, BinaryVariant, JavaArray

public interface FileAccessor
extends Accessor, CloseableAccessor

File accessor is an interface for data that is located in a file in byte format. There are two ways of writing to the files. A) Using the writing methods of Accessor+subtypes, eg. setValue, putValue, ... They guarantee the value is flushed to the file upon return B) Using the write methods of FileAccessor+subtypes, eg. setValueNoflush, putValueNoflush ... They do not guarantee flush upon return. Explicit flush() call is required. The value resides in memory cache and are available for reading event before flushing. see FileAccessorExample

Author:
Toni Kalajainen
See Also:
File/Memory Byte[] implementation, FileArrayAccessor, FileBooleanAccessor, FileByteAccessor, FileDoubleAccessor, FileFloatAccessor, FileIntegerAccessor, FileLongAccessor, FileMapAccessor, FileOptionalAccessor, FileRecordAccessor, FileStringAccessor, FileUnionAccessor, FileVariantAccessor

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.simantics.databoard.accessor.Accessor
Accessor.Listener
 
Method Summary
 void close()
          Close the file.
 java.io.File file()
          Get the file
 void flush()
          Flush the internal write buffer to the disc.
 void reset()
          Reset internal buffer.
 void setValueNoflush(Binding binding, java.lang.Object newValue)
          Write a value to the file without flushing the writebuffer yet.
 
Methods inherited from interface org.simantics.databoard.accessor.Accessor
addListener, apply, getComponent, getValue, getValue, removeListener, setValue, type
 

Method Detail

file

java.io.File file()
Get the file

Returns:
file

close

void close()
           throws AccessorException
Close the file. It is allowed to call this method more than once.

Specified by:
close in interface CloseableAccessor
Throws:
AccessorException

flush

void flush()
           throws AccessorException
Flush the internal write buffer to the disc. This is needed if setXXNoFlush() methods are used.

Note, all the write methods of Accessor and its sub-interfaces guarantee Durability. They flush the value immediately and do not require separate flush().

Throws:
AccessorException

reset

void reset()
           throws AccessorException
Reset internal buffer. If there unwritten changes, they are flushed.

Throws:
AccessorException

setValueNoflush

void setValueNoflush(Binding binding,
                     java.lang.Object newValue)
                     throws AccessorException
Write a value to the file without flushing the writebuffer yet. The write doesn't become durable until the value is flushed with flush().

Parameters:
binding -
newValue -
Throws:
AccessorException