netkit.graph.io
Class NodeReader
java.lang.Object
netkit.graph.io.NodeReader
public final class NodeReader
- extends java.lang.Object
This class reads Node instance data from a Reader object. The
input format is line oriented and organized into columns
corresponding to Node instance data fields. Column delimiters are
commas, and no decorative whitespace is allowed in between values
and the delimiters. Each line represents the instance data for one
Node. The order of the values must match the order of the fields
in the Attributes container of the node type. Data is always
converted into java double types. The conversion for CONTINUOUS
and DISCRETE values is straightforward, except that DISCRETE values
must be a valid integer type before conversion to double.
CATEGORICAL types are first converted into int values coresponding
to the order they appear defined in the TokenSet of the
AttributeCategorical they are from. The KEY field additionally
gets inserted into the name field for each Node and must be unique
across each node type with a single Graph. Lines may contain
comments, which are lines where a '%' or '#' is the first
character. Comments are terminated by the end-of-line.
- Author:
- Kaveh R. Ghazi
- See Also:
SchemaReader
,
SchemaWriter
,
NodeWriter
,
Attributes
,
Node
,
Graph
,
TokenSet
,
AttributeCategorical
Method Summary |
static void |
readNodes(Graph graph,
java.lang.String nodeType,
java.io.Reader reader,
boolean skipFirstLine)
This static method does the work of reading input data for the
class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NodeReader
public NodeReader()
readNodes
public static void readNodes(Graph graph,
java.lang.String nodeType,
java.io.Reader reader,
boolean skipFirstLine)
- This static method does the work of reading input data for the
class. Given a Graph object, a node type name and an input
Reader object, it will read in the Node data and instantiate
Nodes as part of the supplied Graph with the appropriate node
type Attributes container. This assumes that the graph object
contains an appropraite Attributes object with a corresponding
nodeType. The Attributes object must contain a key Attribute.
- Parameters:
graph
- the Graph object to insert Nodes into.nodeType
- the node type name for these Nodes.reader
- the Reader object to read instance data from; the
Reader will be closed when this method completes.skipFirstLine
- true if the reader should skip the first
line of input; appropriate if the first line contains column
headers as in GDA files.
- Throws:
java.lang.RuntimeException
- if any of the input format constraints
are violated or the input cannot be read.