com.sparsity.dex.gdb
Class TextStream

java.lang.Object
  extended by com.sparsity.dex.gdb.TextStream
All Implemented Interfaces:
java.io.Closeable

public class TextStream
extends java.lang.Object
implements java.io.Closeable

TextStream class.

It allows for reading and writting Text attribute values.

It is very important to close the stream once no more reading or writting operations will be performed to ensure data is successfully stored.

Whereas string attributes are set and got using the Value class, text attributes are operated using a stream pattern.

Use of TextStream for writing: (i) Create a TextStream instance and (ii) set the stream for a text attribute of a node or edge instance with the graph SetAttributeText method. Once the set attribute text has been done, (iii) perform as many write operations as you need to the TextStream instance. Lastly, (iv) exeucte Close to flush and close the stream.

Use of TextStream for reading: (i) Get the stream of a text attribute of a node or edge instance with the GetAttributeText graph method. Once you have the TextStream instance, (ii) you can execute Read operations to read from the stream. (iii) The end of the stream is reached when Read returns 0. Finally, (iv) execute Close to close stream resources.

Check out the 'Attributes and values' section in the DEX User Manual for more details on this.

Author:
Sparsity Technologies http://www.sparsity-technologies.com

Constructor Summary
TextStream(boolean append)
          Creates a new instance.
 
Method Summary
 void close()
          Closes the stream.
 boolean isNull()
          Returns TRUE if the stream is not available.
 int read(char[] dataOUT, int length)
          Read data from the stream.
 void write(char[] dataIN, int length)
          Write data to the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextStream

public TextStream(boolean append)
Creates a new instance.

A TextStream only can be created by the user to write data.

Parameters:
append - [in] If TRUE, the it is created in append mode to write from the end of the stream, otherwise it is created to write from the begining of the stream.
Method Detail

read

public int read(char[] dataOUT,
                int length)
Read data from the stream.

Parameters:
dataOUT - [out] Buffer to read data to. It must be allocated by the user.
length - [in] Length of the given data buffer. It must be > 0.
Returns:
Amount of read data (<= length). If 0, there is no more data to be read from the stream.

isNull

public boolean isNull()
Returns TRUE if the stream is not available.

It returns for reading or writing data.

Returns:
FALSE if the stream is ready

write

public void write(char[] dataIN,
                  int length)
Write data to the stream.

Parameters:
dataIN - [in] Buffer to write data from.
length - [in] Length of the data buffer. It must be > 0.

close

public void close()
Closes the stream.

Once the Stream is closed, it cannot be used again.

Specified by:
close in interface java.io.Closeable