jlink.flowchart.graph
Class JLEdgeSet

java.lang.Object
  extended by jlink.flowchart.graph.JLEdgeSet

public class JLEdgeSet
extends java.lang.Object

The complete set of edges used in a JLGraph is modelled using this class. JLEdgeSet is as its name suggests a set of edges and methods to manipulate and search the set.

Author:
jasonkb

Field Summary
protected  java.util.LinkedList<JLEdge> edgeSet
          The inner data model of JLEdgeSet is a linked list with a JLEdge generic value.
 
Constructor Summary
JLEdgeSet()
          Creates a new instance of JLEdgeSet with a blank inner linked list.
JLEdgeSet(java.util.LinkedList<JLEdge> edges)
          Constructor to init this JLEdgeSet with the internal structure from another JLEdgeSet.
 
Method Summary
 void appendJLEdge(JLEdge e)
          Adds this JLEdge to the JLEdgeSet so that it can be included in the model.
 JLEdge getJLEdge(int edgeID)
          Query the JLEdgeSet for a JLEdge with this edge ID.
 JLEdge getJLEdge(int headVertexID, int tailVertexID)
          Query the JLEdgeSet for the first edge with the matching head and tail vertex IDs
 JLEdge getJLEdge(JLVertex vertex, int vertexType)
          Returns the first matching JLEdge that has this particular JLVertex as either a head or tail vertex.
 JLEdge getJLEdge(JLVertex headVertex, JLVertex tailVertex)
          Queries the JLEdgeSet for the first occurrence of a JLEdge with head and tail vertices matching the input parameters.
 JLEdge getJLEdge(java.lang.String edgeName)
          Searches the JLEdgeSet for the first occurrence of a JLEdge who has a name equal to the parameter.
 JLEdge getJLEdge(java.lang.String vertexName, int vertexType)
          Return the first JLEdge with a vertex (either head or tail) that has this name.
 JLEdge getJLEdge(java.lang.String headVertexName, java.lang.String tailVertexName)
          Query the JLEdgeSet for the first edge with the matching head and tail vertex names
 int getJLEdgeCount()
          Get the number of edges in this JLEdgeSet
 JLEdgeSet getJLEdges(int headVertexID, int tailVertexID)
          Query the JLEdgeSet for all edges with the matching head and tail vertex IDs
 JLEdgeSet getJLEdges(JLVertex vertex, int vertexType)
          Returns a JLEdgeSet with all the edges that have this particular JLVertex as either a head or tail vertex.
 JLEdgeSet getJLEdges(JLVertex headVertex, JLVertex tailVertex)
          Query the JLEdgeSet for all edges with the matching head and tail vertices.
 JLEdgeSet getJLEdges(java.lang.String edgeName)
          Returns all edges with the given edge name.
 JLEdgeSet getJLEdges(java.lang.String vertexName, int vertexType)
          Return all JLEdge objects with a vertex (either head or tail) that has this name.
 JLEdgeSet getJLEdges(java.lang.String headVertexName, java.lang.String tailVertexName)
          Query the JLEdgeSet for all edges with the matching head and tail vertex names
 java.util.LinkedList<JLEdge> getLinkedList()
          Use this method to get the inner linked list of JLEdgeSet if you need it to mirror in another JLGraph for instance.
 void mirrorJLEdgeSet(java.util.LinkedList<JLEdge> edges)
          This will make the internal linked list the same as the provided linked list so as to copy the internal data structure of another JLGraph.
 void removeJLEdge(int edgeID)
          Removes the specified JLEdge from this JLEdgeSet using the unique edge ID.
 void removeJLEdge(JLEdge e)
          Removes this JLEdge from this JLEdgeSet.
 void removeJLEdges(JLVertex vertex)
          Removes all JLEdge objects in this JLEdgeSet that have this JLVertex as either a head OR a tail vertex.
 void removeJLEdges(JLVertex vertex, int vertexType)
          Removes all edges that possess this JLVertex as either a head or tail vertex.
 void removeJLEdges(JLVertex headVertex, JLVertex tailVertex)
          Removes all JLEdge objects from JLEdgeSet that have both the head and tail vertices in common.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edgeSet

