edu.upc.dama.dex.io
Class Exporter

java.lang.Object
  extended by edu.upc.dama.dex.io.Exporter
Direct Known Subclasses:
EdgeTypeExporter, NodeTypeExporter

public class Exporter
extends java.lang.Object

Export data of node or edge type.

It allows for export data structured as rows in a node or edge type from a Graph.

Since data is structured as rows (CSV files, etc), it uses a RowWriter to set all data.

When the exporter is running a Exporter.ExporterEvent is sent to their listeners with a given frequency.

Author:
Sparsity Technologies

Nested Class Summary
 class Exporter.ExporterEvent
          Constains information of the running Exporter.
 
Field Summary
protected  long headAttr
          Attribute identifier in the Graph of the tail node type.
protected  int headPos
          Position to be written the head id on the RowWriter.
protected  long tailAttr
          Attribute identifier in the Graph of the tail node type.
protected  int tailPos
          Position to be written the tail id on the RowWriter.
 
Constructor Summary
Exporter(RowWriter rowWriter, Graph graph, int objectType)
          Creates a new instance of Exporter.
Exporter(RowWriter rowWriter, Graph graph, int objectType, java.lang.Long[] exportAttr)
          Creates a new instance of Exporter.
 
Method Summary
 int getFrequency()
          Gets the frequency when Exporter.ExporterEvents are sent to their ExporterListener.
 boolean getNamesOnTop()
          Gets the policy of print attributes information on the first line of the writer.
 void registerUnloaderListener(ExporterListener ul)
          Adds a new ExporterListener.
 void run()
          Start the exportation.
 void setFrequency(int frequency)
          Updates the frequency of the Exporter.ExporterEvents.
 void setNamesOnTop(boolean b)
          Sets the policy of print attributes information on the first line of the writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headPos

protected int headPos
Position to be written the head id on the RowWriter.


tailPos

protected int tailPos
Position to be written the tail id on the RowWriter.


headAttr

protected long headAttr
Attribute identifier in the Graph of the tail node type.


tailAttr

protected long tailAttr
Attribute identifier in the Graph of the tail node type.

Constructor Detail

Exporter

public Exporter(RowWriter rowWriter,
                Graph graph,
                int objectType,
                java.lang.Long[] exportAttr)
Creates a new instance of Exporter.

Parameters:
rowWriter - RowWriter to write data.
graph - Graph that objects are exported.
objectType - Node or edge type to be exported.
exportAttr - Attributes id of the objectType to be exported.

Exporter

public Exporter(RowWriter rowWriter,
                Graph graph,
                int objectType)
Creates a new instance of Exporter.

Parameters:
rowWriter - RowWriter to write data.
graph - Graph that objects are exported.
objectType - Node or edge type to be exported.
Method Detail

registerUnloaderListener

public void registerUnloaderListener(ExporterListener ul)
Adds a new ExporterListener.

Parameters:
ul - A ExporterListener to be registered.

setFrequency

public void setFrequency(int frequency)
Updates the frequency of the Exporter.ExporterEvents.

Parameters:
frequency - New frequency value.

getFrequency

public int getFrequency()
Gets the frequency when Exporter.ExporterEvents are sent to their ExporterListener.

Returns:
The frequency.

setNamesOnTop

public void setNamesOnTop(boolean b)
Sets the policy of print attributes information on the first line of the writer.

Parameters:
b - If true, atrribute information is printed on the first line of the writer.

getNamesOnTop

public boolean getNamesOnTop()
Gets the policy of print attributes information on the first line of the writer.

Returns:
The policy of print attributes information on the first line of the writer.

run

public void run()
         throws java.io.IOException
Start the exportation.

Throws:
java.io.IOException - If bad things happen during the write.