]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/file/FileAccessor.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / accessor / file / FileAccessor.java
diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/file/FileAccessor.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/accessor/file/FileAccessor.java
new file mode 100644 (file)
index 0000000..7a90e09
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************\r
+ *  Copyright (c) 2010 Association for Decentralized Information Management in\r
+ *  Industry THTH ry.\r
+ *  All rights reserved. This program and the accompanying materials\r
+ *  are made available under the terms of the Eclipse Public License v1.0\r
+ *  which accompanies this distribution, and is available at\r
+ *  http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ *  Contributors:\r
+ *      VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.databoard.accessor.file;
+
+import java.io.File;\r
+\r
+import org.simantics.databoard.accessor.Accessor;\r
+import org.simantics.databoard.accessor.CloseableAccessor;\r
+import org.simantics.databoard.accessor.binary.BinaryObject;\r
+import org.simantics.databoard.accessor.error.AccessorException;\r
+import org.simantics.databoard.binding.Binding;\r
+\r
+/**\r
+ * File accessor is an interface for data that is located in a file in byte format.\r
+ * There are two ways of writing to the files. \r
+ *   A) Using the writing methods of Accessor+subtypes, eg. setValue, putValue, ...\r
+ *      They guarantee the value is flushed to the file upon return\r
+ *   B) Using the write methods of FileAccessor+subtypes, eg. setValueNoflush, putValueNoflush ...\r
+ *      They do not guarantee flush upon return. Explicit flush() call is required.\r
+ *      The value resides in memory cache and are available for reading event before flushing.\r
+ *\r
+ * see FileAccessorExample\r
+ * @see BinaryObject File/Memory Byte[] implementation\r
+ * @see FileArrayAccessor\r
+ * @see FileBooleanAccessor\r
+ * @see FileByteAccessor\r
+ * @see FileDoubleAccessor\r
+ * @see FileFloatAccessor\r
+ * @see FileIntegerAccessor\r
+ * @see FileLongAccessor\r
+ * @see FileMapAccessor\r
+ * @see FileOptionalAccessor\r
+ * @see FileRecordAccessor\r
+ * @see FileStringAccessor\r
+ * @see FileUnionAccessor\r
+ * @see FileVariantAccessor\r
+ * @author Toni Kalajainen <toni.kalajainen@vtt.fi>\r
+ */
+public interface FileAccessor extends Accessor, CloseableAccessor {
+
+       /**
+        * Get the file
+        * 
+        * @return file
+        */
+       File file();
+       
+       /**
+        * Close the file. It is allowed to call this method more than once.
+        * 
+        * @throws AccessorException
+        */
+       void close() throws AccessorException;
+       
+       /**
+        * Flush the internal write buffer to the disc. This is needed if 
+        * setXXNoFlush() methods are used.
+        * <p>
+        * 
+        * Note, all the write methods of {@link Accessor} and its sub-interfaces 
+        * guarantee Durability. They flush the value immediately and do not require
+        * separate {@link #flush()}.
+        * 
+        * @throws AccessorException
+        */
+       void flush() throws AccessorException;
+       \r
+       /**\r
+        * Reset internal buffer. If there unwritten changes, they are flushed.\r
+        * \r
+        * @throws AccessorException\r
+        */\r
+       void reset() throws AccessorException;\r
+       
+       /**
+        * Write a value to the file without flushing the writebuffer yet.
+        * The write doesn't become durable until the value is flushed 
+        * with {@link #flush()}.
+        * 
+        * @param binding
+        * @param newValue
+        * @throws AccessorException
+        */
+       void setValueNoflush(Binding binding, Object newValue) throws AccessorException;\r
+       \r
+       
+       
+}
+