org.nsdl.mptstore.query.component
Class BasicNodePattern<T extends Node>

java.lang.Object
  extended by org.nsdl.mptstore.query.component.BasicNodePattern<T>
Type Parameters:
T - The type of node that is described by the pattern. Typically, this is one of SubjectNode, PredicateNode, ObjectNode, or just Node if the exact node type is unimportant or unknown.
All Implemented Interfaces:
NodePattern<T>

public class BasicNodePattern<T extends Node>
extends java.lang.Object
implements NodePattern<T>

Generic implementation of NodePattern.

Author:
birkland

Constructor Summary
BasicNodePattern(java.lang.String variable)
          Construct a BasicNodePattern representing a variable.
BasicNodePattern(T node)
          Construct a BasicNodePattern representing an actual node.
 
Method Summary
 boolean equals(java.lang.Object p)
          Equality of Triple Pattern
 T getNode()
          Get the node value of this pattern, or null if this pattern does not represent a variable.
 java.lang.String getVarName()
          Get the variable name of this pattern, or null if this pattern does not represent a variable.
 int hashCode()
          Get a hash code for this node pattern.
 boolean isVariable()
          Tell whether this node pattern represents a variable.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicNodePattern

public BasicNodePattern(T node)
Construct a BasicNodePattern representing an actual node.

Parameters:
node - the node.

BasicNodePattern

public BasicNodePattern(java.lang.String variable)
Construct a BasicNodePattern representing a variable.

Parameters:
variable - the variable name.
Method Detail

getNode

public T getNode()
Get the node value of this pattern, or null if this pattern does not represent a variable.

Specified by:
getNode in interface NodePattern<T extends Node>
Returns:
the node value

getVarName

public java.lang.String getVarName()
Get the variable name of this pattern, or null if this pattern does not represent a variable.

Specified by:
getVarName in interface NodePattern<T extends Node>
Returns:
the variable name

isVariable

public boolean isVariable()
Tell whether this node pattern represents a variable.

Specified by:
isVariable in interface NodePattern<T extends Node>
Returns:
whether this pattern represents a variable.

equals

public boolean equals(java.lang.Object p)
Equality of Triple Pattern

Equality of triple patterns follow the following rules:

Overrides:
equals in class java.lang.Object
Parameters:
p - the object to compare this one to.
Returns:
whether the objects are equal according to the rules above.

hashCode

public int hashCode()
Get a hash code for this node pattern. If variable, the hash code is that of the variable string. Otherwise, it's the hash code of the node.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object