1 /*******************************************************************************
2 * Copyright (c) 2010 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.databoard.accessor.file;
16 import org.simantics.databoard.accessor.Accessor;
17 import org.simantics.databoard.accessor.CloseableAccessor;
18 import org.simantics.databoard.accessor.binary.BinaryObject;
19 import org.simantics.databoard.accessor.error.AccessorException;
20 import org.simantics.databoard.binding.Binding;
23 * File accessor is an interface for data that is located in a file in byte format.
24 * There are two ways of writing to the files.
25 * A) Using the writing methods of Accessor+subtypes, eg. setValue, putValue, ...
26 * They guarantee the value is flushed to the file upon return
27 * B) Using the write methods of FileAccessor+subtypes, eg. setValueNoflush, putValueNoflush ...
28 * They do not guarantee flush upon return. Explicit flush() call is required.
29 * The value resides in memory cache and are available for reading event before flushing.
31 * see FileAccessorExample
32 * @see BinaryObject File/Memory Byte[] implementation
33 * @see FileArrayAccessor
34 * @see FileBooleanAccessor
35 * @see FileByteAccessor
36 * @see FileDoubleAccessor
37 * @see FileFloatAccessor
38 * @see FileIntegerAccessor
39 * @see FileLongAccessor
40 * @see FileMapAccessor
41 * @see FileOptionalAccessor
42 * @see FileRecordAccessor
43 * @see FileStringAccessor
44 * @see FileUnionAccessor
45 * @see FileVariantAccessor
46 * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
48 public interface FileAccessor extends Accessor, CloseableAccessor {
58 * Close the file. It is allowed to call this method more than once.
60 * @throws AccessorException
62 void close() throws AccessorException;
65 * Flush the internal write buffer to the disc. This is needed if
66 * setXXNoFlush() methods are used.
69 * Note, all the write methods of {@link Accessor} and its sub-interfaces
70 * guarantee Durability. They flush the value immediately and do not require
71 * separate {@link #flush()}.
73 * @throws AccessorException
75 void flush() throws AccessorException;
78 * Reset internal buffer. If there unwritten changes, they are flushed.
80 * @throws AccessorException
82 void reset() throws AccessorException;
85 * Write a value to the file without flushing the writebuffer yet.
86 * The write doesn't become durable until the value is flushed
87 * with {@link #flush()}.
91 * @throws AccessorException
93 void setValueNoflush(Binding binding, Object newValue) throws AccessorException;