]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/Accessors.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / Accessors.java
index 82309bef11a8a4058bbb82a9e15308dc5b2478ff..1ca55812e384c6f1977ca7af533b72a43f8154d5 100644 (file)
@@ -1,49 +1,49 @@
-/*******************************************************************************\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
+/*******************************************************************************
+ *  Copyright (c) 2010 Association for Decentralized Information Management in
+ *  Industry THTH ry.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ *
+ *  Contributors:
+ *      VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
 package org.simantics.databoard;
 
-import java.io.File;\r
-import java.io.IOException;\r
-import java.nio.ByteBuffer;\r
-import java.util.concurrent.Executor;\r
-\r
-import org.simantics.databoard.accessor.Accessor;\r
-import org.simantics.databoard.accessor.ArrayAccessor;\r
-import org.simantics.databoard.accessor.binary.BinaryArray;\r
-import org.simantics.databoard.accessor.binary.BinaryObject;\r
-import org.simantics.databoard.accessor.binary.BinaryStreamArray;\r
-import org.simantics.databoard.accessor.binary.BinaryVariableWidthStreamArray;\r
-import org.simantics.databoard.accessor.error.AccessorConstructionException;\r
-import org.simantics.databoard.accessor.error.AccessorException;\r
-import org.simantics.databoard.accessor.file.FileAccessor;\r
-import org.simantics.databoard.accessor.file.FileArrayAccessor;\r
-import org.simantics.databoard.accessor.file.FileLibrary;\r
-import org.simantics.databoard.accessor.file.FileVariantAccessor;\r
-import org.simantics.databoard.accessor.impl.AccessorParams;\r
-import org.simantics.databoard.accessor.impl.DirectoryMap;\r
-import org.simantics.databoard.accessor.java.JavaObject;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.error.BindingConstructionException;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.binding.mutable.Variant;\r
-import org.simantics.databoard.serialization.Serializer;\r
-import org.simantics.databoard.serialization.SerializerConstructionException;\r
-import org.simantics.databoard.type.ArrayType;\r
-import org.simantics.databoard.type.Datatype;\r
-import org.simantics.databoard.util.binary.BinaryFile;\r
-import org.simantics.databoard.util.binary.BinaryMemory;\r
-import org.simantics.databoard.util.binary.Blob;\r
-import org.simantics.databoard.util.binary.RandomAccessBinary;\r
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.Executor;
+
+import org.simantics.databoard.accessor.Accessor;
+import org.simantics.databoard.accessor.ArrayAccessor;
+import org.simantics.databoard.accessor.binary.BinaryArray;
+import org.simantics.databoard.accessor.binary.BinaryObject;
+import org.simantics.databoard.accessor.binary.BinaryStreamArray;
+import org.simantics.databoard.accessor.binary.BinaryVariableWidthStreamArray;
+import org.simantics.databoard.accessor.error.AccessorConstructionException;
+import org.simantics.databoard.accessor.error.AccessorException;
+import org.simantics.databoard.accessor.file.FileAccessor;
+import org.simantics.databoard.accessor.file.FileArrayAccessor;
+import org.simantics.databoard.accessor.file.FileLibrary;
+import org.simantics.databoard.accessor.file.FileVariantAccessor;
+import org.simantics.databoard.accessor.impl.AccessorParams;
+import org.simantics.databoard.accessor.impl.DirectoryMap;
+import org.simantics.databoard.accessor.java.JavaObject;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.error.BindingConstructionException;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.binding.mutable.Variant;
+import org.simantics.databoard.serialization.Serializer;
+import org.simantics.databoard.serialization.SerializerConstructionException;
+import org.simantics.databoard.type.ArrayType;
+import org.simantics.databoard.type.Datatype;
+import org.simantics.databoard.util.binary.BinaryFile;
+import org.simantics.databoard.util.binary.BinaryMemory;
+import org.simantics.databoard.util.binary.Blob;
+import org.simantics.databoard.util.binary.RandomAccessBinary;
 
 /**
  * This is a facade class for accessor services.
@@ -51,75 +51,75 @@ import org.simantics.databoard.util.binary.RandomAccessBinary;
  * @author Toni Kalajainen <toni.kalajainen@vtt.fi>
  */
 public class Accessors {
-\r
-       /**\r
-        * Open an accessor to byte data.\r
-        * \r
-        * @param binary\r
-        * @param type\r
-        * @param params\r
-        * @return an accessor\r
-        * @throws AccessorConstructionException \r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public static <T extends Accessor> T getAccessor(RandomAccessBinary binary, Datatype type, AccessorParams params) throws AccessorConstructionException {                \r
-               return (T) BinaryObject.createAccessor(binary, type, params);\r
-       }\r
-       \r
-       /**\r
-        * Open an accessor to byte data.\r
-        * \r
-        * @param binary\r
-        * @param type\r
-        * @return an accessor\r
-        * @throws AccessorConstructionException \r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public static <T extends Accessor> T getAccessor(RandomAccessBinary binary, Datatype type) throws AccessorConstructionException {               \r
-               return (T) BinaryObject.createAccessor(binary, type, AccessorParams.DEFAULT);\r
-       }       \r
-       \r
-       /**\r
-        * Open an accessor to byte data.\r
-        * \r
-        * @param binary\r
-        * @param type\r
-        * @return an accessor\r
-        * @throws AccessorConstructionException \r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public static <T extends Accessor> T getAccessor(byte[] binary, Datatype type) throws AccessorConstructionException {\r
-               RandomAccessBinary rab = new BinaryMemory( ByteBuffer.wrap(binary) );\r
-               return (T) BinaryObject.createAccessor(rab, type, AccessorParams.DEFAULT);\r
-       }\r
-\r
-       /**\r
-        * Open an accessor to a Java Object.\r
-        * <p>\r
-        * Accessor is disposed by leaving it to garbage collector.\r
-        * <p>\r
-        * Do not modify the object outside the accessor as long as you use the accessor.\r
-        * Exterioir modifications will mix up listening the mechanism.\r
-        * Also, do not create more than one accessor to one Object. \r
-        * <p>\r
-        * You must provide mutual exclusion locking mechanism to the whole Object Model\r
-        * in AccessorParams, if you intend to use the accessors in multi-thread environment. \r
-        * \r
-        * @since 0.5\r
-        * @param binding\r
-        * @param value\r
-        * @return accessor\r
-        * @throws AccessorConstructionException\r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public static <T extends Accessor> T getAccessor(Binding binding, Object value, AccessorParams params) \r
-       throws AccessorConstructionException {\r
-               return (T) JavaObject.createAccessor(null, binding, value, params);\r
-       }\r
+
+       /**
+        * Open an accessor to byte data.
+        * 
+        * @param binary
+        * @param type
+        * @param params
+        * @return an accessor
+        * @throws AccessorConstructionException 
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends Accessor> T getAccessor(RandomAccessBinary binary, Datatype type, AccessorParams params) throws AccessorConstructionException {                
+               return (T) BinaryObject.createAccessor(binary, type, params);
+       }
        
        /**
-        * Open an accessor to a Java Object.\r
-        * <p>\r
+        * Open an accessor to byte data.
+        * 
+        * @param binary
+        * @param type
+        * @return an accessor
+        * @throws AccessorConstructionException 
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends Accessor> T getAccessor(RandomAccessBinary binary, Datatype type) throws AccessorConstructionException {               
+               return (T) BinaryObject.createAccessor(binary, type, AccessorParams.DEFAULT);
+       }       
+       
+       /**
+        * Open an accessor to byte data.
+        * 
+        * @param binary
+        * @param type
+        * @return an accessor
+        * @throws AccessorConstructionException 
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends Accessor> T getAccessor(byte[] binary, Datatype type) throws AccessorConstructionException {
+               RandomAccessBinary rab = new BinaryMemory( ByteBuffer.wrap(binary) );
+               return (T) BinaryObject.createAccessor(rab, type, AccessorParams.DEFAULT);
+       }
+
+       /**
+        * Open an accessor to a Java Object.
+        * <p>
+        * Accessor is disposed by leaving it to garbage collector.
+        * <p>
+        * Do not modify the object outside the accessor as long as you use the accessor.
+        * Exterioir modifications will mix up listening the mechanism.
+        * Also, do not create more than one accessor to one Object. 
+        * <p>
+        * You must provide mutual exclusion locking mechanism to the whole Object Model
+        * in AccessorParams, if you intend to use the accessors in multi-thread environment. 
+        * 
+        * @since 0.5
+        * @param binding
+        * @param value
+        * @return accessor
+        * @throws AccessorConstructionException
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends Accessor> T getAccessor(Binding binding, Object value, AccessorParams params) 
+       throws AccessorConstructionException {
+               return (T) JavaObject.createAccessor(null, binding, value, params);
+       }
+       
+       /**
+        * Open an accessor to a Java Object.
+        * <p>
         * Accessor is disposed by leaving it to garbage collector.
         * <p>
         * Do not modify the object outside the accessor as long as you use the accessor.
@@ -127,7 +127,7 @@ public class Accessors {
         * Also, do not create more than one accessor to one Object. 
         * <p>
         * The accessor is not multi-thread accessible. If you intend to use it in 
-        * concurrent multi-thread environment, use the other method where you can \r
+        * concurrent multi-thread environment, use the other method where you can 
         * pass lock objects in AccessorParams. 
         * 
         * @since 0.5
@@ -140,70 +140,70 @@ public class Accessors {
        public static <T extends Accessor> T getAccessor(Binding binding, Object value) 
        throws AccessorConstructionException {
                return (T) JavaObject.createAccessor(null, binding, value, AccessorParams.DEFAULT);
-       }\r
-       \r
-       /**\r
-        * Open an accessor to a Varint Object.\r
-        * <p>\r
-        * Accessor is disposed by leaving it to garbage collector.\r
-        * <p>\r
-        * Do not modify the object outside the accessor as long as you use the accessor.\r
-        * Exterioir modifications will mix up listening the mechanism.\r
-        * Also, do not create more than one accessor to one Object. \r
-        * <p>\r
-        * The accessor is not multi-thread accessible. If you intend to use it in \r
-        * concurrent multi-thread environment, use the other method where you can \r
-        * pass lock objects in AccessorParams. \r
-        * \r
-        * @since 0.5\r
-        * @param variant\r
-        * @return accessor\r
-        * @throws AccessorConstructionException\r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public static <T extends Accessor> T getAccessor(Variant variant) \r
-       throws AccessorConstructionException {\r
-               return (T) JavaObject.createAccessor(null, variant.getBinding(), variant.getValue(), AccessorParams.DEFAULT);\r
+       }
+       
+       /**
+        * Open an accessor to a Varint Object.
+        * <p>
+        * Accessor is disposed by leaving it to garbage collector.
+        * <p>
+        * Do not modify the object outside the accessor as long as you use the accessor.
+        * Exterioir modifications will mix up listening the mechanism.
+        * Also, do not create more than one accessor to one Object. 
+        * <p>
+        * The accessor is not multi-thread accessible. If you intend to use it in 
+        * concurrent multi-thread environment, use the other method where you can 
+        * pass lock objects in AccessorParams. 
+        * 
+        * @since 0.5
+        * @param variant
+        * @return accessor
+        * @throws AccessorConstructionException
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends Accessor> T getAccessor(Variant variant) 
+       throws AccessorConstructionException {
+               return (T) JavaObject.createAccessor(null, variant.getBinding(), variant.getValue(), AccessorParams.DEFAULT);
+       }       
+
+       /**
+        * Open an accessor to a Varint Object.
+        * <p>
+        * Accessor is disposed by leaving it to garbage collector.
+        * <p>
+        * Do not modify the object outside the accessor as long as you use the accessor.
+        * Exterioir modifications will mix up listening the mechanism.
+        * Also, do not create more than one accessor to one Object. 
+        * <p>
+        * The accessor is not multi-thread accessible. If you intend to use it in 
+        * concurrent multi-thread environment, use the other method where you can 
+        * pass lock objects in AccessorParams. 
+        * 
+        * @since 0.5
+        * @param binding
+        * @param ref child reference
+        * @return accessor
+        * @throws AccessorConstructionException
+        */
+       @SuppressWarnings("unchecked")
+       public static <T extends Accessor> T getAccessor(Variant variant, ChildReference ref) 
+       throws AccessorConstructionException {
+               Accessor a = getAccessor( variant );
+               return a.getComponent( ref );
        }       
-\r
-       /**\r
-        * Open an accessor to a Varint Object.\r
-        * <p>\r
-        * Accessor is disposed by leaving it to garbage collector.\r
-        * <p>\r
-        * Do not modify the object outside the accessor as long as you use the accessor.\r
-        * Exterioir modifications will mix up listening the mechanism.\r
-        * Also, do not create more than one accessor to one Object. \r
-        * <p>\r
-        * The accessor is not multi-thread accessible. If you intend to use it in \r
-        * concurrent multi-thread environment, use the other method where you can \r
-        * pass lock objects in AccessorParams. \r
-        * \r
-        * @since 0.5\r
-        * @param binding\r
-        * @param ref child reference\r
-        * @return accessor\r
-        * @throws AccessorConstructionException\r
-        */\r
-       @SuppressWarnings("unchecked")\r
-       public static <T extends Accessor> T getAccessor(Variant variant, ChildReference ref) \r
-       throws AccessorConstructionException {\r
-               Accessor a = getAccessor( variant );\r
-               return a.getComponent( ref );\r
-       }       \r
        
        /**
         * Open Accessor to a Java Object. This version reads the type using reflection.
-        * <p>\r
-        * Accessor is disposed by leaving it to garbage collector.\r
+        * <p>
+        * Accessor is disposed by leaving it to garbage collector.
         * <p>
         * Do not modify the object outside the accessor as long as you use the accessor.
         * Exterioir modifications will mix up listening the mechanism.
         * Also, do not create more than one accessor to one Object. 
         * <p>
-        * The accessor is not multi-thread accessible. If you intend to use it in \r
-        * concurrent multi-thread environment, use the other method where you can \r
-        * pass lock objects in AccessorParams. \r
+        * The accessor is not multi-thread accessible. If you intend to use it in 
+        * concurrent multi-thread environment, use the other method where you can 
+        * pass lock objects in AccessorParams. 
         * 
         * @since 0.5
         * @param value
@@ -219,102 +219,102 @@ public class Accessors {
                } catch (BindingConstructionException e) {
                        throw new AccessorConstructionException(e);
                }
-       }\r
-       \r
-       /**\r
-        * Open an accessor to a binary file (.dbb). The file is always a variant.\r
-        * The accessor must be closed by invoking {@link FileAccessor#close()} at \r
-        * root or any sub-accessor.\r
-        * <p>\r
-        * To share accessors of the same file use {@link FileLibrary} utility.\r
-        * \r
-        * @since 0.5\r
-        * @param file\r
-        * @return file accessor\r
-        * @throws AccessorConstructionException \r
-        */\r
-       public static FileVariantAccessor openAccessor(File file) throws AccessorConstructionException {                \r
-               try {                   \r
-                       BinaryFile bf = new BinaryFile(file);\r
-                       FileVariantAccessor result = (FileVariantAccessor) BinaryObject.createAccessor(bf, Datatypes.VARIANT, AccessorParams.DEFAULT);\r
-                       return result;\r
-               } catch (IOException e) {\r
-                       throw new AccessorConstructionException(e);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Open a stream file (.stm). Stream file is an array of elements, with no \r
-        * header. Element size is constant. \r
-        * <p>\r
-        * To create an empty stream file, just create an empty file.\r
-        * \r
-        * @param file\r
-        * @param type expected array type\r
-        * @return accessor\r
-        * @throws AccessorConstructionException\r
-        */\r
-       public static FileArrayAccessor openStream(File file, ArrayType type) throws AccessorConstructionException {\r
-               return openStream(file, type, "rw");\r
-       }\r
-\r
-       /**\r
-        * Open a stream file (.stm). Stream file is an array of elements, with no \r
-        * header. Element size is constant. \r
-        * <p>\r
-        * To create an empty stream file, just create an empty file.\r
-        * \r
-        * @param file\r
-        * @param type expected array type\r
-        * @param mode Mode "r" or "rw"\r
-        * @return accessor\r
-        * @throws AccessorConstructionException\r
-        */\r
-       public static FileArrayAccessor openStream(File file, ArrayType type, String mode) throws AccessorConstructionException {\r
-               return openStream(file, type, mode, null);\r
-       }\r
-       \r
-       /**\r
-        * Open a stream file (.stm). Stream file is an array of elements, with no \r
-        * header. Element size is constant. \r
-        * <p>\r
-        * To create an empty stream file, just create an empty file.\r
-        * \r
-        * @param file\r
-        * @param type expected array type\r
-        * @param mode Mode "r" or "rw"\r
-        * @param index accessor to long array that keeps the index of the variable width stream \r
-        * @return accessor\r
-        * @throws AccessorConstructionException\r
-        */\r
-       public static FileArrayAccessor openStream(File file, ArrayType type, String mode, ArrayAccessor index) throws AccessorConstructionException {\r
-               try {                   \r
-                       BinaryFile bf = new BinaryFile(file, mode);\r
-                       Blob blob = new Blob(bf);\r
-                       Binding b = Bindings.getBinding(type.componentType);\r
-                       Serializer s = Bindings.getSerializer(b);\r
-                       if ( s.getConstantSize() != null ) {\r
-                               return new BinaryStreamArray(null, blob, type, AccessorParams.DEFAULT);\r
-                       } else {\r
-                               if ( index == null ) {\r
-                                       return new BinaryArray(null, blob, type, AccessorParams.DEFAULT);\r
-                               } else {\r
-                                       return new BinaryVariableWidthStreamArray(null, blob, type, AccessorParams.DEFAULT, index);\r
-                               }\r
-                       }\r
-               } catch (IOException e) {\r
-                       throw new AccessorConstructionException(e);\r
-               } catch (AccessorException e) {\r
-                       throw new AccessorConstructionException(e);\r
-               } catch (SerializerConstructionException e) {\r
-                       throw new AccessorConstructionException(e);\r
-               }               \r
-       }\r
+       }
+       
+       /**
+        * Open an accessor to a binary file (.dbb). The file is always a variant.
+        * The accessor must be closed by invoking {@link FileAccessor#close()} at 
+        * root or any sub-accessor.
+        * <p>
+        * To share accessors of the same file use {@link FileLibrary} utility.
+        * 
+        * @since 0.5
+        * @param file
+        * @return file accessor
+        * @throws AccessorConstructionException 
+        */
+       public static FileVariantAccessor openAccessor(File file) throws AccessorConstructionException {                
+               try {                   
+                       BinaryFile bf = new BinaryFile(file);
+                       FileVariantAccessor result = (FileVariantAccessor) BinaryObject.createAccessor(bf, Datatypes.VARIANT, AccessorParams.DEFAULT);
+                       return result;
+               } catch (IOException e) {
+                       throw new AccessorConstructionException(e);
+               }
+       }
+
+       /**
+        * Open a stream file (.stm). Stream file is an array of elements, with no 
+        * header. Element size is constant. 
+        * <p>
+        * To create an empty stream file, just create an empty file.
+        * 
+        * @param file
+        * @param type expected array type
+        * @return accessor
+        * @throws AccessorConstructionException
+        */
+       public static FileArrayAccessor openStream(File file, ArrayType type) throws AccessorConstructionException {
+               return openStream(file, type, "rw");
+       }
+
+       /**
+        * Open a stream file (.stm). Stream file is an array of elements, with no 
+        * header. Element size is constant. 
+        * <p>
+        * To create an empty stream file, just create an empty file.
+        * 
+        * @param file
+        * @param type expected array type
+        * @param mode Mode "r" or "rw"
+        * @return accessor
+        * @throws AccessorConstructionException
+        */
+       public static FileArrayAccessor openStream(File file, ArrayType type, String mode) throws AccessorConstructionException {
+               return openStream(file, type, mode, null);
+       }
+       
+       /**
+        * Open a stream file (.stm). Stream file is an array of elements, with no 
+        * header. Element size is constant. 
+        * <p>
+        * To create an empty stream file, just create an empty file.
+        * 
+        * @param file
+        * @param type expected array type
+        * @param mode Mode "r" or "rw"
+        * @param index accessor to long array that keeps the index of the variable width stream 
+        * @return accessor
+        * @throws AccessorConstructionException
+        */
+       public static FileArrayAccessor openStream(File file, ArrayType type, String mode, ArrayAccessor index) throws AccessorConstructionException {
+               try {                   
+                       BinaryFile bf = new BinaryFile(file, mode);
+                       Blob blob = new Blob(bf);
+                       Binding b = Bindings.getBinding(type.componentType);
+                       Serializer s = Bindings.getSerializer(b);
+                       if ( s.getConstantSize() != null ) {
+                               return new BinaryStreamArray(null, blob, type, AccessorParams.DEFAULT);
+                       } else {
+                               if ( index == null ) {
+                                       return new BinaryArray(null, blob, type, AccessorParams.DEFAULT);
+                               } else {
+                                       return new BinaryVariableWidthStreamArray(null, blob, type, AccessorParams.DEFAULT, index);
+                               }
+                       }
+               } catch (IOException e) {
+                       throw new AccessorConstructionException(e);
+               } catch (AccessorException e) {
+                       throw new AccessorConstructionException(e);
+               } catch (SerializerConstructionException e) {
+                       throw new AccessorConstructionException(e);
+               }               
+       }
        
        /**
         * Create a new binary file with an empty value and open an accessor.
-        * If file already exists, it is overwritten.\r
-        * It is recommended that the file extension is .dbb (Databoard Binary)\r
+        * If file already exists, it is overwritten.
+        * It is recommended that the file extension is .dbb (Databoard Binary)
         * <p>
         * The caller must close the file with {@link FileAccessor#close()}.  
         * 
@@ -324,7 +324,7 @@ public class Accessors {
         */
        public static FileVariantAccessor createFile(File file) 
        throws AccessorConstructionException {
-               try {\r
+               try {
                        file.createNewFile();
                        BinaryFile bf = new BinaryFile(file);
                        FileVariantAccessor result = (FileVariantAccessor) BinaryObject.createAccessor(bf, Datatypes.VARIANT, AccessorParams.DEFAULT);
@@ -357,13 +357,13 @@ public class Accessors {
                }
        }       
 
-       /**\r
-        * Create a binary file (.dbb) and open an accessor. The file is always a variant.\r
-        * <p>\r
-        * File is closed with {@link FileAccessor#close()} at root or any \r
-        * sub-accessor.\r
-        * <p>\r
-        * To share accessors of the same file use {@link FileLibrary} utility.\r
+       /**
+        * Create a binary file (.dbb) and open an accessor. The file is always a variant.
+        * <p>
+        * File is closed with {@link FileAccessor#close()} at root or any 
+        * sub-accessor.
+        * <p>
+        * To share accessors of the same file use {@link FileLibrary} utility.
         * 
         * @param <T>
         * @param file
@@ -374,17 +374,17 @@ public class Accessors {
        @SuppressWarnings("unchecked")
        public static <T extends FileAccessor> T createFile(File file, Datatype type) throws AccessorConstructionException
        {
-               boolean existed;\r
-               BinaryFile bf;\r
-               try {\r
-                       existed = file.createNewFile();\r
-                       bf = new BinaryFile(file);\r
-               } catch (IOException e1) {\r
-                       throw new AccessorConstructionException(e1);\r
-               }\r
-               \r
+               boolean existed;
+               BinaryFile bf;
+               try {
+                       existed = file.createNewFile();
+                       bf = new BinaryFile(file);
+               } catch (IOException e1) {
+                       throw new AccessorConstructionException(e1);
+               }
+               
                try {
-                       FileVariantAccessor result = (FileVariantAccessor) BinaryObject.createAccessor(bf, Datatypes.VARIANT, AccessorParams.DEFAULT);\r
+                       FileVariantAccessor result = (FileVariantAccessor) BinaryObject.createAccessor(bf, Datatypes.VARIANT, AccessorParams.DEFAULT);
                        Binding binding = Bindings.getMutableBinding(type);
                        Object value = binding.createDefault();
                        result.setContentValue(binding, value);
@@ -397,48 +397,48 @@ public class Accessors {
                        throw new AccessorConstructionException(e);
                }
        }
-       \r
-       /**\r
-        * Open a Map(Variant, Variant) accessor to a directory.\r
-        * Map entries are binary files (.dbb), and the file name is the key with the following encoding: \r
-        *   \r
-        *  Filenames have the following encoding:\r
-        *    S<string>.dbb   String types\r
-        *                        Control characters " : < > | ? * \ / % [0..31] [128..] are escaped as %<hex><hex>\r
-        *                        " "-space is _\r
-        *    I<integer>.dbb  Integer types\r
-        *    L<long>.dbb     Long types\r
-        *    H<hex>.dbb      All other cases the value as binary \r
-        * \r
-        * The caller must close (FolderMap#close()) the accessor after usage. \r
-        * This releases file handles and a directory polling thread.\r
-        * \r
-        * FolderMap is not concurrent-use-safe. Its files are not either.\r
-        * The user must ensure that the files are not used concurrently from \r
-        * different threads.\r
-        * \r
-        * @param directory\r
-        * @return MapAccessor\r
-        */\r
-       public static DirectoryMap openDirectory(File directory) {\r
-               return new DirectoryMap(directory);\r
-       }       \r
-       \r
-       /**\r
-        * Get an executor for current thread\r
-        * \r
-        * @return executor\r
-        */\r
-       public static Executor getCurrentThread() {\r
-               return Accessors.getCurrentThread();\r
-       }\r
-       \r
-       static Executor CURRENT_THREAD = new Executor() {\r
-               @Override\r
-               public void execute(Runnable command) {\r
-                       command.run();\r
-               }               \r
-       };      \r
+       
+       /**
+        * Open a Map(Variant, Variant) accessor to a directory.
+        * Map entries are binary files (.dbb), and the file name is the key with the following encoding: 
+        *   
+        *  Filenames have the following encoding:
+        *    S<string>.dbb   String types
+        *                        Control characters " : < > | ? * \ / % [0..31] [128..] are escaped as %<hex><hex>
+        *                        " "-space is _
+        *    I<integer>.dbb  Integer types
+        *    L<long>.dbb     Long types
+        *    H<hex>.dbb      All other cases the value as binary 
+        * 
+        * The caller must close (FolderMap#close()) the accessor after usage. 
+        * This releases file handles and a directory polling thread.
+        * 
+        * FolderMap is not concurrent-use-safe. Its files are not either.
+        * The user must ensure that the files are not used concurrently from 
+        * different threads.
+        * 
+        * @param directory
+        * @return MapAccessor
+        */
+       public static DirectoryMap openDirectory(File directory) {
+               return new DirectoryMap(directory);
+       }       
+       
+       /**
+        * Get an executor for current thread
+        * 
+        * @return executor
+        */
+       public static Executor getCurrentThread() {
+               return Accessors.getCurrentThread();
+       }
+       
+       static Executor CURRENT_THREAD = new Executor() {
+               @Override
+               public void execute(Runnable command) {
+                       command.run();
+               }               
+       };      
        
 }