Class TimeMLSubGraph

java.lang.Object
edu.fiu.jtlex.timeml.data.TimeMLGraph
edu.fiu.jtlex.timeml.data.TimeMLSubGraph
All Implemented Interfaces:
ITimeMLGraph, Cloneable

public class TimeMLSubGraph extends TimeMLGraph
Represents a TimeML SubGraph, based on ITimeMLGraph.
Since:
jTLEX 1.0
  • Constructor Details

    • TimeMLSubGraph

      public TimeMLSubGraph()
      Creates an empty graph.
    • TimeMLSubGraph

      public TimeMLSubGraph(InputStream stream)
      Utilizes an ITimeMLParser to parse a stream into nodes and edges, and adds them to the graph.
      Parameters:
      stream - The InputStream to parse
      Throws:
      NullPointerException - If the stream is null
      Since:
      jTLEX 1.0
    • TimeMLSubGraph

      public TimeMLSubGraph(Set<ITimeMLNode> nodes, Set<ITimeMLLink> links, ITimeMLGraph parent, boolean isMainSubGraph)
      Creates a sub graph based on a set of links and nodes as well as it's parent.
      Parameters:
      nodes - The set of ITimeMLNode.
      links - The set of ITimeMLLink.
      parent - the parent ITimeMLGraph.
      isMainSubGraph - changes the type to Main Subordination Graph if true
      Throws:
      NullPointerException - If any of the parameters are null
      IllegalArgumentException - if the links contain an S-Link
      Since:
      jTLEX 1.0
  • Method Details

    • addLink

      public boolean addLink(ITimeMLLink link)
      Adds a link to the graph. Must have nodes already in Graph.
      Specified by:
      addLink in interface ITimeMLGraph
      Overrides:
      addLink in class TimeMLGraph
      Parameters:
      link - The ILink to be added.
      Returns:
      True if the link was added, otherwise it returns false if the link already exists or if the nodes were not in the graph, and as a result, the link is not added.
      Throws:
      NullPointerException - If the link is null
      Since:
      jTLEX 1.0
    • getNodeById

      public ITimeMLNode getNodeById(int nodeId)
      Gets a node by id.
      Specified by:
      getNodeById in interface ITimeMLGraph
      Overrides:
      getNodeById in class TimeMLGraph
      Parameters:
      nodeId - The id of the node to retrieve.
      Returns:
      The node with the given id, or null if no such node exist.
      Since:
      jTLEX 1.0
    • getLinkById

      public ITimeMLLink getLinkById(int linkId)
      Gets a link by id.
      Specified by:
      getLinkById in interface ITimeMLGraph
      Overrides:
      getLinkById in class TimeMLGraph
      Parameters:
      linkId - The id of the link to retrieve.
      Returns:
      The link with the given id, or null if no such link exist.
      Since:
      jTLEX 1.0
    • removeLink

      public boolean removeLink(ITimeMLLink link)
      Removes a link from the subgraph, also removes link from main graph.
      Specified by:
      removeLink in interface ITimeMLGraph
      Overrides:
      removeLink in class TimeMLGraph
      Parameters:
      link - The ILink to remove.
      Returns:
      true if link is removed, false if not removed or if link was not found.
      Throws:
      NullPointerException - If ILink is null
      Since:
      jTLEX 1.0
    • removeLinkById

      public boolean removeLinkById(int linkId)
      Removes a link by id from subgraph, also removes link from main graph.
      Specified by:
      removeLinkById in interface ITimeMLGraph
      Overrides:
      removeLinkById in class TimeMLGraph
      Parameters:
      linkId - The id of the link to remove.
      Returns:
      true if the link is removed, false if not removed or if link was not found.
      Since:
      jTLEX 1.0
    • addNode

      public boolean addNode(ITimeMLNode node)
      Adds a node to the subgraph, also adds node to main graph.
      Specified by:
      addNode in interface ITimeMLGraph
      Overrides:
      addNode in class TimeMLGraph
      Parameters:
      node - The node to add
      Returns:
      True if the node was added, or False if the node already exists.
      Throws:
      NullPointerException - If the node is null
      Since:
      jTLEX 1.0
    • removeNode

      public boolean removeNode(ITimeMLNode node)
      Removes a node from the subgraph, also removes node from main graph.
      Specified by:
      removeNode in interface ITimeMLGraph
      Overrides:
      removeNode in class TimeMLGraph
      Parameters:
      node - The node to remove.
      Returns:
      True if removed, false otherwise.
      Throws:
      NullPointerException - If the node is null
      Since:
      jTLEX 1.0
    • removeNodeById

      public boolean removeNodeById(int nodeId)
      Removes a node by id from subgraph, also removes node from main graph.
      Specified by:
      removeNodeById in interface ITimeMLGraph
      Overrides:
      removeNodeById in class TimeMLGraph
      Parameters:
      nodeId - The id of the node to remove.
      Returns:
      True if removed, false otherwise.
      Since:
      jTLEX 1.0
    • getNodes

      public Set<ITimeMLNode> getNodes()
      Returns all the nodes in the graph. Modifying this set won't modify the actual graph's node set.
      Specified by:
      getNodes in interface ITimeMLGraph
      Overrides:
      getNodes in class TimeMLGraph
      Returns:
      A copy of the set of the nodes in the graph.
      Since:
      jTLEX 1.0
    • getLinks

      public Set<ITimeMLLink> getLinks()
      Returns all the links in the graph. Modifying this set won't modify the actual graph's link set.
      Specified by:
      getLinks in interface ITimeMLGraph
      Overrides:
      getLinks in class TimeMLGraph
      Returns:
      A copy of the set of the links in the graph.
      Since:
      jTLEX 1.0
    • getOutLinks

      public Map<String,Set<ITimeMLLink>> getOutLinks()
      Returns the OutLinks in the graph.
      Specified by:
      getOutLinks in interface ITimeMLGraph
      Overrides:
      getOutLinks in class TimeMLGraph
      Returns:
      A map with the OutLinks in the graph.
      Since:
      jTLEX 1.0
    • getInLinks

      public Map<String,Set<ITimeMLLink>> getInLinks()
      Returns the InLinks in the graph.
      Specified by:
      getInLinks in interface ITimeMLGraph
      Overrides:
      getInLinks in class TimeMLGraph
      Returns:
      A map of the InLinks in the graph.
      Since:
      jTLEX 1.0
    • getGraphType

      public ITimeMLGraph.GraphType getGraphType()
      Gets the Graph's type.
      Specified by:
      getGraphType in interface ITimeMLGraph
      Overrides:
      getGraphType in class TimeMLGraph
      Returns:
      A ITimeMLGraph.GraphType representing the graph type.
      Since:
      jTLEX 1.0
    • getParentGraph

      public ITimeMLGraph getParentGraph()
      Returns the parent graph.
      Specified by:
      getParentGraph in interface ITimeMLGraph
      Overrides:
      getParentGraph in class TimeMLGraph
      Returns:
      the parent graph.
      Since:
      jTLEX 1.0
    • clone

      public ITimeMLGraph clone()
      Creates a clone of the subgraph by creating a new graph object and sending a copy of the nodes and links.
      Specified by:
      clone in interface ITimeMLGraph
      Overrides:
      clone in class TimeMLGraph
      Returns:
      A copy of the graph.
      Since:
      jTLEX 1.0
    • toJson

      public String toJson()
      Returns the JSON (RFC 8259) representation of the graph.
      Specified by:
      toJson in interface ITimeMLGraph
      Overrides:
      toJson in class TimeMLGraph
      Returns:
      A flattened JSON string of the graph.
      Since:
      jTLEX 1.0
    • toString

      public String toString()
      Gets a printable string representation of the graph.
      Overrides:
      toString in class TimeMLGraph
      Returns:
      A printable string representation of the graph.
      Since:
      jTLEX 1.0
    • hashCode

      public int hashCode()
      Generates a hash code for the graph, based of its nodes and edges.
      Specified by:
      hashCode in interface ITimeMLGraph
      Overrides:
      hashCode in class TimeMLGraph
      Returns:
      The hash code.
      Since:
      jTLEX 1.0
    • equals

      public boolean equals(Object o)
      Checks if this graph equals an object.
      Specified by:
      equals in interface ITimeMLGraph
      Overrides:
      equals in class TimeMLGraph
      Parameters:
      o - The object to compare against.
      Returns:
      True if both graphs are equal, i.e. same set of nodes and links, or else false.
      Throws:
      NullPointerException - If the object to compare against is false.
      Since:
      jTLEX 1.0