net.xqhs.graphs.pattern
Class NodeP

java.lang.Object
  extended by net.xqhs.graphs.representation.AbstractVisualizableGraphComponent
      extended by net.xqhs.graphs.graph.SimpleNode
          extended by net.xqhs.graphs.pattern.NodeP
All Implemented Interfaces:
GraphComponent, Node, VisualizableGraphComponent

public class NodeP
extends SimpleNode

The NodeP is a node that is part of a GraphPattern and may be generic (used in graph matching to match any node in the matched graph).

A generic node is characterized by a label equal to a specific symbol (usually a question mark) and an index, to identify a specific generic node in a graph.

Author:
Andrei Olaru

Field Summary
(package private)  boolean generic
          Indicates that the node is generic.
(package private)  int labelIndex
          Indicates the identifier of the generic node.
static java.lang.String NODEP_INDEX_MARK
          The symbol used in the string representation between the label and the generic index.
static java.lang.String NODEP_LABEL
          The label of all generic nodes.
 
Fields inherited from class net.xqhs.graphs.graph.SimpleNode
label
 
Fields inherited from class net.xqhs.graphs.representation.AbstractVisualizableGraphComponent
representations
 
Constructor Summary
NodeP()
          Creates a new generic NodeP, with an uninitialized index.
NodeP(int genericIndex)
          Creates a new generic NodeP, with a specified index.
NodeP(java.lang.String label)
          Creates a new, non-generic NodeP, with a specified label.
 
Method Summary
 int genericIndex()
           
 boolean isGeneric()
           
 java.lang.String toString()
           
 
Methods inherited from class net.xqhs.graphs.graph.SimpleNode
getLabel
 
Methods inherited from class net.xqhs.graphs.representation.AbstractVisualizableGraphComponent
addRepresentation, getFirstRepresentationForRoot, getRepresentations, getRepresentationsForRoot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NODEP_LABEL

public static final java.lang.String NODEP_LABEL
The label of all generic nodes.

See Also:
Constant Field Values

NODEP_INDEX_MARK

public static final java.lang.String NODEP_INDEX_MARK
The symbol used in the string representation between the label and the generic index.

See Also:
Constant Field Values

generic

boolean generic
Indicates that the node is generic.


labelIndex

int labelIndex
Indicates the identifier of the generic node. It will be strictly positive for generic nodes.

Note: this can only be used in one graph at a time.

Constructor Detail

NodeP

public NodeP()
Creates a new generic NodeP, with an uninitialized index.

Note: the node needs to be indexed before being added to a graph. The add(node) method in GraphPattern does that.


NodeP

public NodeP(int genericIndex)
Creates a new generic NodeP, with a specified index.

WARNING: use this with great caution.

Parameters:
genericIndex - - be absolutely certain this is not the same index with other nodes in the graph

NodeP

public NodeP(java.lang.String label)
Creates a new, non-generic NodeP, with a specified label. It calls the constructor in SimpleNode.

It is assumed that the label is not equal to NODEP_LABEL.

Parameters:
label - - the label for the new node
Method Detail

isGeneric

public boolean isGeneric()
Returns:
true is the node is generic.

genericIndex

public int genericIndex()
Returns:
the index of the generic node, or 0 if the node is not generic.

toString

public java.lang.String toString()
Overrides:
toString in class SimpleNode