Search this API

y.io.gml
Class GraphParser

java.lang.Object
  extended by y.io.gml.ItemParser
      extended by y.io.gml.GraphParser
All Implemented Interfaces:
GMLTokenizer.Callback
Direct Known Subclasses:
HierarchicGraphParser

public class GraphParser
extends ItemParser

This class works together with NodeParser and EdgeParser instances. It can parse the .graph scope It will store the mapping between element ids (Integer) to element instances in the graph.

 

Field Summary
protected  Graph2D graph
          The graph that this parser is currently building.
protected  java.util.Map id2Edge
          The map that is currently used by the parser to map GML String IDs to actual edges.
protected  java.util.Map id2Node
          The map that is currently used by the parser to map GML String IDs to actual nodes.
 
Fields inherited from class y.io.gml.ItemParser
attributes, childMap, delegate, level
 
Constructor Summary
GraphParser(Graph2D graph)
          Creates a new instance that will build the given graph.
 
Method Summary
 void addAttribute(java.lang.String key, java.lang.Object value)
          Puts the key value pair into the local attribute map
 void end()
          this method will be called as soon as the parser leaves the scope.
 java.util.Map getId2Edge()
          Getter for property id2Edge.
 java.util.Map getId2Node()
          Getter for property id2Node.
 java.lang.Object getItem()
          Returns the "product" of this scope.
 
Methods inherited from class y.io.gml.ItemParser
addChild, attribute, attribute, begin, beginScope, childFinished, endScope, getAttributes, getBoolean, getDouble, getDouble, getInt, getInt, getLevel, getString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected Graph2D graph
The graph that this parser is currently building.


id2Node

protected java.util.Map id2Node
The map that is currently used by the parser to map GML String IDs to actual nodes.


id2Edge

protected java.util.Map id2Edge
The map that is currently used by the parser to map GML String IDs to actual edges.

Constructor Detail

GraphParser

public GraphParser(Graph2D graph)
Creates a new instance that will build the given graph.

Parameters:
graph -
Method Detail

getItem

public java.lang.Object getItem()
Description copied from class: ItemParser
Returns the "product" of this scope. This method should be called after this parser has left the scope, i.e. after ItemParser.end() has been called. The latter should construct the resulting item from the collected data and this item should be returned by this method. By default, this method return the map of the attributes.

Overrides:
getItem in class ItemParser
Returns:
the result of the parsing, in this case a Map

getId2Edge

public java.util.Map getId2Edge()
Getter for property id2Edge.

Returns:
Value of property id2Edge.

getId2Node

public java.util.Map getId2Node()
Getter for property id2Node.

Returns:
Value of property id2Node.

addAttribute

public void addAttribute(java.lang.String key,
                         java.lang.Object value)
Description copied from class: ItemParser
Puts the key value pair into the local attribute map

Overrides:
addAttribute in class ItemParser
Parameters:
key - the key
value - the value

end

public void end()
Description copied from class: ItemParser
this method will be called as soon as the parser leaves the scope. This implementation does nothing. Subclasses should nevertheless make a super call.

Overrides:
end in class ItemParser

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.