|
8 | 8 | import org.apache.logging.log4j.Logger; |
9 | 9 |
|
10 | 10 | public class Edge extends TagSupport { |
11 | | - private static final long serialVersionUID = 1L; |
| 11 | + private static final long serialVersionUID = 1L; |
12 | 12 | static Logger logger = LogManager.getLogger(Edge.class); |
13 | 13 |
|
14 | | - GraphNode sourceNode = null; |
15 | | - GraphNode targetNode = null; |
16 | | - GraphEdge currentEdge = null; |
17 | | - String source = null; |
18 | | - String target = null; |
19 | | - double weight = 0.0; |
20 | | - |
21 | | - public int doStartTag() throws JspException { |
22 | | - Graph theGraph = (Graph) findAncestorWithClass(this, Graph.class); |
23 | | - EdgeIterator theIterator = (EdgeIterator) findAncestorWithClass(this, EdgeIterator.class); |
24 | | - |
25 | | - if (theIterator == null) { |
26 | | - logger.trace("Adding edge source: " + source + "\ttarget: " + target + "\tweight: " + weight); |
27 | | - GraphNode sourceNode = theGraph.getNode(source); |
28 | | - GraphNode targetNode = theGraph.getNode(target); |
29 | | - if (sourceNode == null) { |
30 | | - logger.error("source node missing for edge <" + source + ", " + target + ">"); |
31 | | - } else if (targetNode == null) { |
32 | | - logger.error("target node missing for edge <" + source + ", " + target + ">"); |
33 | | - } else |
34 | | - theGraph.addEdge(new GraphEdge(sourceNode, targetNode, weight)); |
35 | | - return SKIP_BODY; |
36 | | - } else { |
37 | | - currentEdge = theIterator.currentEdge; |
38 | | - sourceNode = theIterator.currentEdge.getSource(); |
39 | | - targetNode = theIterator.currentEdge.getTarget(); |
40 | | - weight = theIterator.currentEdge.getWeight(); |
41 | | - // return EVAL_BODY_INCLUDE; |
| 14 | + GraphNode sourceNode = null; |
| 15 | + GraphNode targetNode = null; |
| 16 | + GraphEdge currentEdge = null; |
| 17 | + String source = null; |
| 18 | + String target = null; |
| 19 | + double weight = 0.0; |
| 20 | + int auxInt = 0; |
| 21 | + String auxString = null; |
| 22 | + double auxDouble = 0.0; |
| 23 | + |
| 24 | + public int doStartTag() throws JspException { |
| 25 | + Graph theGraph = (Graph) findAncestorWithClass(this, Graph.class); |
| 26 | + EdgeIterator theIterator = (EdgeIterator) findAncestorWithClass(this, EdgeIterator.class); |
| 27 | + |
| 28 | + if (theIterator == null) { |
| 29 | + logger.trace("Adding edge source: " + source + "\ttarget: " + target + "\tweight: " + weight); |
| 30 | + GraphNode sourceNode = theGraph.getNode(source); |
| 31 | + GraphNode targetNode = theGraph.getNode(target); |
| 32 | + if (sourceNode == null) { |
| 33 | + logger.error("source node missing for edge <" + source + ", " + target + ">"); |
| 34 | + } else if (targetNode == null) { |
| 35 | + logger.error("target node missing for edge <" + source + ", " + target + ">"); |
| 36 | + } else if (weight == 0) { |
| 37 | + logger.error("edge weight cannot be 0"); |
| 38 | + } else |
| 39 | + theGraph.addEdge(new GraphEdge(sourceNode, targetNode, weight, auxInt, auxString, auxDouble)); |
| 40 | + return SKIP_BODY; |
| 41 | + } else { |
| 42 | + currentEdge = theIterator.currentEdge; |
| 43 | + sourceNode = theIterator.currentEdge.getSource(); |
| 44 | + targetNode = theIterator.currentEdge.getTarget(); |
| 45 | + weight = theIterator.currentEdge.getWeight(); |
| 46 | + auxInt = theIterator.currentEdge.getAuxInt(); |
| 47 | + auxString = theIterator.currentEdge.getAuxString(); |
| 48 | + auxDouble = theIterator.currentEdge.getAuxDouble(); |
| 49 | + // return EVAL_BODY_INCLUDE; |
| 50 | + } |
| 51 | + |
| 52 | + // currentEdge = theIterator.currentEdge; |
| 53 | + logger.trace(""); |
| 54 | + return EVAL_BODY_INCLUDE; |
| 55 | + } |
| 56 | + |
| 57 | + public int doEndTag() throws JspTagException, JspException { |
| 58 | + clearServiceState(); |
| 59 | + return super.doEndTag(); |
| 60 | + } |
| 61 | + |
| 62 | + private void clearServiceState() { |
| 63 | + sourceNode = null; |
| 64 | + targetNode = null; |
| 65 | + currentEdge = null; |
| 66 | + source = null; |
| 67 | + target = null; |
| 68 | + weight = 0; |
| 69 | + } |
| 70 | + |
| 71 | + public String getSource() { |
| 72 | + return source; |
| 73 | + } |
| 74 | + |
| 75 | + public void setSource(String source) { |
| 76 | + this.source = source; |
| 77 | + } |
| 78 | + |
| 79 | + public String getTarget() { |
| 80 | + return target; |
| 81 | + } |
| 82 | + |
| 83 | + public void setTarget(String target) { |
| 84 | + this.target = target; |
42 | 85 | } |
43 | 86 |
|
44 | | - // currentEdge = theIterator.currentEdge; |
45 | | - logger.trace(""); |
46 | | - return EVAL_BODY_INCLUDE; |
47 | | - } |
48 | | - |
49 | | - public int doEndTag() throws JspTagException, JspException { |
50 | | - clearServiceState(); |
51 | | - return super.doEndTag(); |
52 | | - } |
53 | | - |
54 | | - private void clearServiceState() { |
55 | | - sourceNode = null; |
56 | | - targetNode = null; |
57 | | - currentEdge = null; |
58 | | - source = null; |
59 | | - target = null; |
60 | | - weight = 0; |
61 | | - } |
62 | | - |
63 | | - public String getSource() { |
64 | | - return source; |
65 | | - } |
66 | | - |
67 | | - public void setSource(String source) { |
68 | | - this.source = source; |
69 | | - } |
70 | | - |
71 | | - public String getTarget() { |
72 | | - return target; |
73 | | - } |
74 | | - |
75 | | - public void setTarget(String target) { |
76 | | - this.target = target; |
77 | | - } |
78 | | - |
79 | | - public double getWeight() { |
80 | | - return weight; |
81 | | - } |
82 | | - |
83 | | - public void setWeight(double weight) { |
84 | | - this.weight = weight; |
85 | | - } |
| 87 | + public double getWeight() { |
| 88 | + return weight; |
| 89 | + } |
| 90 | + |
| 91 | + public void setWeight(double weight) { |
| 92 | + this.weight = weight; |
| 93 | + } |
| 94 | + |
| 95 | + public int getAuxInt() { |
| 96 | + return auxInt; |
| 97 | + } |
| 98 | + |
| 99 | + public void setAuxInt(int auxInt) { |
| 100 | + this.auxInt = auxInt; |
| 101 | + } |
| 102 | + |
| 103 | + public String getAuxString() { |
| 104 | + return auxString; |
| 105 | + } |
| 106 | + |
| 107 | + public void setAuxString(String auxString) { |
| 108 | + this.auxString = auxString; |
| 109 | + } |
| 110 | + |
| 111 | + public double getAuxDouble() { |
| 112 | + return auxDouble; |
| 113 | + } |
| 114 | + |
| 115 | + public void setAuxDouble(double auxDouble) { |
| 116 | + this.auxDouble = auxDouble; |
| 117 | + } |
86 | 118 | } |
0 commit comments