- }\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);
+ }
+ }