org.simantics.databoard
Class Files

java.lang.Object
  extended by org.simantics.databoard.Files

public class Files
extends java.lang.Object


Constructor Summary
Files()
           
 
Method Summary
static void createFile(java.io.File file)
          Create a new binary file (.dbb) with an empty value.
static void createFile(java.io.File file, Binding binding, java.lang.Object value)
          Create a binary file (.dbb) with a initial value.
static void createFile(java.io.File file, Datatype type)
          Create a binary file (.dbb) with empty value of given type.
static void createTextFile(java.io.File file, Binding binding, java.lang.Object value)
          Create a text file (.dbv) with a value.
static java.io.DataInput openInput(byte[] data)
           
static java.io.DataInput openInput(java.io.File file)
           
static java.io.DataInput openInput(java.io.InputStream is)
           
static java.io.DataOutput openOutput(byte[] data)
           
static java.io.DataOutput openOutput(java.io.File file)
           
static java.io.DataOutput openOutput(java.io.OutputStream os)
           
static java.lang.Object readFile(java.io.File file, Binding binding)
          Read a binary file into a java instance.
static void readFile(java.io.File file, RecordBinding binding, java.lang.Object dst)
          Read a file to an object.
static java.lang.Object readFile(java.io.InputStream is, Binding binding)
          Read input stream into a java instance.
static java.lang.Object readFile(java.io.InputStream is, long streamLength, Binding binding)
          Read input stream into a java instance.
static Datatype readFileType(java.io.File file)
          Read file type of a binary file.
static java.lang.Object readTextFile(java.io.File file, Binding binding)
          Read a text file (.dbv).
static void writeFile(java.io.File file, Binding binding, java.lang.Object value)
          Write value as binary file (.dbb).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Files

public Files()
Method Detail

createTextFile

public static void createTextFile(java.io.File file,
                                  Binding binding,
                                  java.lang.Object value)
                           throws java.io.IOException
Create a text file (.dbv) with a value. The file is UTF-8 encoded. If old file exists, it is deleted.

Parameters:
file -
binding -
value -
Throws:
java.io.IOException

createFile

public static void createFile(java.io.File file,
                              Binding binding,
                              java.lang.Object value)
                       throws java.io.IOException
Create a binary file (.dbb) with a initial value. Binary file is a variant, there is a filetype in the header of the file. If old file exists, it is deleted.

Parameters:
file -
binding -
value -
Throws:
java.io.IOException

createFile

public static void createFile(java.io.File file)
                       throws java.io.IOException,
                              RuntimeSerializerConstructionException
Create a new binary file (.dbb) with an empty value. Binary file is a variant, there is a filetype in the header of the file. If old file exists, it is deleted.

Parameters:
file -
Throws:
java.io.IOException
RuntimeSerializerConstructionException
Since:
0.5

createFile

public static void createFile(java.io.File file,
                              Datatype type)
                       throws java.io.IOException,
                              RuntimeSerializerConstructionException
Create a binary file (.dbb) with empty value of given type. Binary file is a variant, there is a filetype in the header of the file. If old file exists, it is deleted.

Parameters:
file -
type -
Throws:
java.io.IOException
RuntimeSerializerConstructionException

readTextFile

public static java.lang.Object readTextFile(java.io.File file,
                                            Binding binding)
                                     throws java.io.IOException,
                                            DataTypeSyntaxError,
                                            BindingException
Read a text file (.dbv).

Parameters:
file -
binding -
Returns:
value
Throws:
java.io.IOException
BindingException
DataTypeSyntaxError

readFileType

public static Datatype readFileType(java.io.File file)
                             throws java.io.IOException
Read file type of a binary file.

Parameters:
file -
Returns:
datatype
Throws:
java.io.IOException

readFile

public static java.lang.Object readFile(java.io.File file,
                                        Binding binding)
                                 throws java.io.IOException
Read a binary file into a java instance. Binary file is a variant, there is a filetype in the header of the file. If requested binding is not the exact binding of the file, an adapter is tried.

Parameters:
file - file
binding - content binding
Returns:
instance
Throws:
java.io.IOException

readFile

public static void readFile(java.io.File file,
                            RecordBinding binding,
                            java.lang.Object dst)
                     throws java.io.IOException
Read a file to an object.

Parameters:
file -
binding -
dst -
Throws:
java.io.IOException

readFile

public static java.lang.Object readFile(java.io.InputStream is,
                                        Binding binding)
                                 throws java.io.IOException
Read input stream into a java instance. Binary file is a variant, there is a filetype in the header of the file. If requested binding is not the exact binding of the file, an adapter is tried.

The implementation reads the inputstream fully into memory.

Parameters:
is - input stream
binding - content binding
Returns:
instance
Throws:
java.io.IOException

readFile

public static java.lang.Object readFile(java.io.InputStream is,
                                        long streamLength,
                                        Binding binding)
                                 throws java.io.IOException
Read input stream into a java instance. If requested binding is not the exact binding of the file, an adapter is tried.

Parameters:
is - input stream
streamLength -
binding - content binding
Returns:
instance
Throws:
java.io.IOException
AccessorException

writeFile

public static void writeFile(java.io.File file,
                             Binding binding,
                             java.lang.Object value)
                      throws java.io.IOException
Write value as binary file (.dbb).

Parameters:
file - file
binding - content binding
value - value
Throws:
java.io.IOException

openInput

public static java.io.DataInput openInput(java.io.InputStream is)

openInput

public static java.io.DataInput openInput(java.io.File file)
                                   throws java.io.IOException
Throws:
java.io.IOException

openInput

public static java.io.DataInput openInput(byte[] data)

openOutput

public static java.io.DataOutput openOutput(java.io.OutputStream os)

openOutput

public static java.io.DataOutput openOutput(java.io.File file)
                                     throws java.io.IOException
Throws:
java.io.IOException

openOutput

public static java.io.DataOutput openOutput(byte[] data)
                                     throws java.io.IOException
Throws:
java.io.IOException