protected java.util.LinkedList<JLEdge> edgeSet
The inner data model of JLEdgeSet is a linked list with a JLEdge generic value. All accessor methods manipulate this structure in a safe and intuitive manner rather than the standard interfaces linked list provides. While you still can access and write over this inner model, it is advised against as the accessor methods make mores sense with respect to the API and are safer.

See Also:
mirrorJLEdgeSet(LinkedList edges), getLinkedList()
Constructor Detail

JLEdgeSet

public JLEdgeSet()
Creates a new instance of JLEdgeSet with a blank inner linked list.

Since:
1.0
See Also:
edgeSet

JLEdgeSet

public JLEdgeSet(java.util.LinkedList<JLEdge> edges)
Constructor to init this JLEdgeSet with the internal structure from another JLEdgeSet.

Parameters:
edges - The externally provided JLEdgeSet to be used in this JLEdgeSet.
See Also:
edgeSet
Method Detail

mirrorJLEdgeSet

public void mirrorJLEdgeSet(java.util.LinkedList<JLEdge> edges)
This will make the internal linked list the same as the provided linked list so as to copy the internal data structure of another JLGraph.

Parameters:
edges - The externally provided linked list to set the JLEdgeSet to.
See Also:
getLinkedList(), edgeSet

getLinkedList

public java.util.LinkedList<JLEdge> getLinkedList()
Use this method to get the inner linked list of JLEdgeSet if you need it to mirror in another JLGraph for instance. While it is possible to edit this list and "mirror" it back into the JLEdgeSet, this is advised against. Use general purpose constructors to alter the internal data structure as this is safer.

Returns:
The current linked list used as the internals of JLEdgeSet
See Also:
mirrorJLEdgeSet(LinkedList edges), edgeSet

appendJLEdge

public void appendJLEdge(JLEdge e)
                  throws DuplicateJLEdgeException
Adds this JLEdge to the JLEdgeSet so that it can be included in the model.

Parameters:
e - The JLEdge to be added.
Throws:
DuplicateJLEdgeException - If a duplicate edge ID is found (but not if a duplicate edge is found ie. same head a tail vertices but not the same ID).

removeJLEdge

public void removeJLEdge(JLEdge e)
Removes this JLEdge from this JLEdgeSet.

Parameters:
e - The JLEdge to be removed.

removeJLEdge

public void removeJLEdge(int edgeID)
Removes the specified JLEdge from this JLEdgeSet using the unique edge ID.

Parameters:
edgeID - The JLEdge unique ID that will be removed from this set.

removeJLEdges

public void removeJLEdges(JLVertex vertex)
Removes all JLEdge objects in this JLEdgeSet that have this JLVertex as either a head OR a tail vertex.

Parameters:
vertex - If a JLEdge connects with this JLVertex it will be removed.

removeJLEdges

public void removeJLEdges(JLVertex headVertex,
                          JLVertex tailVertex)
Removes all JLEdge objects from JLEdgeSet that have both the head and tail vertices in common.

Parameters:
headVertex - The JLVertex that is the head vertex.
tailVertex - The JLVertex that is the tail vertex.

removeJLEdges

public void removeJLEdges(JLVertex vertex,
                          int vertexType)
Removes all edges that possess this JLVertex as either a head or tail vertex.

Parameters:
vertex - The JLVertex to match against in the JLEdgeSet
vertexType - either JLEdge.VERTEX_HEAD or JLEdge.VERTEX_TAIL

getJLEdge

public JLEdge getJLEdge(int edgeID)
Query the JLEdgeSet for a JLEdge with this edge ID.

Parameters:
edgeID - The unique JLEdge identification number to search for.
Returns:
The JLEdge with this unique ID. Returns null if no edge is found.

getJLEdge

public JLEdge getJLEdge(JLVertex headVertex,
                        JLVertex tailVertex)
Queries the JLEdgeSet for the first occurrence of a JLEdge with head and tail vertices matching the input parameters. This method will return only the first occurrence of JLEdge matching these parameters. Consider using getJLEdges(JLVertex headVertex, JLVertex tailVertex) if you suspect there is more than one occurrence of a JLEdge meeting these conditions. This alternative method returns a JLEdgeSet that can be recursively searched further.

Parameters:
headVertex - The head JLVertex to search for.
tailVertex - The tail JLVertex to search for.
Returns:
The JLEdge matching the head JLVertex and tail JLVertex. Returns null if no matches are found.

