Class Predicate

java.lang.Object
dev.roanh.gmark.core.graph.Predicate
All Implemented Interfaces:
OutputSQL, OutputXML, IDable, Comparable<Predicate>

public class Predicate extends Object implements OutputXML, OutputSQL, Comparable<Predicate>, IDable
Class describing predicates applied to graph edges, also called symbols. These predicates can also represent following an edge in its inverse direction from target to source.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    The textual alias name of this predicate.
    static final char
    The character used to denote negated predicates.
    private int
    The unique ID of this predicate.
    private Predicate
    The inverse predicate object or null.
    private boolean
    True if this predicate represents the inverse of the original predicate, meaning it specifies that a directed edge should be followed in the reverse direction.
    private Double
    Fraction of all edges in the graph that have this symbol.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Predicate(int id, String alias)
    Constructs a new predicate with the given ID and alias.
     
    Predicate(int id, String alias, Double proportion)
    Constructs a new predicate with the given ID and alias and graph proportion.
    private
    Predicate(Predicate predicate)
    Constructs an inverse predicate for the given predicate.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
    equals(Object other)
     
    Gets the textual representation for this symbol.
    int
    Gets the unique ID for this object.
    Gets the inverse predicate for this predicate.
    int
     
    boolean
    True if this predicate represents the inverted form of the symbol (going from target to source).
    Converts this object to an SQL query.
     
    void
    Writes this object as XML to the given writer.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface dev.roanh.gmark.output.OutputXML

    toXML
  • Field Details

    • CHAR_INVERSE

      public static final char CHAR_INVERSE
      The character used to denote negated predicates.
      See Also:
    • id

      private int id
      The unique ID of this predicate. This ID uniquely identifies this predicate among all predicates. Note that the inverse predicate has the same ID.
    • alias

      private String alias
      The textual alias name of this predicate.
    • proportion

      private Double proportion
      Fraction of all edges in the graph that have this symbol. Will be null if this is not specified.
    • isInverse

      private boolean isInverse
      True if this predicate represents the inverse of the original predicate, meaning it specifies that a directed edge should be followed in the reverse direction.
    • inverse

      private Predicate inverse
      The inverse predicate object or null.
  • Constructor Details

    • Predicate

      public Predicate(int id, String alias)
      Constructs a new predicate with the given ID and alias.
      Parameters:
      id - The ID of this predicate.
      alias - The alias of this predicate.
    • Predicate

      public Predicate(int id, String alias, Double proportion)
      Constructs a new predicate with the given ID and alias and graph proportion.
      Parameters:
      id - The ID of this predicate.
      alias - The alias of this predicate.
      proportion - The fraction of all edges in the graph that have this symbol. Can be set to null to leave this unspecified.
    • Predicate

      private Predicate(Predicate predicate)
      Constructs an inverse predicate for the given predicate.
      Parameters:
      predicate - The predicate to invert.
  • Method Details

    • isInverse

      public boolean isInverse()
      True if this predicate represents the inverted form of the symbol (going from target to source).
      Returns:
      True if this is an inverse predicate.
    • getAlias

      public String getAlias()
      Gets the textual representation for this symbol. If this predicate is inverted then this will include a super script minus character at the end.
      Returns:
      The predicate alias.
    • getInverse

      public Predicate getInverse()
      Gets the inverse predicate for this predicate. The inverse predicate basically indicates traversing an edge with the predicate in the reverse direction from target to source and is indicated by a super script minus after the predicate symbol.
      Returns:
      The inverse of this predicate.
    • getID

      public int getID()
      Gets the unique ID for this object. This ID uniquely identifies all objects of this type.

      Uniquely identifies this predicate among all predicates. Note that the inverse predicate has the same ID.

      Specified by:
      getID in interface IDable
      Returns:
      The unique ID of this predicate.
    • toSQL

      public String toSQL()
      Description copied from interface: OutputSQL
      Converts this object to an SQL query.
      Specified by:
      toSQL in interface OutputSQL
      Returns:
      An SQL query representing this object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeXML

      public void writeXML(IndentWriter writer)
      Description copied from interface: OutputXML
      Writes this object as XML to the given writer.
      Specified by:
      writeXML in interface OutputXML
      Parameters:
      writer - The writer to write to.
    • compareTo

      public int compareTo(Predicate o)
      Specified by:
      compareTo in interface Comparable<Predicate>