Package edu.fiu.jtlex.timeml.data
Class TimeMLSubGraph
java.lang.Object
edu.fiu.jtlex.timeml.data.TimeMLGraph
edu.fiu.jtlex.timeml.data.TimeMLSubGraph
- All Implemented Interfaces:
ITimeMLGraph,Cloneable
Represents a TimeML SubGraph, based on
ITimeMLGraph.- Since:
- jTLEX 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.fiu.jtlex.timeml.data.ITimeMLGraph
ITimeMLGraph.GraphType -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty graph.TimeMLSubGraph(InputStream stream) Utilizes anITimeMLParserto parse a stream into nodes and edges, and adds them to the graph.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. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddLink(ITimeMLLink link) Adds a link to the graph.booleanaddNode(ITimeMLNode node) Adds a node to the subgraph, also adds node to main graph.clone()Creates a clone of the subgraph by creating a new graph object and sending a copy of the nodes and links.booleanChecks if this graph equals an object.Gets the Graph's type.Returns the InLinks in the graph.getLinkById(int linkId) Gets a link by id.getLinks()Returns all the links in the graph.getNodeById(int nodeId) Gets a node by id.getNodes()Returns all the nodes in the graph.Returns the OutLinks in the graph.Returns the parent graph.inthashCode()Generates a hash code for the graph, based of its nodes and edges.booleanremoveLink(ITimeMLLink link) Removes a link from the subgraph, also removes link from main graph.booleanremoveLinkById(int linkId) Removes a link by id from subgraph, also removes link from main graph.booleanremoveNode(ITimeMLNode node) Removes a node from the subgraph, also removes node from main graph.booleanremoveNodeById(int nodeId) Removes a node by id from subgraph, also removes node from main graph.toJson()Returns the JSON (RFC 8259) representation of the graph.toString()Gets a printable string representation of the graph.Methods inherited from class edu.fiu.jtlex.timeml.data.TimeMLGraph
subGraph
-
Constructor Details
-
TimeMLSubGraph
public TimeMLSubGraph()Creates an empty graph. -
TimeMLSubGraph
Utilizes anITimeMLParserto 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 ofITimeMLNode.links- The set ofITimeMLLink.parent- the parentITimeMLGraph.isMainSubGraph- changes the type to Main Subordination Graph if true- Throws:
NullPointerException- If any of the parameters are nullIllegalArgumentException- if the links contain an S-Link- Since:
- jTLEX 1.0
-
-
Method Details
-
addLink
Adds a link to the graph. Must have nodes already in Graph.- Specified by:
addLinkin interfaceITimeMLGraph- Overrides:
addLinkin classTimeMLGraph- 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
Gets a node by id.- Specified by:
getNodeByIdin interfaceITimeMLGraph- Overrides:
getNodeByIdin classTimeMLGraph- 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
Gets a link by id.- Specified by:
getLinkByIdin interfaceITimeMLGraph- Overrides:
getLinkByIdin classTimeMLGraph- 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
Removes a link from the subgraph, also removes link from main graph.- Specified by:
removeLinkin interfaceITimeMLGraph- Overrides:
removeLinkin classTimeMLGraph- 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:
removeLinkByIdin interfaceITimeMLGraph- Overrides:
removeLinkByIdin classTimeMLGraph- 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
Adds a node to the subgraph, also adds node to main graph.- Specified by:
addNodein interfaceITimeMLGraph- Overrides:
addNodein classTimeMLGraph- 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
Removes a node from the subgraph, also removes node from main graph.- Specified by:
removeNodein interfaceITimeMLGraph- Overrides:
removeNodein classTimeMLGraph- 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:
removeNodeByIdin interfaceITimeMLGraph- Overrides:
removeNodeByIdin classTimeMLGraph- Parameters:
nodeId- The id of the node to remove.- Returns:
- True if removed, false otherwise.
- Since:
- jTLEX 1.0
-
getNodes
Returns all the nodes in the graph. Modifying this set won't modify the actual graph's node set.- Specified by:
getNodesin interfaceITimeMLGraph- Overrides:
getNodesin classTimeMLGraph- Returns:
- A copy of the set of the nodes in the graph.
- Since:
- jTLEX 1.0
-
getLinks
Returns all the links in the graph. Modifying this set won't modify the actual graph's link set.- Specified by:
getLinksin interfaceITimeMLGraph- Overrides:
getLinksin classTimeMLGraph- Returns:
- A copy of the set of the links in the graph.
- Since:
- jTLEX 1.0
-
getOutLinks
Returns the OutLinks in the graph.- Specified by:
getOutLinksin interfaceITimeMLGraph- Overrides:
getOutLinksin classTimeMLGraph- Returns:
- A map with the OutLinks in the graph.
- Since:
- jTLEX 1.0
-
getInLinks
Returns the InLinks in the graph.- Specified by:
getInLinksin interfaceITimeMLGraph- Overrides:
getInLinksin classTimeMLGraph- Returns:
- A map of the InLinks in the graph.
- Since:
- jTLEX 1.0
-
getGraphType
Gets the Graph's type.- Specified by:
getGraphTypein interfaceITimeMLGraph- Overrides:
getGraphTypein classTimeMLGraph- Returns:
- A
ITimeMLGraph.GraphTyperepresenting the graph type. - Since:
- jTLEX 1.0
-
getParentGraph
Returns the parent graph.- Specified by:
getParentGraphin interfaceITimeMLGraph- Overrides:
getParentGraphin classTimeMLGraph- Returns:
- the parent graph.
- Since:
- jTLEX 1.0
-
clone
Creates a clone of the subgraph by creating a new graph object and sending a copy of the nodes and links.- Specified by:
clonein interfaceITimeMLGraph- Overrides:
clonein classTimeMLGraph- Returns:
- A copy of the graph.
- Since:
- jTLEX 1.0
-
toJson
Returns the JSON (RFC 8259) representation of the graph.- Specified by:
toJsonin interfaceITimeMLGraph- Overrides:
toJsonin classTimeMLGraph- Returns:
- A flattened JSON string of the graph.
- Since:
- jTLEX 1.0
-
toString
Gets a printable string representation of the graph.- Overrides:
toStringin classTimeMLGraph- 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:
hashCodein interfaceITimeMLGraph- Overrides:
hashCodein classTimeMLGraph- Returns:
- The hash code.
- Since:
- jTLEX 1.0
-
equals
Checks if this graph equals an object.- Specified by:
equalsin interfaceITimeMLGraph- Overrides:
equalsin classTimeMLGraph- 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
-