getJLEdge

public JLEdge getJLEdge(java.lang.String edgeName)
Searches the JLEdgeSet for the first occurrence of a JLEdge who has a name equal to the parameter.

Parameters:
edgeName - The name to search against all edges in the JLEdgeSet
Returns:
The first matching JLEdge or null if no matches were found.

getJLEdge

public JLEdge getJLEdge(int headVertexID,
                        int tailVertexID)
Query the JLEdgeSet for the first edge with the matching head and tail vertex IDs

Parameters:
headVertexID - Unique ID for the head JLVertex.
tailVertexID - Unique ID for the tail JLVertex.
Returns:
The first matched edge or null if no matching edges.

getJLEdge

public JLEdge getJLEdge(java.lang.String headVertexName,
                        java.lang.String tailVertexName)
Query the JLEdgeSet for the first edge with the matching head and tail vertex names

Parameters:
headVertexName - The name for the head JLVertex.
tailVertexName - The name for the tail JLVertex.
Returns:
The first matched edge or null if no matching edges.

getJLEdge

public JLEdge getJLEdge(java.lang.String vertexName,
                        int vertexType)
Return the first JLEdge with a vertex (either head or tail) that has this name.

Parameters:
vertexName - The JLVertex name to query all edges with.
vertexType - Either JLEdge.VERTEX_HEAD or JLEdge.VERTEX_TAIL
Returns:
A JLEdge containing the first matched edge or null if no matches.

getJLEdge

public JLEdge getJLEdge(JLVertex vertex,
                        int vertexType)
Returns the first matching JLEdge that has this particular JLVertex as either a head or tail vertex.

Parameters:
vertex - The JLVertex to query all edges against.
vertexType - Either JLEdge.VERTEX_HEAD or JLEdge.VERTEX_TAIL
Returns:
A JLEdge containing the first matched edge or null if no matches.

getJLEdges

public JLEdgeSet getJLEdges(JLVertex headVertex,
                            JLVertex tailVertex)
Query the JLEdgeSet for all edges with the matching head and tail vertices.

Parameters:
headVertex - The head JLVertex to search for matching edges (JLEdge)
tailVertex - The tail JLVertex to search for matching edges (JLEdge)
Returns:
A JLEdgeSet containing the matched edges.

getJLEdges

public JLEdgeSet getJLEdges(int headVertexID,
                            int tailVertexID)
Query the JLEdgeSet for all edges with the matching head and tail vertex IDs

Parameters:
headVertexID - Unique ID for the head JLVertex.
tailVertexID - Unique ID for the tail JLVertex.
Returns:
A JLEdgeSet containing the matched edges.

getJLEdges

public JLEdgeSet getJLEdges(java.lang.String headVertexName,
                            java.lang.String tailVertexName)
Query the JLEdgeSet for all edges with the matching head and tail vertex names

Parameters:
headVertexName - Name for the head JLVertex.
tailVertexName - Name for the tail JLVertex.
Returns:
A JLEdgeSet containing the matched edges.

getJLEdges

public JLEdgeSet getJLEdges(java.lang.String edgeName)
Returns all edges with the given edge name.

Parameters:
edgeName - The JLEdgeSet with all matched edges.
Returns:
A JLEdgeSet containing the matched edges.

getJLEdges

public JLEdgeSet getJLEdges(java.lang.String vertexName,
                            int vertexType)
Return all JLEdge objects with a vertex (either head or tail) that has this name.

Parameters:
vertexName - The JLVertex name to query all edges with.
vertexType - Either JLEdge.VERTEX_HEAD or JLEdge.VERTEX_TAIL
Returns:
A JLEdgeSet containing the matched edges.

getJLEdges

public JLEdgeSet getJLEdges(JLVertex vertex,
                            int vertexType)
Returns a JLEdgeSet with all the edges that have this particular JLVertex as either a head or tail vertex.

Parameters:
vertex - The JLVertex to query all edges against.
vertexType - Either JLEdge.VERTEX_HEAD or JLEdge.VERTEX_TAIL
Returns:
A JLEdgeSet containing the matched edges.

getJLEdgeCount

public int getJLEdgeCount()
Get the number of edges in this JLEdgeSet

Returns:
The JLEdge count for this JLEdgeSet