Skip to content

Method: interpret(CommunicationManager)

1: package pruefskript.parser.nodes;
2:
3: import java.util.ArrayList;
4: import java.util.Iterator;
5: import java.util.List;
6:
7: import basic.PruefskriptConstants;
8: import pruefskript.CommunicationManager;
9: import pruefskript.parser.exceptions.CheckScriptException;
10: import pruefskript.parser.values.VoidValue;
11:
12: /**
13: * This will suppress all the PMD warnings in this class.
14: *
15: * @author group B5
16: *
17: */
18: public class InputNode extends AbstractNode {
19:         /**
20:          * List lineNodes.
21:          */
22:         private final List<LineNode> lineNodes;
23:
24:         /**
25:          *
26:          * @param operand1
27:          * LineNode
28:          */
29:         public InputNode(final LineNode operand1) {
30:                 super();
31:                 this.lineNodes = new ArrayList<LineNode>();
32:                 this.lineNodes.add(operand1);
33:         }
34:
35:         @Override
36:         public String toString() {
37:                 final StringBuffer input = new StringBuffer();
38:                 final Iterator<LineNode> it = this.lineNodes.iterator();
39:                 while (it.hasNext()) {
40:                         input.append(it.next().toString());
41:                 }
42:                 return PruefskriptConstants.INPUTNODETITLE + PruefskriptConstants.BRACKET_OPEN
43:                                 + input.toString() + PruefskriptConstants.BRACKET_CLOSE;
44:         }
45:
46:         @Override
47:         public boolean equals(final Object obj) {
48:                 return obj instanceof InputNode && ((InputNode) obj).lineNodes.equals(this.lineNodes);
49:
50:         }
51:
52:         @Override
53:         public int hashCode() {
54:                 return this.lineNodes.hashCode();
55:         }
56:
57:         /**
58:          * Ueber die Liste von Knoten wird iteriert und jeder Wert wird interpretiert, bis jedes Element
59:          * der Liste interpretiert wurde. Der Nichts-Wert wird zurueckgegeben.
60:          */
61:         @Override
62:         public VoidValue interpret(final CommunicationManager mgr) throws CheckScriptException {
63:                 final Iterator<LineNode> it = this.lineNodes.iterator();
64:•                while (it.hasNext()) {
65:                         it.next().interpret(mgr);
66:                 }
67:                 return new VoidValue();
68:         }
69:
70:         /**
71:          * Adds a LineNode to the InputNode.
72:          *
73:          * @param obj
74:          * LineNode
75:          */
76:         public void add(final LineNode obj) {
77:                 this.lineNodes.add(obj);
78:         }
79: }