venice
Class VeniceFileHandler

java.lang.Object
  |
  +--venice.VeniceFileHandler

public class VeniceFileHandler
extends java.lang.Object

VeniceFileHandler is an class which is used to handle loading and saving of .venice-files which is the native storage format of Venice. .venice-files are Zipped files which include both the model in GXL format (model.gxl) and the visualization in visualization subsystems native format (model.visualization).

Do not use the same VeniceFileHandler instance for both loading and saving!

Example of using this class for saving a file in .venice-format:

 VeniceFileHandler vfh = new VeniceFileHandler();

 OutputStream gxlStream = vfh.getGXLOutputStream();
 OutputStream visStream = vfh.getVisualizationOutputStream();

        
 PrintWriter pw;

 pw = new PrintWriter(gxlStream);

 pw.println("This is the GXL FILE!");
 pw.close();

 pw = new PrintWriter(visStream);
 pw.println("This is the Visualization file!");
 pw.close();

 OutputStream os = new FileOutputStream("testfile.venice");
 vfh.writeTo(os);
 

Example of using this class for loading a file in .venice-format:

 InputStream is = new FileInputStream("testfile.venice");
        
 vfh = new VeniceFileHandler();
 vfh.readFrom(is);

 BufferedReader rdr;

 rdr = new BufferedReader (new InputStreamReader(vfh.getGXLInputStream()));

 System.out.println(rdr.readLine());
 rdr.close();

 rdr = new BufferedReader (new InputStreamReader(vfh.getVisualizationInputStream()));
 System.out.println(rdr.readLine());
 rdr.close();
 

Author:
Hannu Laurila

Field Summary
private static int BUFSIZE
          size of buffer which is used when reading in contents of the archive
private  byte[] mGXLData
          full contents of the GXL file as a byte array
private  java.io.ByteArrayOutputStream mGXLOutputStream
          output stream which is returned to applications wanting to write
private  byte[] mVisualizationData
          full contents of the visualization file as a byte array
private  java.io.ByteArrayOutputStream mVisualizationOutputStream
          output stream which is returned to applications wanting to write
 
Constructor Summary
VeniceFileHandler()
           
 
Method Summary
 java.io.InputStream getGXLInputStream()
          returns an InputStream which can be used to write the GXL file inside the venice file
 java.io.OutputStream getGXLOutputStream()
          returns an OutputStream which can be used to read the GXL file embedded in the venice file.
 java.io.InputStream getVisualizationInputStream()
          returns an InputStream which can be used to write the Visualization file inside the venice file
 java.io.OutputStream getVisualizationOutputStream()
          returns an OutputStream which can be used to read the Visualization file embeded in the venice file.
static void main(java.lang.String[] args)
          Module test routines.
private  byte[] readEntry(java.util.zip.ZipInputStream inZipStream)
          helper method to read one file from ZipInputStream to a byte buffer.
 void readFrom(java.io.InputStream ioStream)
          reads the venice file from the InputStream to the handler. after this the 'substreams' can be requested using get*InputStream() methods.
 void writeTo(java.io.OutputStream ioStream)
          Saves the GXL and visualization files associated with this VeniceFileHandler to a venice file (given as an OutputStream)
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

BUFSIZE

private static final int BUFSIZE
size of buffer which is used when reading in contents of the archive

mGXLData

private byte[] mGXLData
full contents of the GXL file as a byte array

mVisualizationData

private byte[] mVisualizationData
full contents of the visualization file as a byte array

mGXLOutputStream

private java.io.ByteArrayOutputStream mGXLOutputStream
output stream which is returned to applications wanting to write

mVisualizationOutputStream

private java.io.ByteArrayOutputStream mVisualizationOutputStream
output stream which is returned to applications wanting to write
Constructor Detail

VeniceFileHandler

public VeniceFileHandler()
Method Detail

getGXLOutputStream

public java.io.OutputStream getGXLOutputStream()
returns an OutputStream which can be used to read the GXL file embedded in the venice file.

getVisualizationOutputStream

public java.io.OutputStream getVisualizationOutputStream()
returns an OutputStream which can be used to read the Visualization file embeded in the venice file.

getGXLInputStream

public java.io.InputStream getGXLInputStream()
                                      throws java.io.IOException
returns an InputStream which can be used to write the GXL file inside the venice file

getVisualizationInputStream

public java.io.InputStream getVisualizationInputStream()
                                                throws java.io.IOException
returns an InputStream which can be used to write the Visualization file inside the venice file

readFrom

public void readFrom(java.io.InputStream ioStream)
              throws java.io.IOException
reads the venice file from the InputStream to the handler. after this the 'substreams' can be requested using get*InputStream() methods.

readEntry

private byte[] readEntry(java.util.zip.ZipInputStream inZipStream)
                  throws java.io.IOException
helper method to read one file from ZipInputStream to a byte buffer.

writeTo

public void writeTo(java.io.OutputStream ioStream)
             throws java.io.IOException
Saves the GXL and visualization files associated with this VeniceFileHandler to a venice file (given as an OutputStream)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Module test routines.